-
Notifications
You must be signed in to change notification settings - Fork 384
feat(release): add artifact-bound SBOM assurance and keyless attestations #6777
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
Open
mcc0nnell
wants to merge
12
commits into
apache:main
Choose a base branch
from
mcc0nnell:assurance/release-verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+749
−11
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
50da676
feat(release): add artifact-bound SBOM assurance and verification
mcc0nnell 4373afc
fix(release): pin assurance tools by commit
mcc0nnell 9155159
fix(release): address assurance review feedback
mcc0nnell 2f4c814
docs(release): explain keyless OIDC permission
mcc0nnell 7976c82
fix(release): use centralized Syft version check
mcc0nnell 38f7416
fix(ci): preserve no-op nightly tag push
mcc0nnell 01ecf20
ci: keep nightly assurance unsigned
mcc0nnell f5c905f
ci: drop nightly OIDC signing permission
mcc0nnell 37e7317
build: remove Cosign from nightly toolchain
mcc0nnell 6619147
ci: remove nightly signing authority
mcc0nnell 7760d64
ci: verify nightly assurance without signatures
mcc0nnell f2fd66e
Merge fix: keep nightly SBOM assurance unsigned
mcc0nnell 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 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| receipt=${1:-release-assurance.json} | ||
| bundle=${2:-release-assurance.sigstore.json} | ||
| issuer=${COSIGN_CERTIFICATE_OIDC_ISSUER:-https://token.actions.githubusercontent.com} | ||
|
|
||
| for command in cosign jq; do | ||
| command -v "$command" >/dev/null 2>&1 || { | ||
| echo "required command not found: $command" >&2 | ||
| exit 1 | ||
| } | ||
| done | ||
|
|
||
| if [[ ! -f "$receipt" ]]; then | ||
| echo "release assurance receipt not found: $receipt" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| identity=${COSIGN_CERTIFICATE_IDENTITY:-} | ||
| if [[ -z "$identity" ]]; then | ||
| if [[ -z "${GITHUB_WORKFLOW_REF:-}" ]]; then | ||
| echo "GITHUB_WORKFLOW_REF or COSIGN_CERTIFICATE_IDENTITY is required for keyless verification" >&2 | ||
| exit 2 | ||
| fi | ||
| identity="https://github.com/${GITHUB_WORKFLOW_REF}" | ||
| fi | ||
|
|
||
| repository_without_tag() { | ||
| local ref=${1%@*} | ||
| local tail=${ref##*/} | ||
|
|
||
| if [[ "$tail" == *:* ]]; then | ||
| ref=${ref%:*} | ||
| fi | ||
|
|
||
| printf '%s\n' "$ref" | ||
| } | ||
|
|
||
| verify_identity_args=( | ||
| --certificate-identity "$identity" | ||
| --certificate-oidc-issuer "$issuer" | ||
| ) | ||
|
|
||
| export COSIGN_YES=true | ||
|
|
||
| # The local bundle makes the downloadable receipt independently verifiable, | ||
| # while OCI signatures and attestations make the registry artifacts discoverable. | ||
| cosign sign-blob --yes --bundle "$bundle" "$receipt" | ||
| cosign verify-blob \ | ||
| --bundle "$bundle" \ | ||
| "${verify_identity_args[@]}" \ | ||
| "$receipt" >/dev/null | ||
|
|
||
| while IFS= read -r image; do | ||
| tag_ref=$(jq -r '.ref' <<<"$image") | ||
| digest=$(jq -r '.digest' <<<"$image") | ||
| repository=$(repository_without_tag "$tag_ref") | ||
| subject="${repository}@${digest}" | ||
|
|
||
| if [[ ! "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then | ||
| echo "invalid image digest in receipt: $digest" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cosign sign --yes "$subject" | ||
| cosign verify "${verify_identity_args[@]}" "$subject" >/dev/null | ||
|
|
||
| cosign attest --yes --type custom --predicate "$receipt" "$subject" | ||
| cosign verify-attestation \ | ||
| --type custom \ | ||
| "${verify_identity_args[@]}" \ | ||
| "$subject" >/dev/null | ||
|
|
||
| while IFS= read -r sbom; do | ||
| sbom_name=$(jq -r '.name' <<<"$sbom") | ||
| sbom_source=$(jq -r '.source' <<<"$sbom") | ||
| sbom_digest=$(jq -r '.imageDigest' <<<"$sbom") | ||
|
|
||
| if [[ ! -f "$sbom_name" ]]; then | ||
| echo "image SBOM not found: $sbom_name" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ "$sbom_source" != *@"$sbom_digest" ]]; then | ||
| echo "image SBOM source/digest binding mismatch: $sbom_name" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cosign attest --yes --type cyclonedx --predicate "$sbom_name" "$sbom_source" | ||
| cosign verify-attestation \ | ||
| --type cyclonedx \ | ||
| "${verify_identity_args[@]}" \ | ||
| "$sbom_source" >/dev/null | ||
| done < <(jq -c '.sboms[]?' <<<"$image") | ||
| done < <(jq -c '.images[]' "$receipt") | ||
|
|
||
| # Re-run the entire release contract from the consumer side. Strict mode requires | ||
| # every local release asset, recomputes hashes, re-reads embedded Go VCS metadata, | ||
| # and requires the verified OCI predicates to match the exact local JSON files. | ||
| ASSURANCE_REQUIRE_LOCAL_ASSETS=true \ | ||
| COSIGN_CERTIFICATE_IDENTITY="$identity" \ | ||
| COSIGN_CERTIFICATE_OIDC_ISSUER="$issuer" \ | ||
| bash "$(dirname "$0")/verify_release_assurance.sh" \ | ||
| "$receipt" \ | ||
| "$bundle" \ | ||
| release-assurance.verdict.json |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.