-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generate SLSA provenance for release binaries #730
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5d28ecc
Support for SLSA provenance generation
laurentsimon 60098b0
updates
laurentsimon 8fa30c2
updates
laurentsimon bfe600c
updates
laurentsimon af9ae56
updates
laurentsimon f6a984f
updates
laurentsimon 6059d03
comment
laurentsimon 838bd31
update
laurentsimon fbd1ed1
update
laurentsimon 17d55af
update
laurentsimon 563a98e
update
laurentsimon ff9e28a
update
laurentsimon 822d8fb
update
laurentsimon d1c801b
update
laurentsimon a5955a5
update
laurentsimon 4a4897b
update
laurentsimon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ on: | |
|
||
jobs: | ||
goreleaser: | ||
outputs: | ||
hashes: ${{ steps.hash.outputs.hashes }} | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
@@ -16,8 +19,79 @@ jobs: | |
go-version: 1.18 | ||
check-latest: true | ||
- uses: goreleaser/[email protected] | ||
id: run-goreleaser | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Generate subject | ||
id: hash | ||
env: | ||
ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" | ||
run: | | ||
set -euo pipefail | ||
checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') | ||
echo "::set-output name=hashes::$(cat $checksum_file | base64 -w0)" | ||
provenance: | ||
needs: [goreleaser] | ||
permissions: | ||
actions: read # To read the workflow path. | ||
id-token: write # To sign the provenance. | ||
contents: write # To add assets to a release. | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" | ||
upload-assets: true | ||
|
||
verification: | ||
needs: [goreleaser, provenance] | ||
runs-on: ubuntu-latest | ||
permissions: read-all | ||
steps: | ||
# Note: this will be replaced with the GHA in the future. | ||
- name: Install the verifier | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -euo pipefail | ||
gh -R slsa-framework/slsa-verifier release download v1.2.0 -p "slsa-verifier-linux-amd64" | ||
chmod ug+x slsa-verifier-linux-amd64 | ||
# Note: see https://github.com/slsa-framework/slsa-verifier/blob/main/SHA256SUM.md | ||
COMPUTED_HASH=$(sha256sum slsa-verifier-linux-amd64 | cut -d ' ' -f1) | ||
EXPECTED_HASH="37db23392c7918bb4e243cdb097ed5f9d14b9b965dc1905b25bc2d1c0c91bf3d" | ||
if [[ "$EXPECTED_HASH" != "$COMPUTED_HASH" ]];then | ||
echo "error: expected $EXPECTED_HASH, computed $COMPUTED_HASH" | ||
exit 1 | ||
fi | ||
- name: Download assets | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -euo pipefail | ||
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "*.tar.gz" | ||
gh -R "$GITHUB_REPOSITORY" release download "$GITHUB_REF_NAME" -p "attestation.intoto.jsonl" | ||
- name: Verify assets | ||
env: | ||
CHECKSUMS: ${{ needs.goreleaser.outputs.hashes }} | ||
PROVENANCE: "${{ needs.provenance.outputs.attestation-name }}" | ||
run: | | ||
set -euo pipefail | ||
checksums=$(echo "$CHECKSUMS" | base64 -d) | ||
while read -r line; do | ||
fn=$(echo $line | cut -d ' ' -f2) | ||
echo "Verifying $fn" | ||
./slsa-verifier-linux-amd64 -artifact-path "$fn" \ | ||
-provenance "$PROVENANCE" \ | ||
-source "github.com/$GITHUB_REPOSITORY" \ | ||
-tag "$GITHUB_REF_NAME" | ||
done <<<"$checksums" |
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this will create an attestation file
attestation.intoto.jsonl
by default. The name can be customized with the option:attestation-name: xxx.intoto.jsonl
if you want.