Repository navigation
fix(report): parse line ranges and multi-site locations in SAST and secret scanning - #137
kushaldave002 wants to merge 2 commits into
Conversation
…ecret scanning - Parse line ranges, bare line continuations, and multi-file locations into structured locations - Recompute primary-path fingerprints in migration with deterministic row collapse - Preserve reviewer sign-off status across migration and subsequent scans - Format SARIF locations[] per site with region startLine/endLine Fixes secfoo-com#112
|
Thanks for this, @kushaldave002. The parser part is solid: all four real NodeGoat locations from #112 parse correctly, and Windows paths ( Blocking: the migration rewrites fingerprints without the line-bucket and region-hash parts
Suggested fix
Also worth fixing in the next PR
Happy to look at the next version. |
Summary
Fixes #112.
When SAST or secret scanning agents report findings with line ranges (e.g.
server.js:78-102), bare line continuations (app/data/user-dao.js:25, :61), or multi-file locations (server.js:135-137, app/views/layout.html:75), the entire raw string was previously placed intolocation_filewithlocation_line = NULL. In SARIF output, this produced invalid or single-point regions, and web UI templates could not navigate individual sites.This PR addresses all parser requirements, SARIF formatting, UI display, and crucially addresses maintainer review feedback on PR #129 regarding fingerprint migration, duplicate collapse, and reviewer sign-off preservation.
Key Changes
parse_locations):file.py:10), line ranges (file.py:10-25), bare line continuations (file.py:10, :25), and multi-file locations (file1.py:10, file2.py:20).location_fileto the primary path andlocation_lineto the primary start line._migrate_finding_locations):locationsJSON column onsast_findingsandsecret_findings.review_status>status == 'open'> earliestfirst_seen_at>id).review_status,review_note,reviewed_by,reviewed_at) is preserved onto the primary row.<new_fp>:merged:<id>so they satisfy the uniqueness constraint without colliding on future scans.locations[]for each site withphysicalLocation.region.startLineandendLine.Verification
tests/test_property_parsers.py.tests/test_report/test_sarif.py.tests/test_storage/test_structured_findings_storage.py:test_migration_re_derives_locations_for_existing_sast_and_secret_rowstest_migration_collapses_duplicate_findings_preserving_reviewtest_migration_rescan_causes_no_churnpytest) and linter (ruff check) cleanly.