You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deduplicates SARIF rules by problem ID in UFM output to fix duplicate rule entries. When multiple findings share the same problem ID (e.g., two generic-api-key secrets found in different files), the SARIF output previously emitted one rule per finding, producing duplicate rule IDs in the rules array. Per the SARIF v2.1.0 spec, rule IDs must be unique within the rules array.
The fix adds a deduplicateIssuesByProblemID template function that filters the issues list to one entry per unique problem ID (first-wins) for the rules loop only. The results loop is unchanged — all findings still appear as individual results referencing their shared rule.
The PR removes the logic that falls back to issue.GetID() if issue.GetProblemID() is empty. In the new template code, ruleId is set directly to the problem ID. If a finding lacks a problem ID (which occurs for certain scan types or custom rules), it will result in a result with an empty ruleId string. This breaks the SARIF contract which requires ruleId to be a non-empty string referencing an entry in the rules array.
The deduplicateIssues function explicitly checks if field != "" before adding an issue to the result. Because the template now calls this function with "problemID", any finding that does not have a defined problemID will be entirely omitted from the SARIF rules array. This causes a schema violation where the results array contains findings referencing a ruleId that does not exist in the rules array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Deduplicates SARIF rules by problem ID in UFM output to fix duplicate rule entries. When multiple findings share the same problem ID (e.g., two
generic-api-keysecrets found in different files), the SARIF output previously emitted one rule per finding, producing duplicate rule IDs in therulesarray. Per the SARIF v2.1.0 spec, rule IDs must be unique within therulesarray.The fix adds a
deduplicateIssuesByProblemIDtemplate function that filters the issues list to one entry per unique problem ID (first-wins) for therulesloop only. Theresultsloop is unchanged — all findings still appear as individual results referencing their shared rule.Relevant ticket: CLI-1344
Checklist
make test)make generate)make lint)go get github.com/snyk/go-application-framework@YOUR_LATEST_GAF_COMMITin thecliv2directory.go.modto point to your local GAF code.go mod tidyin thecliv2directory.go.modandgo.sumchanges.