Skip to content

Commit 7edec36

Browse files
committed
Attest per-platform SPDX SBOMs with cosign
Extract each platform's SPDX document from the BuildKit SBOM attestation and sign it as a cosign spdxjson attestation against the manifest-list digest, so downstream consumers (e.g. Kyverno image-verification policies) can verify the predicate signature rather than relying on the unsigned BuildKit attachment.
1 parent dc5c7fd commit 7edec36

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,30 @@ jobs:
6969
[[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]
7070
cosign sign --yes "${IMAGE}@${DIGEST}"
7171
72-
- name: Verify remote provenance and SBOM attestations
72+
- name: Verify BuildKit attestations and extract SPDX predicates
7373
env:
7474
DIGEST: ${{ steps.build.outputs.digest }}
7575
IMAGE: ghcr.io/${{ github.repository }}
7676
run: |
7777
set -euo pipefail
7878
reference="${IMAGE}@${DIGEST}"
79-
docker buildx imagetools inspect "$reference" --format '{{ json .Provenance }}' \
80-
| jq -e 'type == "object" and length > 0' >/dev/null
81-
docker buildx imagetools inspect "$reference" --format '{{ json .SBOM }}' \
82-
| jq -e 'type == "object" and length > 0' >/dev/null
79+
docker buildx imagetools inspect "$reference" --format '{{ json .Provenance }}' > provenance.json
80+
docker buildx imagetools inspect "$reference" --format '{{ json .SBOM }}' > sbom.json
81+
82+
for platform in linux/amd64 linux/arm64; do
83+
jq -e --arg p "$platform" '.[$p].SLSA | type == "object" and length > 0' \
84+
provenance.json >/dev/null
85+
jq -e --arg p "$platform" '.[$p].SPDX' sbom.json > "sbom-${platform//\//-}.spdx.json"
86+
done
87+
88+
- name: Attest platform SBOMs by digest
89+
env:
90+
DIGEST: ${{ steps.build.outputs.digest }}
91+
IMAGE: ghcr.io/${{ github.repository }}
92+
run: |
93+
set -euo pipefail
94+
[[ "$DIGEST" =~ ^sha256:[0-9a-f]{64}$ ]]
95+
reference="${IMAGE}@${DIGEST}"
96+
for predicate in sbom-linux-amd64.spdx.json sbom-linux-arm64.spdx.json; do
97+
cosign attest --yes --type spdxjson --predicate "$predicate" "$reference"
98+
done

0 commit comments

Comments
 (0)