feat(trivy-image-scan): add fail-on-finding, so the gate can actually gate - #166
Merged
Merged
Conversation
… gate A consumer setting continue-on-error: false on this workflow got a gate that never fires. The scan reported success on an image with a CRITICAL finding and failed only when it could not reach the image at all -- verified against the published module before fixing it. stuttgart-things/dagger v0.129.0 fixes the module side: trivy's exit code was discarded and the summary that should have carried the verdict was parsing secrets rather than vulnerabilities, so ParsedSummary was null on every image report ever produced. ScanImage now takes failOnFinding and errors with the findings listed. This is the other half. fail-on-finding defaults to false, unlike the govulncheck template: an image scan takes an inventory of a whole artefact and its first findings are usually transitive, so most consumers want to read a report before gating on one. govulncheck filters by reachability, which is what lets it gate on day one; this does not. The gate is a second call placed after the artifact upload, because with --fail-on-finding the module returns an error and export is never reached -- the report would go missing exactly when somebody wants it. Same shape as call-dagger-govulncheck.yaml, for the same reason. The second call hits the cache from the first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DGshyN1b9amKkrRRUubhbM
This was referenced Sep 5, 2026
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.
The downstream half of stuttgart-things/dagger#351 (released as v0.129.0).
The defect
A consumer setting
continue-on-error: falseon this workflow had a gate that never fires. Verified against the published module before touching anything:alpine:3.10, carries 1 CRITICAL"Found something" reported success; "could not look" reported failure.
Two causes, both in the module: trivy exits 0 on findings and its exit code was discarded by
|| true, and the summary that should have carried the verdict was parsing secrets rather than vulnerabilities — soParsedSummarywasnullon every image report this module has ever produced. dagger#351 fixes both and addsfailOnFinding.This half
fail-on-findinginput, defaultfalse.trivy@v0.129.0.--fail-on-findingthe module returns an error, soexportis never reached and the report would go missing exactly when somebody wants it. Same two-call shape ascall-dagger-govulncheck.yaml, for the same reason; the second call hits the cache from the first.Why the default differs from the govulncheck template
call-dagger-govulncheck.yamldefaultsfail-on-findingto true; this one to false, and that asymmetry is deliberate rather than an oversight.govulncheck filters by reachability — it stays quiet about a CVE whose affected function is never called, so a finding means something is genuinely exposed and gating on day one is defensible. An image scan takes an inventory of a whole artefact, and its first findings are usually transitive and unactionable. Most consumers want to read a report before gating on one. Turning it on is a deliberate step once the list is known — which is exactly the discipline
stuttgart-things/schmetterpause#86followed for its own adoption.Verified
exit 1, namesCVE-2021-36159 in apk-tools) and off (exit 0,ParsedSummarypopulated), a clean image with the gate on (exit 0), and a missing image (exit 1, unchanged).pre-commitpasses on the changed file, includingcheck-github-workflows.uses:-only change that cannot run outside GitHub, and no consumer here has a vulnerable image to point it at. The first real proof will be a consumer enabling it.Downstream
stuttgart-things/schmetterpausesetcontinue-on-error: falseon its Trivy job in #183 believing it had a gate. It does not until it also passesfail-on-finding: trueagainst this revision — a follow-up PR there, plus a correction to the comment that currently overstates what the job does.🤖 Generated with Claude Code
https://claude.ai/code/session_01DGshyN1b9amKkrRRUubhbM