Skip to content

fix(ci): pin trivy-action to a tag that exists - #194

Merged
scttfrdmn merged 7 commits into
mainfrom
fix/trivy-action-pin
Aug 2, 2026
Merged

scttfrdmn merged 7 commits into
mainfrom
fix/trivy-action-pin

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

The v0.10.1 release run failed on a pin I wrote wrong: aquasecurity/[email protected] does not resolve, because every tag that action publishes is v-prefixed (v0.26.0 … v0.36.0).

An unresolvable action fails at "Set up job" — before any step runs, so there are no step logs and the failure reads as infrastructure rather than a typo. Security Scan Release went red, publish gates on it, and so the release did not publish.

That part is the restructure working. All four Build jobs succeeded, which had never happened before in this repository, and gh release view v0.10.1 returns release not found. v0.10.0 published an empty release page from a smaller failure than this one.

Changes

  • release.yml:219 and security.yml:77 → @v0.36.0 (published 2026-04-22)
  • Corrects the security-scan job comment, which claimed a finding "blocks the release". It does not: exit-code has no default in trivy-action, so findings upload as SARIF and the step passes. Left that way on purpose, with the reasoning stated inline — see below.

Verified before editing

  • repos/aquasecurity/trivy-action/tags → every tag v-prefixed
  • v0.36.0's action.yaml accepts scan-type and scan-ref and forwards both to the trivy CLI
  • Ran the equivalent locally against a freshly built stripped linux/amd64 binary: trivy rootfs --format sarif → exit 0, valid SARIF, 2 results
  • Both workflows parse, and every needs: names a job that exists

The two findings are real

GHSA-xmrv-pmrh-hhx2  MODERATE (CVSS 5.9)
  aws-sdk-go-v2/aws/protocol/eventstream  v1.7.1  → 1.7.8
  aws-sdk-go-v2/service/s3                v1.88.4 → 1.97.3

A malformed EventStream frame with an out-of-range header type byte panics the decoder, terminating the host process — which for a FUSE mount means unmounting under every open fd. Filed separately rather than folded into a release cut; the s3 bump is 9 minor versions and wants its own test run.

This is also why the scan is not a gate yet: making every release from here contingent on a scan whose first output nobody had triaged would block on that bump. Worth turning into exit-code: 1 with an explicit severity floor once these are cleared.

Next

Because a tag-triggered workflow is read from the tagged tree, re-running the failed job alone would use the same broken pin. The v0.10.1 tag has to move to this commit after merge.

`aquasecurity/[email protected]` does not resolve. Every tag that action
publishes is v-prefixed — v0.26.0 through v0.36.0 — and I pinned it without the
`v` in both workflows.

An unresolvable action fails at "Set up job", before any step runs, so there are
no step logs to read and the failure presents as an infrastructure problem rather
than a typo. On the v0.10.1 tag it took down `Security Scan Release`, which
`publish` gates on, so the release did not publish.

That much is the restructure working as designed: all four Build jobs succeeded —
the first time in this project's history — and no release page exists, where
v0.10.0 published an empty one from a worse failure. Fixing forward rather than
loosening the gate.

Pinned to v0.36.0 (published 2026-04-22) rather than v0.28.0, verified to accept
`scan-type`/`scan-ref` and to forward them to the trivy CLI. The equivalent scan
was run locally against a freshly built stripped linux/amd64 binary first:
`trivy rootfs --format sarif` exits 0 and writes valid SARIF with two results.

Those two results are real and are now recorded as issue work, not silently
absorbed: GHSA-xmrv-pmrh-hhx2 (MODERATE, CVSS 5.9) in the pinned
aws-sdk-go-v2 — an EventStream header decoder that panics on a malformed frame.

Also corrects the job comment above it. It claimed a finding "blocks the release",
which this configuration does not do: trivy-action's `exit-code` has no default,
so findings annotate via SARIF and the step passes. Left that way deliberately and
said why — gating on a scan whose first output nobody had seen would make this
release contingent on a dependency bump it does not carry. A comment that
overstates what a gate does is the same defect class this release exists to fix.
Neither of these is caused by the pin fix. Both were latent, and fixing the pin
is what let CI get far enough to run into them.

## gosec SARIF upload rejected the whole file

`Analysis upload status is failed` / `locationFromSarifResult: expected artifact
location`, three times. gosec emits three G115 integer-conversion findings with
`"artifactLocation": {}` — no file path at all — and GitHub rejects the entire
submission, discarding the other 45 findings with them.

They come from `sdks/c/main.go`, which is cgo: gosec analyses the generated
intermediate and cannot map the location back to a real file. Reproduced locally,
exactly 3 of 48 results affected.

The existing jq step already stripped `fixes` for the same class of reason. It now
also drops results with no resolvable location, taking 48 → 45 with the three bad
ones gone and every real finding preserved. Dropped rather than back-filled with a
placeholder path: inventing a location would pin a finding to a line that has
nothing to do with it. The G115 conversions in sdks/c are worth a hand audit, and a
SARIF entry pointing at the wrong file is not how to remember that.

First observation of this, because the workflow was `disabled_inactivity` from
January 2026 until it was rewritten in #191 — the `fixes` deletion was carried
forward untested along with the rest of the file.

## pkg/memmon fell below its coverage floor on a YAML-only commit

Which is a real finding, not a flake to paper over.

The package measured 51.0% or 50.6% run to run against a floor of 51 — zero
margin. CI passed on main at e969ff7 and failed on the same tree 12 minutes later.
Reproduced locally: 3 of 12 runs at 50.6%.

The variance was one statement, `monitor.go:279` — the memory-growth alert branch
in analyzeMemory — which fired only when the test's own allocations happened to
push `Alloc` past the threshold between two samples. Garbage-collector timing.

The larger half of the finding is why that branch was timing-dependent:

    alerts := monitor.GetAlerts()
    if len(alerts) == 0 {
        t.Log("No alerts generated (may be normal if memory growth is small)")
    }

TestMemoryMonitor_MemoryGrowthDetection allocated 100 MB to trigger growth
detection and then accepted either outcome. It asserted nothing — deleting the
entire growth-detection branch left it green. That is the defect class this whole
release exists to fix, in the test suite rather than in the code.

Replaced with three tests that assert:

  - MemoryGrowthDetection — seeds baselineSample/currentSample so the threshold
    comparison is the only variable. Four cases: over threshold alerts, under is
    silent, exactly at threshold is silent (the comparison is `>`, and which one it
    is decides whether a monitor configured at its steady-state growth rate alerts
    continuously or never), and shrinking does not alert. Asserts the alert carries
    BaselineMem, CurrentMem, and GrowthPct — an alert saying something grew without
    saying from what to what is not actionable.
  - AnalyzeMemoryNeedsTwoSamples — pins the early return for all three incomplete
    states. Comparing a sample to itself would report 0% growth as a fact rather
    than as an absence of data.
  - LiveSampling — keeps the real Start/sample/Stop loop under test, asserting only
    what is deterministic there (sampling happens, a baseline is established) and
    polling to a deadline instead of sleeping a guessed interval.

Result: 15 consecutive runs measure 51.9% exactly, the growth branch is covered on
every one, and analyzeMemory goes 87.0% → 95.7%.

Floor left at 51 per the file's stated policy — measured, rounded down — so it now
clears with margin rather than landing on the number. The note above it records
what happened, because a gate with zero margin is what made this visible at all.

Verified: gofmt clean · go vet clean · golangci-lint --new-from-merge-base 0 issues
· full `go test -covermode=atomic ./...` as CI runs it → coverage-gate reports all
30 packages at or above their floor.
The trivy pin, the gosec SARIF filter, and the memmon test that asserted
nothing. All three are in the tree the v0.10.1 tag will point at, so they
belong in that section rather than in Unreleased.

The memmon entry leads with what the test did rather than with the coverage
number it tripped, because the flake was the smaller half of the finding: a
test that allocates 100 MB to trigger detection and then accepts either
outcome is the same defect class as the seam bugs this release exists to fix,
located in the test suite instead of the code.
@scttfrdmn

Copy link
Copy Markdown
Owner Author

Pushed two more commits. Both are latent defects that fixing the pin made reachable — CI could not previously get far enough to hit them.

gosec SARIF upload rejected the whole file

Analysis upload status is failed.
##[error]Code Scanning could not process the submitted SARIF file:
locationFromSarifResult: expected artifact location  (×3)

Three G115 findings carry "artifactLocation": {} — no path at all — and GitHub rejects the entire submission, discarding the other 45 with them. Reproduced locally: exactly 3 of 48 results. They come from sdks/c/main.go, which is cgo — gosec analyses the generated intermediate and cannot map the location back.

The step already stripped gosec's invalid fixes for the same class of reason; it now also drops location-less results. 48 → 45, every actionable finding preserved. Not back-filled with a placeholder path — that would pin a finding to an unrelated line.

First observation of either, because this workflow was disabled_inactivity from January 2026 until #191 rewrote it. The fixes deletion had been carried forward untested along with the rest of the file.

pkg/memmon below its coverage floor — on a YAML-only commit

CI passed on main at e969ff7, then failed on the same tree 12 minutes later. Reproduced locally: 3 of 12 runs at 50.6% against a floor of 51.

One statement, monitor.go:279 — the growth-alert branch in analyzeMemory — reached only when the test's own allocations happened to cross the threshold between two samples. GC timing.

The flake is the smaller half of the finding. Here is why that branch was timing-dependent:

alerts := monitor.GetAlerts()
if len(alerts) == 0 {
    t.Log("No alerts generated (may be normal if memory growth is small)")
}

TestMemoryMonitor_MemoryGrowthDetection allocated 100 MB to trigger growth detection and then accepted either outcome. Deleting the entire growth-detection branch left it green — the same defect class this release exists to fix, sitting in the test suite instead of the code.

Replaced with three tests that assert. Notable case: exactly at threshold is silent, because the comparison is > — and which one it is decides whether a monitor configured at its steady-state growth rate alerts continuously or never.

before after
15 consecutive runs 50.6% / 51.0% 51.9%, every run
analyzeMemory 87.0% 95.7%
growth branch covered ~3 runs in 4 covered every run

Floor stays at 51 per the file's ratchet policy (measured, rounded down), so it now clears with margin rather than landing on the number. A gate with zero margin is what made this visible.

Verified

gofmt clean · go vet clean · golangci-lint --new-from-merge-base 0 issues · full go test -covermode=atomic ./... as CI runs it → coverage-gate: all 30 packages at or above their floor · notes extraction re-run against the updated CHANGELOG → 1,201 bytes from a 184 KB section

The original tag run has finished, and it ended correctly

success   Build (linux, amd64)      success   Build (darwin, amd64)
success   Build (linux, arm64)      success   Build (darwin, arm64)
success   Build and Push Docker Image
failure   Security Scan Release
skipped   Publish Release           ← and no release page exists

Four builds and the multi-arch image all green, and publish skipped rather than publishing an empty page. That is the whole point of the restructure in #191, demonstrated by the first release run to exercise it.

…pmrh-hhx2

govulncheck reported **20 vulnerabilities**, 19 of them in the Go standard
library. Closes #195.

## The toolchain was pinned to a patch release five behind

`go.mod` carried only `go 1.26.0`, and `actions/setup-go` with
`go-version-file: go.mod` reads that line as an *exact version spec*. CI logged
it plainly once the scan finally ran:

    Setup go version spec 1.26.0
    go version go1.26.0 linux/amd64

So every job in every workflow — including the four that build release binaries —
compiled with go1.26.0, while go1.26.5 had been out for some time. The 19
advisories were not defects in this code; they were shipped by it:

    crypto/tls        fixed in 1.26.5   (2 advisories)
    crypto/x509       fixed in 1.26.2 / 1.26.4   (6)
    net/http          fixed in 1.26.3
    net/http/httputil fixed in 1.26.3
    net, net/textproto, html/template, archive/tar   (the rest)

`crypto/x509` and `crypto/tls` are on the path to S3 on every request, and
`net/http/httputil` is what `internal/testaws` builds its recording proxy from.

