Repository navigation
fix(trivy): Correct macOS asset name in installer script - #1032
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
trivy): Correct macOS asset name in installer script
|
This PR is included in version 1.109.3 🎉 |
Put an
xinto the box if that apply:Description of your changes
tools/install/trivy.shbuilds its GitHub release-asset regex using$TARGETOSdirectly (uname -s, lowercased), e.g.darwinon macOS.Trivy's release assets are named with
macOSinstead(
trivy_0.74.0_macOS-ARM64.tar.gz), so the regex never matches on anyMac, for any
--tool-version(pinned orlatest), regardless ofGITHUB_TOKEN."could not find a release asset matching version... looked through up to 20 pages,"because it finds a match.
latest-> acurlcrash ("blank argument where content isexpected"), since the empty match feeds curl a malformed URL.
This adds a
darwin -> macOStranslation for$TARGETOS, mirroringthe
amd64 -> 64bittranslation already done for$TARGETARCHtwolines above it, and the OS-name mapping
terrascan.shalready does forits vendor's naming convention (
Darwin, capitalized).How can we test changes
Test 1 -
Standalone repro (no pre-commit needed):
Fails on
master, succeeds with this patch.Test 2 -
Tested on macOS (Apple Silicon, arm64) using
pre-commit try-repo-stylelocal testing against a throwaway Terraform repo containing a single
.tffile with a deliberate misconfiguration (anaws_s3_bucketresource missing encryption/versioning), to confirm trivy actually
executes against real content rather than just confirming a binary
downloads.
master(before this fix):terraform_trivyfails duringinstallation with
ERROR: could not find a 'trivy' release asset matching version '0.74.0' (looked through up to 20 page(s) of releases)- the installer never resolves a download URL.downloads trivy, and the hook runs trivy against the test file,
which flags the missing bucket encryption/versioning as expected -
confirming trivy both installed and executed successfully.
Cache was cleared between runs (
~/.cache/pre-commit,~/.cache/pre-commit-terraform) to ensure each test exercised theinstaller fresh rather than reusing a cached binary.