Skip to content

Commit bc24b58

Browse files
committed
feat(release): sign the release assets and attach a source SBOM
No release carried a signature or an SBOM, so users could verify none of the ISO, disk images, kernel, initramfs, manifests and cozypkg binaries they download, and the OpenSSF Scorecard Signed-Releases check and CLOMonitor's signed_releases and sbom checks failed. hack/upload-assets.sh now hands its asset list to the new hack/sign-release-assets.sh before the first upload. That script writes cozystack-source-sbom.spdx.json with syft over the committed tree and the cozypkg binaries, cozystack-checksums.txt with the SHA-256 of every asset and the SBOM, and cozystack-checksums.txt.sigstore.json with a keyless cosign signature over the checksums. The SBOM does not describe the container images or the Talos boot images, which is what its name says; image SBOMs are #2937. The script verifies the bundle against the identities of tags.yaml on a v* tag and promote-rc.yaml on main before returning, so a bad signature fails the job with nothing uploaded, and hack/upload-assets.bats pins the upload list and that order. The two jobs that call make upload_assets get id-token: write, cosign v3.1.3 from the SHA-pinned cosign-installer, and syft from its release tarball checked against a committed SHA-256, because anchore/sbom-action/download-syft runs an install script fetched at run time; hack/ci-tool-installs-contract.bats now covers both. docs/release.md describes the files, what the SBOM covers, the minimum cosign version to verify a download with, what the certificate identity proves, and that promote-rc.yaml is dispatched from main only. Refs #4759 Assisted-by: LLM Signed-off-by: Marian Koreniuk <[email protected]>
1 parent 1d813c9 commit bc24b58

8 files changed

Lines changed: 711 additions & 35 deletions

File tree

‎.github/workflows/promote-rc.yaml‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ jobs:
258258
contents: write # push the release-X.Y.Z staging branch, stage the draft release
259259
packages: write # publish the temporary stable-candidate packages artifact
260260
pull-requests: write # reserved for parity; the PR is opened in open-pr
261+
id-token: write # keyless signing of the release checksums in hack/upload-assets.sh
261262

262263
# open-pr reads these from `promote`, which passes the parse job's validated
263264
# outputs straight through.
@@ -410,8 +411,8 @@ jobs:
410411
# installer values differently between two promotions of the same rc. The
411412
# version tracks packages/core/testing/images/e2e-sandbox/Dockerfile.
412413
#
413-
# yq is additionally pinned BY CONTENT, which nothing else in this repo
414-
# does. It earns the exception by being the one downloaded binary with
414+
# yq is additionally pinned BY CONTENT (syft further down is too, for
415+
# another reason). It earns that by being the one downloaded binary with
415416
# write authority over what a release contains: it is what stamps the
416417
# candidate digest into installer values. skopeo, helm and oras only move
417418
# bytes that are already digest-addressed, so a substituted one is caught
@@ -576,6 +577,41 @@ jobs:
576577
run: |
577578
make manifests assets-cozypkg openapi-json COZYSTACK_VERSION="${STABLE_VERSION}"
578579
580+
# The rc tree's hack/upload-assets.sh writes a fresh SBOM with syft and
581+
# signs the stable checksums with cosign, keylessly, as this job. An rc
582+
# tagged from a tree without hack/sign-release-assets.sh uploads neither,
583+
# and the two tools go unused.
584+
#
585+
# syft is pinned by content, like yq above. This job holds the app token,
586+
# the GHCR login and an OIDC token for the identity users are told to
587+
# trust, and anchore/sbom-action/download-syft, though pinned by commit,
588+
# runs syft's install.sh fetched from a tag at run time. SYFT_SHA256 is the
589+
# release's own checksums entry, whose keyless signature by anchore/syft's
590+
# release workflow was checked when the version was chosen. Bump both
591+
# together, here and in tags.yaml; hack/ci-tool-installs-contract.bats
592+
# holds them equal.
593+
- name: Set up syft
594+
env:
595+
SYFT_VERSION: "1.54.1"
596+
SYFT_SHA256: "c069905b391cc4c20a5ba65ad5c10be2a7ba074f8ea6ad203e24d14e303dad47"
597+
run: |
598+
syft_dir="${RUNNER_TEMP}/syft"
599+
mkdir -p "$syft_dir"
600+
curl -fsSL -o "$syft_dir/syft.tar.gz" \
601+
"https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz"
602+
printf '%s %s\n' "$SYFT_SHA256" "$syft_dir/syft.tar.gz" | sha256sum -c -
603+
tar -xzf "$syft_dir/syft.tar.gz" -C "$syft_dir" syft
604+
rm -f "$syft_dir/syft.tar.gz"
605+
echo "$syft_dir" >> "$GITHUB_PATH"
606+
# cosign is the version docs/release.md asks users for, so the job checks
607+
# its own signature the way they will. The action verifies that binary
608+
# against cosign's keyless and KMS bundles with its digest-pinned
609+
# bootstrap cosign. Bump with tags.yaml; the contract test holds them equal.
610+
- name: Set up cosign
611+
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
612+
with:
613+
cosign-release: v3.1.3
614+
579615
- name: Create draft stable release and upload assets
580616
env:
581617
GH_TOKEN: ${{ steps.app-token.outputs.token }}

‎.github/workflows/tags.yaml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ jobs:
398398
packages: write
399399
pull-requests: write
400400
actions: write
401+
id-token: write # keyless signing of the release checksums in hack/upload-assets.sh
401402

402403
steps:
403404
- name: Generate GitHub App token
@@ -532,6 +533,34 @@ jobs:
532533
533534
core.setOutput('upload_url', rel.upload_url);
534535
536+
# hack/upload-assets.sh writes the release SBOM with syft and signs the
537+
# checksums of every asset with cosign, keylessly, as this job. syft is
538+
# the release tarball checked against a committed SHA-256, for the reason
539+
# given at the same step in promote-rc.yaml: this job holds the app token,
540+
# the GHCR login and an OIDC token for the signing identity, so it runs no
541+
# install script fetched at run time. Bump with promote-rc.yaml.
542+
- name: Set up syft
543+
if: needs.build-amd64.outputs.release_exists == 'false'
544+
env:
545+
SYFT_VERSION: "1.54.1"
546+
SYFT_SHA256: "c069905b391cc4c20a5ba65ad5c10be2a7ba074f8ea6ad203e24d14e303dad47"
547+
run: |
548+
syft_dir="${RUNNER_TEMP}/syft"
549+
mkdir -p "$syft_dir"
550+
curl -fsSL -o "$syft_dir/syft.tar.gz" \
551+
"https://github.com/anchore/syft/releases/download/v${SYFT_VERSION}/syft_${SYFT_VERSION}_linux_amd64.tar.gz"
552+
printf '%s %s\n' "$SYFT_SHA256" "$syft_dir/syft.tar.gz" | sha256sum -c -
553+
tar -xzf "$syft_dir/syft.tar.gz" -C "$syft_dir" syft
554+
rm -f "$syft_dir/syft.tar.gz"
555+
echo "$syft_dir" >> "$GITHUB_PATH"
556+
# cosign is the version docs/release.md asks users for, as in
557+
# promote-rc.yaml. Bump with it.
558+
- name: Set up cosign
559+
if: needs.build-amd64.outputs.release_exists == 'false'
560+
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
561+
with:
562+
cosign-release: v3.1.3
563+
535564
# The assets were built by build-amd64; the operator manifests are
536565
# rendered here, from the tree pinned on the index digests.
537566
- name: Upload assets

0 commit comments

Comments
 (0)