Skip to content

pentest: _rel does not normalise file:// SARIF URIs, so such a producer gets zero correlations #45

Description

@Shahid-BugB

pentest/threat_correlation.py:18-29 treats Hypothesis.file as a filesystem path:

p = Path(file)
if not p.is_absolute():
    return p.as_posix().removeprefix("./")

SARIF's artifactLocation.uri is a URI, and the spec permits an absolute file:// form. guardlink.py passes it through verbatim. Path('file:///repo/src/main.ts') is relative as far as pathlib is concerned — it has no leading / — so the absolute branch is never taken, no resolution happens, and the key becomes the literal string file:/repo/src/main.ts. That matches no key electron_surface ever produces.

Every routeless threat from such a producer is therefore filed review-only, and the run prints 0 correlated, N review-only and exits successfully — indistinguishable from a codebase where nothing genuinely correlates. Same silent-miss shape as the relative---codebase bug fixed on feat/constant-channels (resolved once at the boundary via cxg_pentest.resolve_codebase), but on the other side of the join, and not reachable through that fix.

guardlink itself emits relative URIs today, which is why this has not bitten; it is a correctness gap against any other SARIF producer.

Suggested fix: in _rel, detect a file: scheme and convert with urllib.request.url2pathname(urlparse(uri).path) before the existing absolute/relative split. Reject or pass through unchanged any other scheme rather than string-stripping it — see _rel's own annotation on why a character strip manufactured false correlations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions