mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-03 21:53:20 +09:00
feat(release): sign the release images and attach their SBOMs
A release has signed its assets since #4861, but not the container images a cluster installed from it pulls, and the SBOM each image carries since #4997 sat in the registry only, readable with buildx and signed by nothing. A user could verify the ISO they booted and not the platform it installed. hack/sign-release-images.sh signs every first-party digest the repinned tree holds with cosign, keylessly, in prepare-release after the stitch, one cosign call per digest so that cosign's per-call timeout does not grow with the number of images. It skips a digest that already verifies, so a re-run stacks no second signature, and verifies each one against the identity docs/release/signatures-and-sbom.md names before hack/upload-assets.sh runs, so nothing is uploaded over an unsigned image. The draft release is created only after that step, so a failed signing run leaves no draft for a re-run to take for a finished release. The signature over an index covers the attestation manifest the index lists, so the SBOM needs none of its own, and cosign stores it as a referrer of the digest in the repository hack/promote-retag.sh copies the digest within, so promote-rc.yaml only verifies, with the rc tree's script, before it stages the stable release, and prints cosign's reason for every digest that fails. hack/collect-image-sboms.sh reads the SBOM attestation of every such image back into cozystack-images-sbom.tar.gz, one SPDX document per platform, and fails on an image that lacks one for any platform its index serves. With cozystack-images.txt, the digests the signatures are bound to, both join the asset list hack/upload-assets.sh hands to hack/sign-release-assets.sh, so the existing checksums signature covers them. docs/release/signatures-and-sbom.md gains the verification recipe for a whole release, which requires a signed checksum entry for each of the two image assets; cozystack-scheduler, whose image a separate repository builds, is not in the list. The bats files pin the scripts, the recipe, the upload list and the two workflow steps. Refs #2937, #3278 Assisted-by: LLM Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
This commit is contained in:
12 files changed
+847
-35
No files matched your search
@@ -616,6 +616,25 @@ jobs:
|
||||
with:
|
||||
cosign-release: v3.1.3
|
||||
|
||||
# The stable release ships the rc's image digests, so their signatures
|
||||
# are the rc's too: tags.yaml signed each index in the repository that
|
||||
# finalize's retag copies the digest within, where cosign keeps the
|
||||
# signature. Checked here, before any stable asset is uploaded, with the
|
||||
# rc tree's script, so an rc cut from a tree without it is promoted as it
|
||||
# always was, and one whose signatures are missing never reaches the
|
||||
# promote PR.
|
||||
- name: Verify the rc image signatures
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
REGISTRY: ghcr.io/cozystack/cozystack
|
||||
RC_TAG: ${{ needs.parse.outputs.rc_tag }}
|
||||
run: |
|
||||
if [ -f hack/sign-release-images.sh ]; then
|
||||
hack/sign-release-images.sh --verify-only packages "$REGISTRY"
|
||||
else
|
||||
echo "::notice::${RC_TAG} was cut from a tree without hack/sign-release-images.sh, so its images carry no signature to check"
|
||||
fi
|
||||
|
||||
- name: Create draft stable release and upload assets
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
||||
|
||||
+49
-28
@@ -502,7 +502,56 @@ jobs:
|
||||
# tag is cut by pull-requests-release.yaml finalize, at the stable tag's
|
||||
# merge commit (#2677 goal 3).
|
||||
|
||||
# hack/upload-assets.sh writes the release SBOM with syft and signs the
|
||||
# checksums of every asset with cosign, keylessly, as this job. syft is
|
||||
# the release tarball checked against a committed SHA-256, for the reason
|
||||
# given at the same step in promote-rc.yaml: this job holds the app token,
|
||||
# the GHCR login and an OIDC token for the signing identity, so it runs no
|
||||
# install script fetched at run time. Bump with promote-rc.yaml.
|
||||
- name: Set up syft
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
env:
|
||||
SYFT_VERSION: "1.54.1"
|
||||
SYFT_SHA256: "c069905b391cc4c20a5ba65ad5c10be2a7ba074f8ea6ad203e24d14e303dad47"
|
||||
run: |
|
||||
syft_dir="${RUNNER_TEMP}/syft"
|
||||
mkdir -p "$syft_dir"
|
||||
curl -fsSL -o "$syft_dir/syft.tar.gz" \
|
||||
"https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz"
|
||||
printf '%s %s\n' "$SYFT_SHA256" "$syft_dir/syft.tar.gz" | sha256sum -c -
|
||||
tar -xzf "$syft_dir/syft.tar.gz" -C "$syft_dir" syft
|
||||
rm -f "$syft_dir/syft.tar.gz"
|
||||
echo "$syft_dir" >> "$GITHUB_PATH"
|
||||
# cosign is the version docs/release/signatures-and-sbom.md asks users
|
||||
# for, as in promote-rc.yaml. Bump with it.
|
||||
- name: Set up cosign
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
||||
with:
|
||||
cosign-release: v3.1.3
|
||||
|
||||
# Every index the stitch repinned the tree on is signed by digest with
|
||||
# this job's OIDC identity, and the SBOM attestation each carries is read
|
||||
# back into one archive, before anything is uploaded: a signature that
|
||||
# does not verify, or an image that lost its SBOM, fails the job with no
|
||||
# asset uploaded. The checksums hack/upload-assets.sh signs next cover
|
||||
# the archive and the image list. The signature over an index covers its
|
||||
# attestation manifest, and promotion copies the digest within the same
|
||||
# repository, so the stable release needs no signing step of its own.
|
||||
- name: Sign the release images and collect their SBOMs
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
run: |
|
||||
set -eu
|
||||
hack/sign-release-images.sh --list _out/assets/cozystack-images.txt packages "$REGISTRY"
|
||||
hack/collect-image-sboms.sh packages "$REGISTRY" _out/assets/cozystack-images-sbom.tar.gz
|
||||
env:
|
||||
DOCKER_CONFIG: ${{ runner.temp }}/.docker
|
||||
REGISTRY: ghcr.io/cozystack/cozystack
|
||||
|
||||
# Create or reuse draft release
|
||||
# Created only after the images are signed and their SBOMs collected: a
|
||||
# draft left by a run that failed before that makes the re-run see an
|
||||
# existing release and skip the whole preparation, leaving the rc unpublished.
|
||||
- name: Create / reuse draft release
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
id: release
|
||||
@@ -536,34 +585,6 @@ jobs:
|
||||
|
||||
core.setOutput('upload_url', rel.upload_url);
|
||||
|
||||
# hack/upload-assets.sh writes the release SBOM with syft and signs the
|
||||
# checksums of every asset with cosign, keylessly, as this job. syft is
|
||||
# the release tarball checked against a committed SHA-256, for the reason
|
||||
# given at the same step in promote-rc.yaml: this job holds the app token,
|
||||
# the GHCR login and an OIDC token for the signing identity, so it runs no
|
||||
# install script fetched at run time. Bump with promote-rc.yaml.
|
||||
- name: Set up syft
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
env:
|
||||
SYFT_VERSION: "1.54.1"
|
||||
SYFT_SHA256: "c069905b391cc4c20a5ba65ad5c10be2a7ba074f8ea6ad203e24d14e303dad47"
|
||||
run: |
|
||||
syft_dir="${RUNNER_TEMP}/syft"
|
||||
mkdir -p "$syft_dir"
|
||||
curl -fsSL -o "$syft_dir/syft.tar.gz" \
|
||||
"https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz"
|
||||
printf '%s %s\n' "$SYFT_SHA256" "$syft_dir/syft.tar.gz" | sha256sum -c -
|
||||
tar -xzf "$syft_dir/syft.tar.gz" -C "$syft_dir" syft
|
||||
rm -f "$syft_dir/syft.tar.gz"
|
||||
echo "$syft_dir" >> "$GITHUB_PATH"
|
||||
# cosign is the version docs/release/signatures-and-sbom.md asks users
|
||||
# for, as in promote-rc.yaml. Bump with it.
|
||||
- name: Set up cosign
|
||||
if: needs.build-amd64.outputs.release_exists == 'false'
|
||||
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
|
||||
with:
|
||||
cosign-release: v3.1.3
|
||||
|
||||
# The assets were built by build-amd64; the operator manifests are
|
||||
# rendered here, from the tree pinned on the index digests.
|
||||
- name: Upload assets
|
||||
|
||||
Reference in new issue
Block a user