-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display positions in RuleCodeDuplicate errors (#735)
Summary: **Pre-submission checklist** - [x] 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` - [x] `pre-commit run` Display positions of where duplicate rule codes appear in RuleCodeDuplicate taint configuration errors. Previously rule codes were only checked for uniqueness within a single taint.config file. This leads to unintended results when multiple rules share the same code in multiple taint.config files under analysis. The errors emitted also lacked positioning information which makes it harder to find where duplicate rule codes occurred. Adds ability to cross validate rule codes as now like source and sink uniqueness checks, rule codes are checked after all taint.config files are parsed. Also Since we now store positioning information for all parsed taint.config nodes, adds position information of the previous and current location when a rule code appears. Since uniqueness is checked after parsing, modifies Rules module to contain the taint config path and location to be used in error messages - created a module in jsonParsing.ml for the same. Other minor changes: - Update tests to check for the new sort of RuleDuplicate error - Update tests to conform to the updated rule records Pull Request resolved: #735 Test Plan: - Before the changes, ran pysa on `documentaiton/pysa_tutorial/exercise1/`: <img width="1179" alt="Screenshot 2023-05-06 at 1 17 36 PM" src="https://user-images.githubusercontent.com/8947010/236805900-3d42af02-c06f-4663-8286-d432bc1a74a5.png"> - After the changes with default `taint.config`: <img width="983" alt="Screenshot 2023-05-27 at 5 28 55 PM" src="https://github.com/facebook/pyre-check/assets/8947010/c86d4267-0151-4a1d-a6d6-e2472ae021c8"> - After the changes with the following `taint.config`: ```json { "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" } ] } ``` <img width="1039" alt="Screenshot 2023-05-31 at 2 06 36 PM" src="https://github.com/facebook/pyre-check/assets/8947010/e0125754-5859-481b-b372-7796ba9166e5"> - Ran tests with `make test`. Fixes part of MLH-Fellowship#82 Footnotes: - Pysa Github CI Action was failing before this PR Reviewed By: tianhan0 Differential Revision: D46352827 Pulled By: arthaud fbshipit-source-id: e6e3bc30939990a95cf8bea2071f930aa642d989
- Loading branch information
1 parent
4eb3bbe
commit dbdb32b
Showing
8 changed files
with
234 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.