Skip to content

fix(sarif): do not count results marked as suppressed - #9383

Merged
nvuillam merged 7 commits into
oxsecurity:mainfrom
jmkle:fix/sarif-suppressed-results
Oct 30, 2026
Merged

nvuillam merged 7 commits into
oxsecurity:mainfrom
jmkle:fix/sarif-suppressed-results

Conversation

@jmkle

@jmkle jmkle commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #9373

With SARIF_REPORTER: true, MegaLinter counted every result of a linter's SARIF output, including the ones the linter itself marks as suppressed (for example # nosemgrep). They showed up as warnings in the summary, the PR/MR comment and the console details, although the linter passed.

Per SARIF 2.1.0 §3.27.23, a suppressed result is excluded from result lists and counts. A result is treated as suppressed when suppressions is non-empty and none of its entries has status underReview or rejected (§3.35.3). An entry without status is accepted, which is how semgrep writes in-source suppressions.

Proposed Changes

  1. utils_sarif.is_suppressed() helper, plus remove_suppressed_results() / remove_suppressed_results_from_text() that return a filtered copy of the SARIF
  2. Suppressed results are skipped in Linter.get_sarif_result_count and in the cli_lint_errors_count: sarif stdout counting path (DevSkim)
  3. sarif-fmt receives the filtered copy, so the console/text details no longer list suppressed results. The SARIF report files are untouched, so SARIF consumers still see the suppressions
  4. ApiReporter.build_sarif_breakdowns skips suppressed results
  5. Tests: new fixture .automation/test/sarif_reports/REPOSITORY_SEMGREP.sarif (one suppressed result, one plain result), plus unit tests for both counting paths, the API breakdowns and the helpers (accepted / underReview / rejected / mixed statuses)

Readiness Checklist

Author/Contributor

  • Add entry to the CHANGELOG listing the change and linking to the corresponding issue (if appropriate)
  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as breaking if this is a large fundamental change
  • Label as either automation, bug, documentation, enhancement, infrastructure, or performance

Results whose SARIF suppressions are all accepted (ex: # nosemgrep) are no longer counted as errors or warnings, listed in the human-readable details, or included in the API reporter breakdowns. The SARIF reports keep them untouched.

TEST_KEYWORDS=linter_test,mega_linter_3_sarif_test,api_reporter_v2_test

Fixes oxsecurity#9373

@nvuillam nvuillam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks :)

@nvuillam

Copy link
Copy Markdown
Member

@jmkle plz can you fix the issues detected by ci jobs ? :)

jmkle added 2 commits October 30, 2026 07:13
Signed-off-by: Joel Klein <113847502+jmkle@users.noreply.github.com>
@jmkle

jmkle commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@nvuillam I have added nosemgrep to the .cspell.json which should fix the error in the ci :)

jmkle added 3 commits October 30, 2026 09:40
…dir()

Signed-off-by: Joel Klein <113847502+jmkle@users.noreply.github.com>
…zation

Signed-off-by: Joel Klein <113847502+jmkle@users.noreply.github.com>
@jmkle

jmkle commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@nvuillam now the test errors are also resolved :)

@nvuillam
nvuillam merged commit 0c8642e into oxsecurity:main Oct 30, 2026
12 checks passed
@nvuillam

Copy link
Copy Markdown
Member

Let's go :)
I'll release a new beta today, and a new minor version in the next days :)

@jmkle
jmkle deleted the fix/sarif-suppressed-results branch October 30, 2026 11:31

This branch was successfully deployed

1 active deployment
dev — 90b6b1c7 Deployed Oct 30, 2026 by jmkle via MegaLinter #54572
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 result counts include results the linter marked as suppressed

2 participants