Skip to content

Bug: line ranges and multi-file locations become bogus file paths (breaks fingerprints and SARIF locations) #112

Closed

Description

@vsn411

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 in examples/sample-output/nodegoat/findings.sarif).
  • The SAST fingerprint is skill + CWE + normalized path, so a finding at all.js:8-9 and the same finding reported next run as all.js:8 get 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:

  1. 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 :61 inherits the previous path.
  2. Store the first location in location_file/location_line (keeps the schema) and the full list in a new locations JSON column; fingerprint on the first path only.
  3. SARIF: one locations[] entry per site, region.startLine/endLine when a range is known; JSONL gets locations.
  4. Apply the same parser to the secret-scanning report (report/secret_scanning.py uses 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

  1. added
    bug
    help wanted
    hackathon
    difficulty: medium
    on Nov 15, 2026
  2. aaas72 commented on Nov 20, 2026

    @aaas72
    Contributor

    Hi! I'd like to work on this one. Plan: a parse_locations() that returns (path, start_line, end_line) for path:line, path:start-end, path:line,line, backticked forms and comma/semicolon lists (a bare :61 inherits the previous path); keep the first site in location_file/location_line, store all sites in a new locations JSON column and fingerprint on the first path; one SARIF locations[] entry per site with startLine/endLine; the same parser for secret scanning, and the NodeGoat sample as a regression test.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdifficulty: mediumhackathonhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions