Files
cozystack/docs/agents
Aleksei Sviridkin 48d91c2413 feat(release): sign the release images and attach their SBOMs (#5042)
## What this PR does

Follow-up to #4997 (merged as d32092ac9), which puts the SBOM into each
release image's index. Rebased onto `main` at that merge, one commit
`57346c16d`; bats on the touched files 36/36, shellcheck clean. This is
the follow-up agreed there, and the image half of #4759: the release
images get signed, and their SBOMs become a release asset, along the
lines of #4861.

Refs #4759, #2937, #3278

`hack/sign-release-images.sh` runs in `tags.yaml::prepare-release` after
the stitch, before `make upload_assets`. It enumerates every first-party
`<repo>@<digest>` the repinned tree holds the way
`hack/stitch-multiarch.sh` does (the shared enumeration, refs under the
registry, `cozystack-packages` left out), skips each one that already
verifies, signs the rest with the job's OIDC identity, one `cosign sign
--yes` call per ref so that cosign's per-call `--timeout` (3 minutes by
default) does not have to cover every ref's key, Fulcio certificate,
Rekor entry and registry round trips, and verifies every one against the
identity regexp of `hack/sign-release-assets.sh` before returning; the
two scripts' regexps are held equal by bats. A signature that does not
verify fails the job with nothing uploaded. A signature over an index
covers every manifest the index lists by digest, the attestation
manifest with the SBOM included, so the SBOM has no signature of its
own. cosign v3.1.3 writes the signature as a Sigstore bundle, an OCI
referrer of the digest in the same repository (`--new-bundle-format`
defaults to true). GHCR answers `/v2/<name>/referrers/<digest>` with
404, so go-containerregistry lists the referrer under the fallback tag
`sha256-<hex>`, without `.sig`, which `cosign verify` reads the same
way; the `.sig` tag exists only with `--new-bundle-format=false`.
`hack/promote-retag.sh` copies a digest to its stable tag inside that
repository, so the stable release's images carry the rc's signatures.
`promote-rc.yaml::promote` runs the rc tree's script with
`--verify-only` before it stages the stable release, and prints a notice
instead for an rc cut from a tree without the script. Under
`--verify-only` cosign's stderr is kept, so a registry 429 or a Rekor
fetch error is not reported as a missing signature;
`docs/release/ci-failures.md` has a row for that step.

`hack/collect-image-sboms.sh` reads `docker buildx imagetools inspect
<ref> --format '{{ json .SBOM }}'` for the same refs, takes the
platforms the index serves from `--raw` (entries that are not
attestation manifests, keyed as buildx keys them), and writes
`<image>.<os>-<arch>.spdx.json` per platform (or `<image>.spdx.json` for
an image with one platform, whose SBOM buildx prints unkeyed) into
`cozystack-images-sbom.tar.gz`, with fixed order, times and owners so a
re-run gives the same bytes. An image without a non-null SBOM for every
platform its index serves fails the run, naming it and the platforms:
after #4997 every pinned first-party image is built with `SBOM=1`, so a
missing one is a lost attestation, and I preferred no allowlist over one
with no entry (the Talos installer image, which has no SBOM, is not
pinned in the tree).

`hack/upload-assets.sh` adds `cozystack-images.txt` (the refs, one per
line, from `--list`) and the archive to the list it hands to
`hack/sign-release-assets.sh`, so the existing checksums signature
covers both and nothing new signs anything. `promote-rc.yaml` downloads
every rc asset, so both travel to the stable release as the other assets
do. `docs/release/signatures-and-sbom.md` describes the two files and
the image signatures, drops #4997's "The attestations are not signed",
and gains a "How to verify a release" block that checks the checksums,
every asset, every image signature and unpacks the SBOMs in one go, the
image loop in a subshell that exits on the first image that fails;
`docs/agents/image-refs.md` lists the two new consumers of the
enumeration; the SBOM row and the "Signed / reproducible builds" gap of
`docs/security/self-assessment.md` now say what a release publishes and
signs.

### How it was checked

- Bats 1.14.0: `hack/sign-release-images.bats` (13 tests: the refs it
signs and skips, one `cosign sign` call per ref, the identity and issuer
it verifies, equality with the assets regexp and with
`docs/release/signatures-and-sbom.md`, the fenced verify block of
`docs/release/signatures-and-sbom.md` run with cosign stubbed, which
fails on a rejected first image, on a list read from stdin, on a
checksums file that lacks either image asset and on one that lists one
asset twice in place of the other, a failed verify, `--verify-only`,
`--list`, an empty tree, and the shape of both workflow steps by `yq`)
and `hack/collect-image-sboms.bats` (5: file names and content per
platform, member order, owners and times read from the archive headers,
the same bytes twice, an image without an SBOM, an index with an SBOM on
one platform only, a platform with `"SPDX": null`, an empty tree;
dropping `--sort=name`, the owner flags or `--mtime` fails it on XFS and
ZFS), both with cosign and docker stubbed; `hack/upload-assets.bats`
updated for the two assets; `hack/sign-release-assets.bats` and
`hack/ci-tool-installs-contract.bats` unchanged and green. The
repository's bats contract suites (strict setup, no negated asserts, no
exit traps, runner coverage) pass with the two new files. `make
bats-unit-tests`: see the last comment of this PR for the count.
- `shellcheck -x` on both scripts; `zizmor` on `tags.yaml` and
`promote-rc.yaml` reports nothing.
- Checked against the registry, not the code: GHCR has no referrers API
for a cozystack image (404), so the referrer lands in the `sha256-<hex>`
fallback tag; `hack/promote-retag.sh` copies within the repository; `gh
release download` in promote takes every rc asset.
- Not checked: a real keyless run (the first alpha after the merge, like
#4861 and #4997), a stitched index against a live registry (the `.SBOM`
shape follows buildx v0.31.0 `util/imagetools/printers.go`: keyed by
platform for more than one platform, bare otherwise; @lexfrei's ttl.sh
run on #4997 saw the map), and the time the signing adds to
`prepare-release`.

### Decisions for the release owners

- The packages artifact (`cozystack-packages`) and the installer chart
are not signed: promotion republishes both under a new digest, so
signing them means a signing step in `promote` too. Follow-up if wanted.
- Every pre-release signs about forty indexes, each with its own Fulcio
certificate and Rekor entry. #4861 already writes one per release, so
the policy question is settled; the volume is new.
- An image without an SBOM fails the release rather than being listed as
missing. If an exception appears, an allowlist with a reason, as
`hack/multiarch-allowlist`, is the shape to add.
- The identity regexp accepts `promote-rc.yaml` on `main` as well as
`tags.yaml` on a `v*` tag, though only `tags.yaml` signs images today,
so that `docs/release/signatures-and-sbom.md` has one expression for
every release signature. A reader who wants the tighter check drops the
alternative.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

I walked the trigger map against the diff. `hack/upload-assets.sh` adds
two assets and renames none, so the install pages that hardcode asset
filenames on the website are untouched. `tags.yaml` gains a step between
the stitch and the upload and `promote-rc.yaml` a check before the
upload; who cuts and who promotes a release, which the ccp guidance
rests on, is the same. `hack/package.mk` and `hack/common-envs.mk` are
not touched.

### Release note

```release-note
feat(release): every first-party container image of a release is signed with cosign, keylessly, by the `tags.yaml` run that prepared it, and a release carries `cozystack-images.txt` (the pinned images by digest) and `cozystack-images-sbom.tar.gz` (the SPDX SBOM of each image, per platform) as assets covered by the signed checksums. `docs/release/signatures-and-sbom.md` shows how to verify a release end to end. Releases cut from this change on have them.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Releases now include a list of pinned first-party image digests and an
archive of image software bills of materials (SBOMs), with coverage for
each image platform.
* Release image digests are signed, and release checksums cover the
image list and SBOM archive.
* RC promotion checks image signatures before creating a stable release;
unsigned images can block promotion.
* **Documentation**
* Added guidance on release image signatures, SBOM assets, verification,
and related release failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 21:41:44 +03:00
..