Skip to content

ci: add build provenance attestations for release artifacts#10316

Merged
knqyf263 merged 6 commits into
aquasecurity:mainfrom
knqyf263:ci/build-provenance
Mar 12, 2026
Merged

ci: add build provenance attestations for release artifacts#10316
knqyf263 merged 6 commits into
aquasecurity:mainfrom
knqyf263:ci/build-provenance

Conversation

@knqyf263

@knqyf263 knqyf263 commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Add SLSA build provenance attestations to the release workflow using actions/attest. While cosign keyless signing already provides signature verification, attestations offer a standardized SLSA format and simple verification via gh attestation verify.

Changes:

  • Add attestations: write permission to reusable-release.yaml
  • Add id: goreleaser to the GoReleaser step to access its outputs
  • Add actions/attest@v4.1.0 step after GoReleaser to generate attestations
    from the versioned checksums file (dist/trivy_<version>_checksums.txt)
  • Use fromJSON(steps.goreleaser.outputs.metadata).version to get the
    version without the v prefix, matching GoReleaser's checksum filename

Tested on knqyf263/trivy with a release workflow run (v0.0.2-test-provenance), confirming that:

  • Build provenance attestations are generated successfully
  • The install script's checksum verification works correctly

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Add SLSA build provenance attestations using actions/attest to the
release workflow. This allows users to verify the origin of release
artifacts with `gh attestation verify`.

Changes:
- Add attestations:write permission to reusable-release workflow
- Add actions/attest step after GoReleaser (skipped for canary builds)
- Set fixed checksums filename in goreleaser.yml for predictable path
@knqyf263 knqyf263 added the kind/security Categorizes issue or PR as related to Trivy's own security or internal vulnerabilities. label Mar 3, 2026
@knqyf263 knqyf263 self-assigned this Mar 3, 2026
@knqyf263 knqyf263 requested a review from DmitriyLewen March 3, 2026 18:12
@knqyf263 knqyf263 marked this pull request as ready for review March 4, 2026 06:59
Comment thread .github/workflows/reusable-release.yaml Outdated
if: ${{ inputs.goreleaser_config != 'goreleaser-canary.yml' }}
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4.1.0
with:
subject-checksums: dist/checksums.txt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue with the install script. It currently expects a versioned filename:

trivy/contrib/install.sh

Lines 393 to 394 in 75c4dc0

CHECKSUM=${PROJECT_NAME}_${VERSION}_checksums.txt
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}

Because of this, http_download will fail when trying to fetch trivy_X.Y.Z_checksums.txt (instead of checksums.txt).

We either need to update the install script, or, alternatively, we can just specify the correct filename right here:

Suggested change
subject-checksums: dist/checksums.txt
subject-checksums: dist/trivy_${{ github.ref_name }}_checksums.txt

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed in 88eb9d2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this?
I understand now that we don't trim the v prefix for github.ref_name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I hadn't tested after changing to dist/trivy_${{ github.ref_name }}_checksums.txt. The v prefix needed to be stripped since GoReleaser's {{ .Version }} doesn't include it.

I've fixed this by using fromJSON(steps.goreleaser.outputs.metadata).version instead, which gives the version without the v prefix directly from GoReleaser's output.

Confirmed working: https://github.com/knqyf263/trivy/actions/runs/22934149686/job/66561715834

knqyf263 added 5 commits March 6, 2026 13:25
Use the default goreleaser checksum filename (trivy_X.Y.Z_checksums.txt)
instead of the custom checksums.txt, to stay consistent with the install
script (contrib/install.sh) which expects the versioned filename.
@knqyf263 knqyf263 requested a review from DmitriyLewen March 11, 2026 07:51
@knqyf263 knqyf263 added this pull request to the merge queue Mar 12, 2026
Merged via the queue into aquasecurity:main with commit 88a91cf Mar 12, 2026
15 checks passed
@knqyf263 knqyf263 deleted the ci/build-provenance branch March 12, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/security Categorizes issue or PR as related to Trivy's own security or internal vulnerabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add build provenance attestations for release artifacts

2 participants