fix: handle invalid JSON in semgrep parser and add unit tests - #1741
Conversation
utksh1
left a comment
There was a problem hiding this comment.
The semgrep JSON-handling fix and tests look good, but the branch has merge conflicts. Please rebase on latest main and push again — should be straightforward to land after that.
Ok, I will fix it |
cec5256 to
0177a0d
Compare
|
Hi @utksh1, I have resolved the merge conflicts and also noticed a checksum mismatch in plugins/semgrep_scanner/metadata.json due to the parser changes — so I ran refresh_plugin_checksum.py to update it. All CI checks are passing now. Please review when you get a chance. |
utksh1
left a comment
There was a problem hiding this comment.
Approved after follow-up changes addressed the previous review request. CI is green.
Description
Fixed the semgrep_scanner parser to handle invalid JSON gracefully instead of silently ignoring errors. Added unit tests to verify all three scenarios — valid JSON, invalid JSON, and mixed stdout output.
Related Issues
#1421
Type of Change
How Has This Been Tested?
Added 3 unit tests in testing/test_semgrep_parser.py and ran them using pytest:
test_valid_json — verifies valid Semgrep JSON is parsed correctly
test_invalid_json — verifies invalid JSON does not crash the parser
test_mixed_stdout — verifies mixed stdout is handled gracefully
Checklist