Skip to content

[fix][report-converter] Honour trim-path-prefix in sarif export - #4987

Open
Sanjays2402 wants to merge 1 commit into
Ericsson:masterfrom
Sanjays2402:fix/sarif-trim-path-prefix
Open

[fix][report-converter] Honour trim-path-prefix in sarif export#4987
Sanjays2402 wants to merge 1 commit into
Ericsson:masterfrom
Sanjays2402:fix/sarif-trim-path-prefix

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #4659

The sarif exporter built artifactLocation URIs from report.file.original_path, which always holds the untrimmed path, so CodeChecker parse --trim-path-prefix ... --export sarif still emitted absolute paths. Using report.file.path returns the trimmed path once Report.trim_path_prefixes() has run and the original path otherwise — the same fix applied to the HTML export in #4387.

Added a regression test covering both the primary result location and the code flow locations; it fails on master with file:///home/user/project/src/main.c and passes with the change.

The sarif parser built artifactLocation URIs from
report.file.original_path, which always holds the untrimmed path, so
`CodeChecker parse --trim-path-prefix ... --export sarif` still emitted
absolute paths. Use report.file.path instead, which returns the trimmed
path once Report.trim_path_prefixes() has been called and the original
path otherwise. This mirrors the fix made for the HTML export in Ericsson#4387.

Added a regression test asserting both the primary result location and
the code flow locations honour the trimmed prefix.
@Sanjays2402
Sanjays2402 requested a review from bruntib as a code owner July 25, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sarif output ignores trim-path-prefix

1 participant