Pin the TruffleHog scanner image by digest - #6677
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
behroozazarkhalili
left a comment
There was a problem hiding this comment.
Verified the mechanism independently rather than taking the description on trust, and it holds on every point.
action.yml at the SHA currently pinned (27b0417) builds the image reference by direct interpolation:
docker run --rm -v .:/tmp -w /tmp \
"${IMAGE}:${VERSION}" \with version: default: "latest" and image: default: "ghcr.io/trufflesecurity/trufflehog". Because VERSION lands bare after the colon, <tag>@sha256:<digest> produces a valid repo:tag@digest reference, so the pin works exactly as you describe.
I can also confirm the digest is the image that actually ran. The Secret Leaks job that failed on #6005 logged:
Digest: sha256:aa821cf4ace8861c7d096d83818cdf7bb9719028a52d37a52eaad44086a52577
Status: Downloaded newer image for ghcr.io/trufflesecurity/trufflehog:latest
... "trufflehog_version": "3.96.0"
which is the digest this PR pins, pulled from :latest, reporting 3.96.0 while the workflow was labelled v3.95.9. That is the mismatch this closes.
That version string was in the log I read while investigating #6674 and I did not follow up on the fact that it disagreed with the pin, so this is a good catch. Pinning the container as well as the wrapper also removes the failure mode that started this: a scanner behaviour change with no reviewable diff on our side.
No objection from me. Leaving the approval to a maintainer.
This PR pins the TruffleHog scanner container image by digest, so that the secret scanning job runs a fixed, immutable version.
Motivation
The
trufflesecurity/trufflehogaction is pinned by commit SHA, but that pins only the composite action wrapper. Its final step runs the scanner as a container built from theimageandversioninputs, andversiondefaults to the mutable:latesttag. The job labelledv3.95.9was therefore running scanner3.96.0.This leaves an unpinned mutable dependency executing in CI, and lets scanner behaviour change without any reviewable diff. That is exactly how the recent Lob false positives broke this workflow on every new branch push, with no change on our side. See:
Solution
The
versioninput accepts a fullrepo:tag@digestreference, because the action builds the image reference by concatenating the two inputs. Passing the digest there pins the scanner image by content, which is the container equivalent of the commit SHA pin already applied to the action. The tag is kept alongside the digest so the version stays readable.The pinned digest is the multi-arch index digest, covering
linux/amd64andlinux/arm64.Note that Dependabot bumps the action SHA but has no visibility into action inputs, so the digest has to be bumped by hand alongside it. A comment in the workflow records that coupling.
Changes
versioninputNote
Low Risk
CI workflow-only change with no application runtime impact; reduces supply-chain drift in secret scanning.
Overview
Hardens secret scanning so CI runs a fixed TruffleHog scanner build instead of whatever
:latestresolves to when only the action wrapper is SHA-pinned.The workflow bumps
trufflesecurity/trufflehogto v3.96.0 and setsversionto3.96.0@sha256:…, pinning the scanner container by digest. Comments note that the action SHA alone does not pin the scanner image and that the digest must be updated together with the action bump (Dependabot will not do that).Reviewed by Cursor Bugbot for commit d734d69. Bugbot is set up for automated code reviews on this repo. Configure here.