Repository navigation
Description
What happened
PR #414 added a uint64 → int64 conversion in internal/distributed/cluster.go. gosec flagged it as G115 and reported 1 new alert including 1 error on the PR — and the PR was still mergeable, because gosec is not among main's 19 required status checks. It was noticed only because the checks were read by hand.
The finding was real, not noise: a negative CacheRequests reads as "nothing has asked yet" to the guard that decides whether a cache hit rate is reported, so an overflow would make the busiest cache in the cluster report hit=not measured. Fixed in #414 by clamping.
Two separate problems
-
The
Security Scanjob runsgosec -no-fail(.github/workflows/security.yml:58), so the job passes regardless of findings. Thegoseccheck that does go red is the code-scanning check produced by the SARIF upload, which is a different check from the job. -
The
goseccheck only appears on pull requests, never onmainpushes. Measured across the last four commits onmain: zerogoseccheck runs on each. So it cannot simply be added to the required-checks list — a required context that does not always report blocks every PR forever, which is the failure mode ci: give the modulefiles matrix legs names that can be required checks #413 was written to avoid for the modulefiles legs.
Why this is not just "add it to branch protection"
Requiring a context that reports on PRs but not on pushes needs verifying first; branch protection matches by exact string and has no notion of "required only when present". Options, in rough order of preference:
- Have the
Security Scanjob itself fail on new findings — drop-no-fail, or gate on a severity threshold — so the job is the required check. A job name is stable and reports on both triggers. - Keep
-no-failfor the SARIF upload and add a separate step that fails on findings above a threshold, so the historical backlog does not block every PR while new findings do.
The severity threshold matters: the repo has a pre-existing G115 backlog in sdks/c that the SARIF filter already works around (see the comments at security.yml:63-94), so failing on all findings would block everything. Failing on findings in code changed by the PR is the behavior the current check-run summary already reports ("New alerts in code changed by this pull request").
Acceptance
- A new gosec finding in changed code blocks the merge without anyone reading the checks by hand.
- The mechanism reports on both
push: mainandpull_request, verified by looking at check runs on a merge commit — not assumed. - The pre-existing backlog does not block unrelated PRs.
Activity
scttfrdmn commentedon Aug 14, 2026
Measured the trigger question this issue flags as needing verification, since it decides which of the two options is available.
Security Scanreports onpush: main. Onfb0ecbc(the merge of #431) the commit carries 45 check runs andSecurity Scanis among them. It is insecurity.yml'son:block for bothpush: branches: [main]andpull_request, and the workflow's run list confirms both event types firing.So the issue's second problem — "only appears on pull requests, never on
mainpushes" — is true of thegoseccode-scanning check produced by the SARIF upload, and not of theSecurity Scanjob. Those are two different contexts with two different names, which is exactly the confusion the issue body identifies; this just settles which side of it each one falls on.That makes option 1 the one to take: have the job fail on new findings and require
Security Scan, which is a stable job name that reports on both triggers. No need for the "required only when present" behaviour branch protection cannot express.The severity/backlog constraint stands unchanged.
gosec -no-failmust keep running for the SARIF upload — thesdks/cback-fill step depends on getting a complete report — so the gate has to be a separate step readinggosec.sarif, failing on findings outside the known backlog rather than on all of them..github/workflows/security.yml:113-115already counts total results and back-filled results, so the numbers a threshold would compare against are being printed today.One addition to the acceptance criteria, from a defect just fixed next door in #433: whatever the gate prints, verify the message is reachable on a failing run.
install-scripthad three carefully worded::error::messages that aset -ecommand substitution killed the step before reaching, so a real failure's log held only bash's errno. A security gate whose explanation only appears when it passes has the same problem.ci(security): fail Security Scan on a gosec finding that is not basel…
scttfrdmn commentedon Aug 14, 2026
#435 is merged. The gate exists and is verified on both triggers; one step remains and it needs your say-so.
What landed
.github/scripts/gosec-gate.sh, run as the last step ofSecurity Scan, diffing the report against.github/gosec-baseline.txt.-no-failstays, deliberately. The SARIF upload needs the complete report, including the threesdks/cfindings the format-fix step back-fills a path onto — and which golangci-lint discards for the same cgo reason, so they reach no other tool. Dropping the flag reads as a tightening and is a loosening: the job would end before either step ran.The severity-threshold option in this issue is not available
Measured: 12 findings, all G115, all
errorlevel. There is no level that separates the backlog from a new finding, because gosec reports every G115 identically. So the baseline is what the acceptance criterion actually needs, not a threshold.Keyed by
(rule, file, count)— not by line number, which moves whenever anything above it moves, so a line-keyed baseline goes stale on unrelated edits and the failure it reports is always about the wrong thing. Keyed this way, a refactor inside one of those eight files is silent and a second conversion added to it is not. The ratchet is exact in both directions: fixing one of these fails too until its line goes with it, because a slot kept after its finding was fixed is permanent headroom for the next conversion in that file.Acceptance, item by item
Security Scanon thepush: maincommitbb914cfprinted:Verified by running the failure path, which found a bug in the gate itself
Five mutated SARIF files: a second finding in an already-baselined file; a finding in a file not baselined; a baselined finding removed; a different rule in a baselined file; and zero results, which is the shape a failed scan leaves behind as easily as a clean one and now gets its own message instead of a bogus eight-fixed-findings diff.
The first run caught a defect in the script:
diffexits 1 on a difference,pipefailpromotes that to the pipeline, andset -eended the script atdiff | tail— so the mutant printed the diff and then none of the three paragraphs explaining what to do about it. Which is precisely the failure #433 had just fixed in the install-script job, occurring directly beneath a comment describing it. Fixed and re-verified.internal/config/gosec_gate_test.gogates the two silent failure modes — a baselined path that no longer exists, and the workflow step deleted,-no-faildropped, or the script not executable. All six branches mutation-verified.Outstanding: adding
Security Scanto required checksThat is the last step, and it is the one that makes this issue's headline true — until the context is required, a red
Security Scanstill does not block a merge, it just goes red where someone can see it.It is a persistent branch-protection change on
main(19 contexts → 20), so I have not made it. Say the word and it is one API call:Note it must be the job name
Security Scan, notgosec— that is the code-scanning check this issue identified as not reporting onpush: main, and requiring it is the thing that would block every PR forever.Leaving this open until then.