Skip to content

feat(check): emit SARIF 2.1.0 so findings land in the Security tab - #212

Merged
kerlenton merged 3 commits into
kerlenton:mainfrom
hsdfat:feat/check-sarif
Aug 8, 2026
Merged

kerlenton merged 3 commits into
kerlenton:mainfrom
hsdfat:feat/check-sarif

Conversation

@hsdfat

@hsdfat hsdfat commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Closes #205.

check emitted text and JUnit but nothing code scanning could ingest, so findings could fail a build without ever becoming an alert. Adds --format sarif (SARIF 2.1.0).

  • one run per file, not per session — code scanning caps a file at 20 runs, and a concatenated capture can hold more
  • every rule declared on every run, so a fixed finding's alert closes
  • level follows --fail-on; a clean run emits "results": [], not null
  • results anchor at the true line, but fingerprints are built from what a finding is, so alerts survive lines moving

One design note worth a look: the error signal comes from a new EventView.Errored, set in the store wherever the session's error counter is incremented. Deriving it from Call.Errored instead was wrong — some counted errors carry no call at all (a bare HTTP failure, an error response matching no request), and a task's terminal failure mutates its call in place, which anchored the alert at the call's first response. Marking the frame where it's counted keeps the report and the gate in sync by construction.

README gains the --format synopsis and an upload-sarif snippet.

Checklist

  • make check passes (gofmt, vet, staticcheck, race tests)
  • Added or updated tests for the change, where it makes sense
  • Updated the README / docs if user-facing behaviour changed

check could only report an aggregate per signal, so three distinct
protocol warnings reached CI as the string "has 3 warnings" and the
report ended up in a zip nobody downloads. The store already knows which
frame caused each one.

Add --format sarif beside junit: one result per finding, carrying the
session id, the frame Seq and the frame's own text, at level error for a
signal named in --fail-on and note for one outside it, so the report
follows the gate. All nine rules are declared on every run, clean or not,
so a fixed finding closes its alert instead of staying open forever.

A result points at the real 1-based line the envelope was decoded from,
supplied by a new exporter.LoadFileLines: Seq is scoped per session and
skips dropped frames, so writing it into startLine would send a reader to
the wrong frame. The log path is made relative to the working directory
when it sits under it, since code scanning resolves a result's path
against the repository root, and a stdin run emits no location at all.

Refs kerlenton#205
@kerlenton

Copy link
Copy Markdown
Owner

Great! Thank you!

@kerlenton
kerlenton merged commit cf06c9a into kerlenton:main Aug 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emit SARIF from check so findings land in the Security tab

2 participants