feat: report semgrep findings as a CWE/OWASP table; honour nosemgrep - #8
Merged
Conversation
The one-line-per-finding format said WHERE but not WHAT CLASS, so acting on a
finding meant looking the rule up by hand. semgrep already carries CWE, OWASP
category and confidence in tool.driver.rules[].properties.tags, so the report
now renders:
# SEVERITY FILE:LINE RULE CWE OWASP CONFIDENCE
1 warning src/clj/cleancoders/mfa.clj:218 cc-generic-catch 396,636 A10:2025 LOW
2 error src/cljs/cleancoders/contact.cljs:224 cc-cljs-innerhtml CWE-79 A05:2025 HIGH
Identifiers stay in the table and a legend expands each CWE and OWASP category
once, so rows remain scannable instead of ~200 columns wide.
Fixes a real bug found while building the fixture: semgrep still emits a result
for source annotated with a nosemgrep comment, marking it
suppressions:[{kind:"inSource"}]. The reporting counted those, so
cleancoders.com's two already-triaged secret findings were being reported AND
blocking the build -- which makes nosemgrep look broken. Suppressed results are
now excluded from the table, the legend and the exit code, and reported as a
count so the suppression stays visible rather than silent. That repo's real
number is 1 blocking, not 3.
Rendering and the exit decision move into bin/report-sarif.sh with 20 tests in
bin/test-report-sarif.sh, run against a SARIF captured from an actual consumer
scan. The fixture has region.snippet stripped: semgrep embeds matched source,
which for a secret-detection rule means the secret itself, and this repo is
public.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested: map findings to their CWE / OWASP Top 10 classes instead of just
printing a location. semgrep already carries all of it in
tool.driver.rules[].properties.tags.Identifiers stay in the table and the legend expands each once — inlining the
full CWE titles pushed rows past 200 columns.
It found a real bug: nosemgrep was being ignored
Building the fixture from cleancoders.com's actual scan turned up that both
secret findings carry
suppressions: [{"kind": "inSource"}]— the source hasnosemgrepannotations and semgrep honoured them, but still emits theresult. The reporting counted them anyway.
So those two already-triaged findings were being reported and blocking the
build, which makes
nosemgreplook broken. Suppressed results are now excludedfrom the table, the legend and the exit code, and reported as a count so the
suppression stays visible rather than silent.
cleancoders.com's real number is 1 blocking, not 3. The only genuinely
actionable finding is
cc-cljs-innerhtmlatcontact.cljs:224.Structure
Rendering and the exit decision move into
bin/report-sarif.sh, called via thecheckout the semgrep job already does. 37 lines of inline jq in YAML become 7.
bin/test-report-sarif.shcovers it with 20 cases against a real captured SARIF,pinning: suppressed excluded, warnings never block, error-level blocks, clean
scan passes, missing SARIF fails loudly.
The fixture has
region.snippetstripped. semgrep embeds the matched sourceline, which for a secret-detection rule is the secret itself — and this repo is
public.
🤖 Generated with Claude Code