Adding an explicit `toolchain go1.26.5` fixes it: setup-go prefers `toolchain`
over `go` when both are present, and the `go` line stays what it should be — the
language minimum, not a build pin. That distinction is the actual bug; one
directive was doing two jobs and the wrong one won.

Verified: 19 standard library advisories → **0**.

## The AWS SDK bump

Which left one finding, the one filed as #195:

    GO-2026-5764 / GHSA-xmrv-pmrh-hhx2  (MODERATE, CVSS 5.9)
      aws-sdk-go-v2/aws/protocol/eventstream  v1.7.1  → v1.7.8
      aws-sdk-go-v2/service/s3                v1.88.4 → v1.97.3

A malformed EventStream frame with an out-of-range header type byte panics the
decoder and terminates the host process. For a library that is one failed request;
for a FUSE mount it unmounts the filesystem under every open fd, and buffered
writes not yet flushed are gone. Same failure shape as the shutdown panics fixed
under M15/M16/M19 this release, which is why those were treated as integrity bugs.

Done here rather than deferred because the alternative was releasing with a known
advisory and a scan configured not to mention it, and because the collision #195
anticipated did not happen: smithy-go moved only v1.24.0 → v1.24.2, not to the
v1.26.0 the pricing work expects, so the two bumps do not conflict.

Nine minor versions of `service/s3` is enough surface to want real evidence, not a
green `go build`:

  - `go test -race -count=1 ./...` — full suite, not -short: **zero failures**
  - `internal/testaws` and `internal/difftest` included, which is the part that
    mattered. They assert on wire-level behavior — headers sent, ranges requested,
    bytes transferred — so an SDK bump is precisely the change that could move them
  - `AWS_PROFILE=aws AWS_REGION=us-west-2 go test -race -tags=integration
    ./internal/storage/s3/...` against real S3: ok
  - coverage-gate: all 30 packages at or above their floor
  - gofmt clean, go vet clean, golangci-lint --new-from-merge-base 0 issues
  - govulncheck: **0 vulnerabilities**
Both close real advisories in the shipped artifact, so they belong in 0.10.1
rather than deferred: 19 stdlib advisories from a toolchain CI pinned five
patch releases behind, and the EventStream decoder panic that would unmount a
filesystem under every open fd.
`go-licenses check ./...` failed on `modernc.org/mathutil`. Two things are wrong
with that, and both point the same way.

**It is a test-only dependency.** The path is
internal/testaws → substrate → sqlite → libc → mathutil, and
`go list -deps ./cmd/objectfs` contains zero modernc.org packages. It ships in
nothing. License compliance is a question about distributed artifacts, so a check
scoped to `./...` is asking about code no user receives.

**The finding is also wrong on its own terms.** mathutil has a LICENSE file
containing a textbook BSD-3-Clause — all three clauses verbatim,
Apache-2.0-compatible. go-licenses cannot classify it because the text is
reflowed, wrapping mid-clause instead of matching its matcher's expected layout.

So the alternative fix was an allowlist entry asserting a license on someone
else's behalf, which this project has no standing to do, versus scoping the check
to the artifact whose licensing anyone can actually be bound by. Scoped.

Verified: `go-licenses check ./cmd/objectfs` exits 0, and mathutil was the only
unclassified license in the whole graph — so this narrows what is checked without
suppressing any other finding.

Never reached before now for the same reason as the other two fixes in this
branch: the workflow was `disabled_inactivity` from January 2026 until #191, and
the govulncheck step ahead of it failed on every run until the toolchain pin was
fixed. Each fix has been uncovering the next step that had never executed.
Same pattern as the other CI entries in this release: a gate that had never
run, failing on the first thing it saw, which turned out to be a test-only
dependency and a false positive on a reflowed BSD-3-Clause.
@scttfrdmn
scttfrdmn merged commit 4be2327 into main Aug 2, 2026
22 checks passed
@scttfrdmn
scttfrdmn deleted the fix/trivy-action-pin branch August 2, 2026 17:10
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.

1 participant