feat: add container image provenance attestation to shared workflow#87
Conversation
Adds actions/attest-build-provenance to the docker-build job so all components using this shared workflow (operator, kubevuln, storage, node-agent, synchronizer, http-request, prometheus-exporter) get SLSA provenance attestation on every release. Captures the image digest from the build-push step and attests it using subject-digest for accurate per-digest attestation. Also adds attestations: write permission required by the action. Signed-off-by: Varadraj75 <agrawalvaradraj2007@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe workflow grants ChangesImage Provenance Attestation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the GitHub Actions workflow that builds and pushes the container image to also generate and publish a build provenance attestation for the produced image.
Changes:
- Adds
attestations: writeworkflow permission to allow publishing build attestations. - Adds a step
id: buildso the image digest output can be referenced later. - Adds an “Attest image provenance” step using
actions/attest-build-provenance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Varadraj75 <agrawalvaradraj2007@gmail.com>
matthyx
left a comment
There was a problem hiding this comment.
Reviewed the provenance-attestation change. The approach (capture digest from build-push, attest per-digest, push to registry) is sound and the action is correctly SHA-pinned. I found one blocking issue and one thing to verify before this can be merged/run — details inline.
| - name: Attest image provenance | ||
| uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0 | ||
| with: | ||
| subject-name: ${{ inputs.IMAGE_NAME }}:${{ steps.image-prerelease-tag.outputs.IMAGE_TAG_PRERELEASE }} |
There was a problem hiding this comment.
Blocker: subject-name must not include a tag when push-to-registry: true.
With push-to-registry: true, the attest-build-provenance docs are explicit:
it is important that the
subject-namespecify the fully-qualified image name (e.g.ghcr.io/user/app). Do NOT include a tag as part of the image name — the specific image being attested is identified by the supplied digest.
Here subject-name is ${{ inputs.IMAGE_NAME }}:${{ steps.image-prerelease-tag.outputs.IMAGE_TAG_PRERELEASE }}, which appends the -prerelease tag. The action will fail when it tries to push the attestation to the registry (the OCI reference is built from subject-name + the digest, and a tagged name is rejected).
Fix:
subject-name: ${{ inputs.IMAGE_NAME }}The digest in subject-digest already uniquely identifies the image, so dropping the tag is correct.
There was a problem hiding this comment.
Fixed, removed the tag from subject-name. The digest in subject-digest already uniquely identifies the image so the tag is not needed.
| packages: write | ||
| contents: read | ||
| pull-requests: read | ||
| attestations: write |
There was a problem hiding this comment.
Verify caller permissions — attestations: write may not take effect here.
This is a reusable workflow (workflow_call). For reusable workflows the GITHUB_TOKEN permissions are capped by the caller: a permissions: block in the called workflow can only narrow what the caller grants, never widen it. So adding attestations: write here only has an effect if every caller (operator, kubevuln, storage, node-agent, synchronizer, http-request, prometheus-exporter) also grants attestations: write on the job that does uses: this workflow.
If a caller doesn't grant it, the attest step fails with a 403 when persisting the attestation to the GitHub attestations API — and it would only surface on a real release-labeled run, not in this PR's checks.
Please confirm the callers already grant attestations: write (same way they must already grant id-token: write for keyless cosign), or update them alongside this change.
There was a problem hiding this comment.
Checked all 7 callers, none of them currently grant attestations: write. Will add it to all of them. Also noticed node-agent uses a local copy of the workflow instead of the shared one so it will need a separate update. Should I open separate PRs per repo or is there a preferred way to batch them?
When push-to-registry: true, subject-name must be the fully-qualified image name without a tag. The digest in subject-digest already uniquely identifies the image. Signed-off-by: Varadraj75 <agrawalvaradraj2007@gmail.com>
I don't think there's a way... just open separate PRs in each repo as needed. Thanks. |
|
Thanks for the fix — the One thing still worth confirming before a release run (following up on my earlier inline note): since this is a reusable ( So please verify the workflows that call this one (operator, kubevuln, storage, node-agent, synchronizer, http-request, prometheus-exporter) grant |
|
Confirmed, none of the 7 callers currently grant attestations: write. Will open separate PRs for each repo to add it. |
…d-provenance actions/attest-build-provenance v4+ is a wrapper on actions/attest. New implementations should use actions/attest directly per upstream guidance. Signed-off-by: Varadraj75 <agrawalvaradraj2007@gmail.com>
|
Updated to actions/attest@v4.1.0 (SHA-pinned) as suggested by @scop , attest-build-provenance v4+ delegates to actions/attest anyway so this uses the correct action directly. |
Overview
Adds
actions/attest-build-provenanceto the sharedincluster-comp-pr-merged.yamlworkflow so all components using it get SLSA provenance attestation on every release. This is the follow-up to kubescape/kubescape#2346 which added binary attestation to the CLI release workflow.Components covered by this single change:
The image digest is captured from the
build-pushstep and attested usingsubject-digestfor accurate per-digest attestation. The attestation is pushed to the registry alongside the image.Users can verify any released image with:
Additional Information
Also adds
attestations: writepermission to thedocker-buildjob as required by the action.Related issues/PRs
Checklist before requesting a review
Summary by CodeRabbit