Repository navigation
Description
Problem: parse_location() in src/secfoo/report/sast.py only understands file:line. Anything else is returned whole as the file name with no line. Observed on a real run against OWASP/NodeGoat (examples/sample-output/nodegoat/):
'config/env/all.js:8-9' -> ('config/env/all.js:8-9', None)
'server.js:78-102, app/routes/session.js:116, …' -> (whole string, None)
'app/data/user-dao.js:25, :61' -> (whole string, None)
'`server.js:135-137`, `app/views/layout.html:75`' -> ('server.js:135-137, app/views/layout.html:75', None)
Consequences:
- The SARIF export emits
artifactLocation.uri = "server.js%3A78-102%2C%20app/routes/session.js%3A116…", so GitHub code scanning cannot attach the alert to a file (see the result for F12 inexamples/sample-output/nodegoat/findings.sarif). - The SAST fingerprint is
skill + CWE + normalized path, so a finding atall.js:8-9and the same finding reported next run asall.js:8get different identities and show as closed + new instead of open. hash_code_region()is never computed for these rows, so incremental scans cannot track them.- Agents write ranges and multi-site locations often: 5 of the 12 SAST findings in the sample hit this.
Fix:
- Parse
path:line,path:start-end,path:line,line, backticked variants, and comma/semicolon-separated lists into a list of(path, start_line, end_line); a bare:61inherits the previous path. - Store the first location in
location_file/location_line(keeps the schema) and the full list in a newlocationsJSON column; fingerprint on the first path only. - SARIF: one
locations[]entry per site,region.startLine/endLinewhen a range is known; JSONL getslocations. - Apply the same parser to the secret-scanning report (
report/secret_scanning.pyuses the same helper) and check the dashboard's finding detail page shows every site.
Where to look: src/secfoo/report/sast.py (parse_location, _LOCATION_RE, fingerprint_for_row), src/secfoo/report/secret_scanning.py, src/secfoo/report/sarif.py (_location), src/secfoo/storage/repository.py (upsert_sast_findings, the migrations dict near line 63), tests/test_report/.
Done when: the four strings above parse as expected; a property test (Hypothesis is already in dev deps, see tests/test_property_parsers.py) shows parse_location never returns a path containing ,, ;, a backtick or a trailing :range; the SARIF for the sample output validates and every result has a real uri; a migration test opens an existing store and re-derives locations for old rows.
Activity
aaas72 commentedon Nov 20, 2026
Hi! I'd like to work on this one. Plan: a
parse_locations()that returns(path, start_line, end_line)forpath:line,path:start-end,path:line,line, backticked forms and comma/semicolon lists (a bare:61inherits the previous path); keep the first site inlocation_file/location_line, store all sites in a newlocationsJSON column and fingerprint on the first path; one SARIFlocations[]entry per site withstartLine/endLine; the same parser for secret scanning, and the NodeGoat sample as a regression test.fix(report): rekey unbackticked location lists the old parser matched
fix(report): parse ranged and multi-site locations into real paths (s…