fix(trivy-repo): install Trivy explicitly so setup failures name themselves - #86
Merged
Merged
Conversation
…selves trivy-action installs Trivy and immediately scans in one step, so a setup that half-works surfaces as entrypoint.sh: line 88: trivy: command not found Process completed with exit code 127 from the scan, naming neither the cause nor the step responsible. Not hypothetical. On a self-hosted runner actions/cache restored the binary to /home/runner/.local/bin/trivy-bin, logged "Cache restored successfully", ran the $GITHUB_PATH step -- and the binary still was not there. That host had a doubled /home/runner/runner/_work layout while its sibling in the SAME run had /home/runner/_work. The pool is not uniform and the cached path derives from that layout, so the restore reported success while putting the binary somewhere PATH never looked. Now installed by an explicit setup-trivy step with `cache: false`, and `trivy --version` proves it before any scan runs. That trades a ~45MB download per run for a restore path that cannot silently no-op, and moves the failure to setup where it says what broke. setup-trivy is pinned to v0.2.6 deliberately -- the exact SHA trivy-action@0.36.0 pins internally -- so the explicit step installs what the action would have installed itself. Verified the SHA against the upstream tag list rather than trusting the comment I first wrote, which said v0.2.3 and was wrong. Applied to both the table-scan and SARIF jobs; they shared the failure mode, and only one being fixed would have been worse than neither. Also adds a `trivy-version` input (default v0.70.0) so the binary is pinned rather than tracking whatever upstream moves to. actionlint clean.
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 failure
trivy-actioninstalls Trivy and immediately scans in the same step, so a setup that half-works surfaces as exit 127 from the scan — naming neither the cause nor the step responsible. It reads like a Trivy bug; it isn't.Root cause
Not a download failure. The cache restore reported success:
…and the binary still wasn't on PATH. The distinguishing detail is the runner layout:
fs / trivy— failed/home/runner/runner/_work/...config / trivy— passed/home/runner/_work/...The self-hosted pool is not uniform, and the cached binary path derives from that layout. So the restore succeeded into a path PATH never looked at, and nothing noticed.
Fix
Install Trivy in an explicit step with the binary cache off, and prove it landed before anything scans:
cache: falsetrades a ~45MB download per run for a restore path that cannot silently no-op.trivy --versionthen fails at setup, loudly, instead of as a mystery 127 mid-scan.Applied to both the table-scan and SARIF jobs — they share the failure mode, and fixing only one would be worse than fixing neither, since the surviving path would fail identically while looking addressed.
Pin detail
setup-trivyis pinned to v0.2.6, not the newer v0.3.x — that's the exact SHAtrivy-action@0.36.0pins internally, so the explicit step installs precisely what the action would have installed itself. Bump the two together.I verified that SHA against the upstream tag list rather than trusting my own annotation, which initially said
v0.2.3and was wrong.Also
Adds a
trivy-versioninput (defaultv0.70.0) so the binary is pinned rather than tracking whatever upstream moves to — a scan shouldn't start reporting differently because of an unpinned dependency.actionlintclean. Changelog updated under[Unreleased].🤖 Generated with Claude Code
https://claude.ai/code/session_01Soh3XygRSFTojB3mvakDBr