Skip to content

fix: handle invalid JSON in semgrep parser and add unit tests#1741

Open
vedasingh00-rgb wants to merge 2 commits into
utksh1:mainfrom
vedasingh00-rgb:fix/semgrep-parser-tests
Open

fix: handle invalid JSON in semgrep parser and add unit tests#1741
vedasingh00-rgb wants to merge 2 commits into
utksh1:mainfrom
vedasingh00-rgb:fix/semgrep-parser-tests

Conversation

@vedasingh00-rgb

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

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

image

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 added the gssoc:approved Admin validation: approved for GSSoC scoring label Jul 9, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label area:plugins Scanner plugin metadata, schemas, or plugin runtime work type:testing Testing work category bonus label labels Jul 9, 2026
@vedasingh00-rgb

Copy link
Copy Markdown
Contributor Author

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

@vedasingh00-rgb vedasingh00-rgb force-pushed the fix/semgrep-parser-tests branch from cec5256 to 0177a0d Compare July 10, 2026 06:33
@vedasingh00-rgb

Copy link
Copy Markdown
Contributor Author

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.

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

Labels

area:plugins Scanner plugin metadata, schemas, or plugin runtime work gssoc:approved Admin validation: approved for GSSoC scoring level:intermediate 35 pts difficulty label for moderate contributor PRs type:bug Bug fix work category bonus label type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants