Skip to content

fix(sarif): deduplicate CWE taxa entries to fix schema validation failure#7974

Open
cx-ori-bendet wants to merge 1 commit intomasterfrom
fix/sarif-duplicate-taxa
Open

fix(sarif): deduplicate CWE taxa entries to fix schema validation failure#7974
cx-ori-bendet wants to merge 1 commit intomasterfrom
fix/sarif-duplicate-taxa

Conversation

@cx-ori-bendet
Copy link
Contributor

Summary

  • Multiple queries sharing the same CWE ID (e.g. CWE-798) caused duplicate entries in runs[0].taxonomies[1].taxa of the SARIF output
  • This triggered instance.runs[0].taxonomies[1].taxa contains duplicate item schema validation errors, blocking SARIF upload to GitHub and other consumers
  • Root cause: auxID []string in PrintSarifReport accumulated all CWE IDs without deduplication across queries
  • Fix: add a seenCWEs map so each CWE ID is only appended to auxID once before being passed to RebuildTaxonomies

Fixes #7588

Test plan

  • Run KICS on a Terraform file with multiple resources that trigger the same CWE (e.g. several @Microsoft.KeyVault(...) references triggering CWE-798) and verify the SARIF output passes schema validation
  • Upload the generated .sarif file to GitHub via github/codeql-action/upload-sarif — should succeed without duplicate taxa errors
  • Run go test ./pkg/report/... to verify existing tests still pass

I submit this contribution under the Apache-2.0 license.

🤖 Generated with Claude Code

…lure

Multiple queries sharing the same CWE ID (e.g. CWE-798) caused duplicate
entries in the SARIF taxonomies taxa array. This caused schema validation
errors and prevented SARIF upload to GitHub and other consumers.

Add a seenCWEs map to ensure each CWE ID is appended to auxID only once
before being passed to RebuildTaxonomies.

Fixes #7588

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cx-ori-bendet cx-ori-bendet requested a review from a team as a code owner February 28, 2026 22:45
@github-actions github-actions bot added community Community contribution query New query feature terraform Terraform query labels Feb 28, 2026
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.18

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

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

Labels

community Community contribution query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(sarif): output contains duplicate taxa items causing schema validation failure

1 participant