Repository navigation
ci: pin actions to commit SHAs and verify downloaded tools - #426
Conversation
terencechotai2-commits
left a comment
There was a problem hiding this comment.
Looks good. I verified everything the description claims and found one small ordering suggestion.
Action pins. All four resolve to the commit of the tag in their comment (dereferencing annotated tags):
actions/checkoutv7.0.1;actions/setup-gov7.0.0;golangci/golangci-lint-actionv9.3.0;aws-actions/configure-aws-credentialsv6.3.0.
Each is also the current latest release, and no unpinned uses: is left in any workflow. dependabot.yml covers github-actions weekly, as RELEASE.md says.
install-goreleaser.sh, dry-run here. I used a stub sudo that redirects /usr/local/bin to a scratch dir:
- Pinned script →
goreleaser.tar.gz: OK, exit 0,GitVersion: 2.18.2.goreleaser checkvalidates.goreleaser.yaml. - Hash with one character changed →
FAILED, exit 1, nothing installed. - Nonexistent version → curl 404, exit 22, nothing installed.
- Empty hash →
no properly formatted checksum lines found, exit 1.
It runs under set -euo pipefail, and curl -f makes HTTP errors fatal. The hash is compared against the value recorded in the script; checksums.txt is never fetched.
Hash provenance. I matched both recorded hashes against the release's own checksum file and GitHub's asset digest:
- GoReleaser
0a96edc9…: matches. - gitleaks
a65b5253…: matches, and I also recomputed it from the download.
Release job compatibility:
- v2.18.2 is the current latest v2, which is what
~> v2resolved to, so the release version doesn't change. .goreleaser.yamlhas no signs, sboms, docker or nfpms, so no cosign/syft step depended on the action.- The script
cds inside its own process, so the job's cwd anddist/(used by the S3 upload) are unaffected. - The asset is
Linux_x86_64, which is right forubuntu-latest. On an arm runner, the x86_64 binary that installs would fail to run, so it would still fail loudly rather than run something unexpected. - The
goreleaser-checkCI job runs the same script on every PR, so a bad version/hash bump is caught before it reaches a release. It's green here, as is the rest of CI.
golangci-lint. At the pinned action commit, goinstall mode takes version literally (go install …/[email protected]), with no remote version-mapping fetch. Module content is checked against sum.golang.org.
check_pr_template.py. urlopen raises on a 4xx/5xx, so it still fails closed.
Low, suggestion: install before tagging (inline).
— tai2
| echo "GORELEASER_PREVIOUS_TAG=$prev" >> "$GITHUB_ENV" | ||
| fi | ||
|
|
||
| - name: Install GoReleaser |
There was a problem hiding this comment.
Suggestion (Low, same exposure as before but cheap to close): move Install GoReleaser above Create git tag here and in dev-release.yml.
Right now the tag is pushed first. If the download hits a GitHub outage, or the hash fails, the stable tag is left on origin with no release. A re-run then stops at Validate version with tag already exists, and someone has to delete the tag by hand. The install has no dependency on the tag, so running it before the tag makes a failed fetch leave nothing behind.
There was a problem hiding this comment.
Done in 1d39ac7: Install GoReleaser now runs before Create git tag in both release-stable.yml and dev-release.yml, so a failed or tampered download stops the job before any tag is pushed. Steps after the push (GoReleaser itself, AWS credentials, the S3 upload) can still strand a tag; that predates this PR and is noted as a follow-up.
jrusso1020
left a comment
There was a problem hiding this comment.
Approving at 6b83bebb. I focused on the release path as asked; tai2 already ran the install script's failure modes (wrong hash, 404, empty hash), so I didn't repeat those and checked the inputs and the claim behind the switch instead.
The switch away from goreleaser-action is justified
At v7 (f06c13b6), src/goreleaser.ts verifyChecksum catches a failed checksums.txt download, logs Skipping checksum verification, and returns. The binary is then extracted and run. So the PR body's reason is accurate. The script is stricter than the action in every case: it never needs checksums.txt, and the archive must match a hash this repo committed.
What the action did that the script doesn't is the cosign check on checksums.txt. That only proves checksums.txt came from GoReleaser's release key, and the pinned hash already fixes the exact archive, so nothing is lost.
Pins checked against upstream
- GoReleaser
v2.18.2: I downloadedgoreleaser_Linux_x86_64.tar.gzand its sha256 is0a96edc9…606d3. That matches the script and the release'schecksums.txt.v2.18.2is also the latest non-nightly release, so~> v2was resolving to it. - gitleaks
8.28.0:gitleaks_8.28.0_linux_x64.tar.gzhashes toa65b5253…840eb, matching the workflow and the release's checksums file. - Actions:
checkoutv7.0.1,setup-gov7.0.0,golangci-lint-actionv9.3.0 andconfigure-aws-credentialsv6.3.0. Each SHA is the commit its tag names, and each is also the current major tag, so behaviour is unchanged. No unpinneduses:is left in.github/.dependabot.ymlalready coversgithub-actionsweekly, so the RELEASE.md note about reviewing SHA and comment together matches how updates will arrive.
Script
- Fails closed:
set -euo pipefail,curl -f, andsha256sum -cruns beforetar, so a mismatch stops before anything is extracted or moved. - Platform: it hardcodes
Linux_x86_64. On a non-x64 runner the hash wouldn't match and it would fail, which is the safe direction. - Executable: the file is committed as
100755, so the barerun: .github/scripts/install-goreleaser.shworks and picks up the shebang's-euo pipefail.
Nit
- Install before the tag: +1 to tai2's ordering note. In both release workflows the tag is pushed before Install GoReleaser. A download failure, now possible in a new way via a hash mismatch, leaves a pushed tag with no release. Moving the install step above Create git tag costs nothing.
— Rames
terencechotai2-commits
left a comment
There was a problem hiding this comment.
Re-review at 1d39ac7: no findings, and my Low is resolved.
6b83bebb..1d39ac7 is a pure move. In both dev-release.yml and release-stable.yml, the three Install GoReleaser lines moved up, unchanged, to sit right before Create git tag. Nothing else in the diff changed. Order is now install → tag → GoReleaser in both workflows. In stable, install also runs after Validate version and the AWS-config check. So a failed or tampered download stops the job before any tag is pushed.
CI on the new head was still running when I posted (pr-template, secrets and surface-report had passed).
— tai2
jrusso1020
left a comment
There was a problem hiding this comment.
Re-approving at 1d39ac74.
The only change since 6b83bebb is the move. In both dev-release.yml and release-stable.yml, Install GoReleaser now sits above Create git tag, and the step body is byte-identical (6 lines in, 6 out per file). The script runs in its own process with its own temp dir, so the move doesn't affect the working directory of the tag or release steps. A failed or mismatched download now stops the job before any tag is pushed. That resolves the ordering nit.
— Rames
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, drop the pip install Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1d39ac7 to
28f2ad8
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
Re-approving at 28f2ad8a after the rebase. The PR's diff against its new base (3485904, the #425 merge) is byte-identical to the diff I approved at 1d39ac74. The only commit added underneath is #425's .gitattributes, which doesn't touch any file this PR changes. All three commits are signed and verified.
— Rames
Scope
Surfaces: CI and release workflows | Module: Build / release pipeline
Summary
CI and both release workflows ran remote code at versions or content nobody fixed: GitHub Actions by mutable tag, GoReleaser by version range, gitleaks and golangci-lint as unverified downloads, and an unpinned
pip install. The release jobs hold a write-capable token and AWS credentials, so any of those being swapped upstream would run with them. Every one is now pinned to exact content, or removed.How it works
The rule is: a tool runs only if this repository fixed what it is. How each one is fixed:
@v7)goreleaser-action,version: "~> v2".github/scripts/install-goreleaser.sh: exact version, archive sha256 checked before extractioninstall-mode: goinstall, sogo installverifies it against the Go checksum databasepip install requests(unpinned, unhashed)urllib; nothing installedEvery pin is the version already in use today, so behaviour is unchanged. RELEASE.md gains a "Pinned CI tools" section with the bump procedure: change a tool's version and its hash together, taking the hash from that release's
checksums.txt.Design decisions
GoReleaser is installed by a script, not by its action. At the pinned commit,
goreleaser-actionlogs a warning and runs the binary anyway when it cannot fetchchecksums.txt, so pinning its version alone left verification failing open in the jobs that hold release credentials. The script fails closed, and keeps the version and hash in one place for all three workflows.The hashes are recorded in the repository, not fetched alongside the archive. Downloading
checksums.txtfrom the same release would trust the same origin twice. Each recorded hash was matched against three sources: the computed hash of the download, the release'schecksums.txt, and GitHub's own asset digest.Runner images are out of scope.
ubuntu-latestand its preinstalled tools (such as the AWS CLI used by the stable upload) are GitHub's. RELEASE.md says so rather than claiming more than the workflows control.Deferred: the end-user installer.
scripts/install.shverifies archives against a checksum file served from the same CDN as the archive. Closing that needs signed manifests and a separately distributed key, which is a larger change than this one.Testing
bash -eo pipefail: the recorded hash installs the tool, and a wrong hash exits 1 before anything is extracted.goreleaser checkvalidates the config, and a--snapshot --skip=publishrelease builds all six platform archives plus checksums.uses:lines with no other line removed.🤖 Generated with Claude Code