Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display TaintConfig Error locations when available #739

Closed

Conversation

abishekvashok
Copy link
Contributor

@abishekvashok abishekvashok commented May 31, 2023

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

Display TaintConfigurationError locations when available. The Ocaml binary now returns positions after Github PR: #734 (commit 59d2cf0). Parse and print when the location(s) are available.

Test Plan

Invocation command in all of the below: python3 -m pyre-check.client.pyre analyze --no-verify

  • Run pyre check with the following faulty taint.config: (modify documentation/pysa_tutorial/exercise1)
{
  "sources": [
    {
      "name": "CustomUserControlled",
      "comment": "use to annotate user input"
    }
  ],

  "sinks": [
    {
      "name": "CodeExecution",
      "comment": "use to annotate execution of python code"
    }
  ],

  "features": [],

  "rules": [
    {
      "name": "Possible RCE:",
      "code": 5001,
      "sources": [ "CustomUserControlled" ],
      "sinks": [ "CodeExecution" ],
      "message_format": "User specified data may reach a code execution sink"
    }
    {
      "name": "test-duplicate",
      "code": 5001,
      "sources": [ "CustomUserControlled" ],
      "sinks": [ "CodeExecution" ],
      "message_format": "duplicate"
    }
  ]
}
  • Before:
Screenshot 2023-05-31 at 2 45 34 PM
  • After:
Screenshot 2023-05-31 at 2 36 49 PM
  • Run with the stock taint.config: (same results before and after)
Screenshot 2023-05-31 at 2 48 33 PM
  • tox -e py

  • Github Actions (pysa action was failing before this PR and is failing due to an unrelated issue - possibly outdated opam cache?)

Fixes part of MLH-Fellowship#82
Signed-off-by: Abishek V Ashok [email protected]

Display TaintConfigurationError locations when available. The Ocaml
binary now returns positions after Github PR: facebook#734
(commit 59d2cf0). Parse and print when
the location(s) are available.

Adds test for the same and updates two existing ones.

Signed-off-by: Abishek V Ashok <[email protected]>
Comment on lines +170 to +171
error_location = error_json["location"]
if error_location is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: does that mean that we export something like "location": null when we don't have a location? That's a bit odd, I would just expect to not have the key.

Copy link
Contributor Author

@abishekvashok abishekvashok Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes making the key not be present would be much more ideal :) would require changes to the binary though. Will make those changes :)

@facebook-github-bot
Copy link
Contributor

@arthaud has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@arthaud merged this pull request in 2ba88c3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants