fix(ci): compile SLSA generator from source to fix SHA-pinned ref failure - #263
Merged
Conversation
slsa-github-generator v2.1.0's builder-fetch.sh rejects bare commit SHAs (e.g. the SHA emitted by detect-workflow-js when the caller pins the reusable workflow with @<sha>). compile-generator: true uses `git checkout <sha>` instead, which works regardless of ref format. Root cause: builder-fetch.sh requires BUILDER_REF to start with refs/tags/ but detect-workflow-js emits the raw 40-char SHA when the workflow is pinned by commit hash.
2 tasks
Benchmark ComparisonComparing PR branch against main branch: Legend: ✅ OK (no change or faster) | |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the release workflow’s SLSA provenance generation to avoid failures when the reusable workflow is pinned by commit SHA (where BUILDER_REF becomes a bare SHA instead of a refs/tags/* ref).
Changes:
- Enable
compile-generator: truefor theprovenancejob to force the SLSA generator to be built from source instead of downloading a prebuilt binary.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
shinagawa-web
force-pushed
the
fix/slsa-compile-generator
branch
from
May 5, 2026 07:06
8fd1325 to
21d1067
Compare
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.
Summary
compile-generator: trueto theprovenancejob ingoreleaser.ymlRoot cause
The previous workaround in #262 (
private-repository: true) was based on an incorrect diagnosis.The actual failure chain in the v3.0.2 release run was:
When the caller pins the reusable workflow with
@<sha>,detect-workflow-jsemits the raw 40-char commit SHA asBUILDER_REF.builder-fetch.shinside slsa-github-generator requiresBUILDER_REFto start withrefs/tags/before it will download the pre-built binary, so it exits 2. The SHA resolution code that exists later in the script is never reached.This affects both v2.0.0 and v2.1.0 and is independent of
private-repository. The privacy-check (if repoResp.data.private && !override) always passes for this public repository — it was never the root cause.Fix
compile-generator: trueswitches from the download path (builder-fetch.sh) to the compile-from-source path (git checkout <sha>+go build), which accepts a bare SHA ref without therefs/tags/prefix requirement.Smoke test
Verified via
workflow_dispatchon this branch (run 25362560733) with a valid base64-encoded subject. All provenance jobs passed:provenance-test / detect-env✅provenance-test / generator✅ (Generate builder, Create and sign provenance, Upload the signed provenance)provenance-test / final✅This is the first run where
provenance-test / finalsucceeded. Theprivate-repository: trueworkaround in #262 did not pass this test.Upstream
Filed slsa-framework/slsa-github-generator#4503 with a proposed fix (PR slsa-framework/slsa-github-generator#4502) so that the default
compile-generator: falsepath can also handle bare SHA refs in a future release.Test plan
workflow_dispatchon this branchv3.0.3tag and verify theprovenancejob succeeds and.intoto.jsonlis attached to the release