Skip to content

ci: cosign from the rules_img_signer_cosign toolchain (v3.1.2), not cosign-installer - #995

Merged
bpalermo merged 3 commits into
mainfrom
ci/cosign-from-rules-img-signer
Sep 27, 2026
Merged

bpalermo merged 3 commits into
mainfrom
ci/cosign-from-rules-img-signer

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

What

This PR gives the repo one pinned cosign for signing and verifying, in CI and on a workstation. It comes from bazel_dep(name = "rules_img_signer_cosign", version = "0.0.1"), which provides the official release binary as @rules_img_signer_cosign//cosign. The binary is sha256-pinned per platform in the module's cli/cosign_cli.lock.json, currently v3.1.2. It replaces sigstore/cosign-installer@6f9f177… (v4.1.2, which installs cosign v3.0.6) in all three workflows. To bump cosign, bump the bazel_dep.

  • //tools/cosign (sh_binary, public): runs the pinned binary from runfiles. It runs in BUILD_WORKING_DIRECTORY with the caller's environment. Usage: bazel run //tools/cosign -- <args>.
  • //tools/cosign:verify_image_signatures (public): wraps scripts/verify-image-signatures.sh and exports COSIGN as the pinned binary. The script still works standalone.
  • //tools/cosign:version_test: network-free check that cosign version reports GitVersion: v3.1.2. I saw it fail with EXPECTED=v3.0.6 before setting the real value.
  • Workflows:
    • publish.yaml and the proxy-release.yml sign job now run bazel build //tools/cosign first. Signing is bazel run //tools/cosign -- sign --yes --recursive …, with the same flags as before. Verifying is bazel run //tools/cosign:verify_image_signatures -- ….
    • publish-verify.yaml runs its cosign pass through the same target.
    • proxy-release.yml sign and publish-verify.yaml had no Bazel setup. Each now has the plain Setup Bazel step used by ci.yaml's shell job (bazelisk and repository cache, no BuildBuddy key).
    • None of these invocations pass --config, so cosign is fetched and run locally on the runner, never on RBE.
  • Docs: the docs/runbook.md cosign section and the script headers now say bazel run //tools/cosign is the way to get cosign.

Why only the CLI, not the module's signer plugin

rules_img_signer_cosign also ships sign-oci-artifact, a plugin for rules_img's signing_config / img deploy. That plugin stores signatures as OCI 1.1 referrers, but ghcr.io has no Referrers API. The sign step, the verify step and the publish-verify sweep all rely on cosign's sha256-<hex> tag, so signing stays an explicit cosign sign step after the pushes.

How OIDC reaches cosign under bazel run

bazel run execs the binary with the Bazel client's environment, which here is the step's environment. --incompatible_strict_action_env and --action_env only affect build actions, not the run, and the wrapper execs cosign without changing the environment. So ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN (provided by id-token: write) reach cosign unchanged, as does COSIGN_YES.

I checked this locally with a --run_under probe on //tools/cosign, with both variables set in the calling shell. The target process received both, and BUILD_WORKING_DIRECTORY was the caller's directory.

Not provable before merge: the keyless sign itself. It runs only on main, and nothing was signed from this branch.

Verification (read-only, workstation, linux/amd64)

$ bazel run //tools/cosign -- version
GitVersion:    v3.1.2
GitCommit:     193d2153431f8bb0d945a4c1ee721872f73add67
Platform:      linux/amd64

agent image from main's latest publish (7f8f825, tag dev-7f8f825…, bundle layout):

  verified index ghcr.io/bpalermo/aether/agent@sha256:066267b66b722ab39194c5d912ba9892ea683e7210b56243881e10ea9be8a8c6
  verified child ghcr.io/bpalermo/aether/agent@sha256:bad85c4f554f54bcf675d6f4c7872bf1b7a6d32424b0b21628140bb288a4792f
  verified child ghcr.io/bpalermo/aether/agent@sha256:6abc270316915ff836229cfddfccea08f614c9a0b267a9eccb2a5dda78532fe6
PASS: 3 manifest(s) verified (1 index(es) + their children)

The same PASS came from a relative --file run from another directory. v3.1.2 also verifies the legacy .sig layout: agent@sha256:14949387… (5b0c199, 2026-09-22) passes 3/3.

aether-proxy 574d5211…, under the proxy-release identity. This is the first hand verification of a signed proxy image:

  verified index ghcr.io/bpalermo/aether/aether-proxy@sha256:574d52114caa86b3a1670f12009ef29b3939a8aeecd2895e7d50f7d6c3e1aee8
  verified child ghcr.io/bpalermo/aether/aether-proxy@sha256:4d7b967b4b414a37c91c8d8b30d709a6d0edfcdc01845f057a29324b2e09e628
  verified child ghcr.io/bpalermo/aether/aether-proxy@sha256:1505e36b6cab8992c3a7248861c1a272e1710c9b01363126e1496298f3557d21
PASS: 3 manifest(s) verified (1 index(es) + their children)

Expected failure: the old unsigned proxy 938c5a57…:

  FAILED   index …aether-proxy@sha256:938c5a57…: error during command execution: no signatures found
  FAILED   child …aether-proxy@sha256:bb53bed6…: error during command execution: no signatures found
  FAILED   child …aether-proxy@sha256:4a90a7fb…: error during command execution: no signatures found
FAIL: 3 manifest(s) did not verify, 0 did, across 1 index(es)      (exit 1)

Other checks:

  • All three workflow YAMLs parse.
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //tools/... //scripts/... is green. The shellcheck reports for all three new scripts exist and are empty, so they were actually linted.
  • bazel test //tools/... passes.
  • scripts/check-shell-lint.sh reports OK (36 scripts covered).

Things to watch

  • cosign 3.0.6 → 3.1.2: v3.1.1 marked --new-bundle-format and other flags as deprecated for v4, and they no longer show in --help. The sign step never passed any of them. I could not check locally whether v3.1.2 still writes the sha256-<hex> fallback tag on ghcr.io, because that needs a real sign. After the first post-merge publish, publish-verify's registry-side layout check will confirm it.
  • cosign verify still has no --recursive in v3.1.2, so the walk in the verify script is still needed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…osign-installer

One pinned cosign for signing and verifying, in CI and locally: the
official release binary that bazel_dep rules_img_signer_cosign 0.0.1
downloads per platform, sha256-pinned in that module's lock (v3.1.2).
Bumping cosign is now bumping the bazel_dep.

- MODULE.bazel: bazel_dep(rules_img_signer_cosign, 0.0.1). Only the CLI
  (@rules_img_signer_cosign//cosign) is used. The module's
  sign-oci-artifact signer plugin is not: it stores signatures as OCI 1.1
  referrers, and ghcr.io has no Referrers API.
- //tools/cosign: an sh_binary that runs the pinned binary from runfiles
  in the caller's directory with the caller's environment.
  //tools/cosign:verify_image_signatures wraps
  scripts/verify-image-signatures.sh with COSIGN exported (the script
  still runs standalone). //tools/cosign:version_test is a network-free
  guard that the binary is v3.1.2.
- publish.yaml, proxy-release.yml (sign job) and publish-verify.yaml:
  the SHA-pinned sigstore/cosign-installer steps are replaced by
  `bazel build //tools/cosign` and `bazel run //tools/cosign -- sign
  --yes --recursive ...` / `bazel run
  //tools/cosign:verify_image_signatures -- ...`. These run locally with
  no --config=remote. proxy-release's sign job and publish-verify gain a
  plain Setup Bazel step. `bazel run` execs with the client environment,
  so the Actions OIDC request variables reach cosign; this was checked
  locally with a --run_under env probe.
- runbook + script headers: `bazel run //tools/cosign` is how you get
  cosign, and the runbook explains why the signer plugin is not used.

Verified by hand with the new target: agent@066267b6 (main 7f8f825,
bundle layout) PASS 3/3; agent@14949387 (5b0c199, legacy .sig) PASS 3/3;
aether-proxy@574d5211 under the proxy-release identity PASS 3/3, the
first hand verification of a signed proxy image; aether-proxy@938c5a57
(pre-signing) FAIL "no signatures found" x3, as expected.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 3f29108 into main Sep 27, 2026
36 of 38 checks passed
@bpalermo
bpalermo deleted the ci/cosign-from-rules-img-signer branch September 27, 2026 16:28
bpalermo added a commit that referenced this pull request Sep 27, 2026
…uay migration phase 1, no behaviour change) (#998)

* ci: one image-registry setting and a quay-capable registry library (Quay migration phase 1, no behaviour change)

Proposal 040 moves every image and chart from ghcr.io/bpalermo/aether to the
quay.io org `aethermesh`. This is phase 1: nothing moves yet, but the move
becomes a one-file flip and the verification library already works against
both registries.

One setting: bazel/img/registry.bzl (IMAGE_REGISTRY, IMAGE_NAMESPACE,
IMAGE_NAME_OVERRIDES, CHART_REPOSITORY_PREFIX + image_repository(),
image_reference(), chart_repository(), chart_registry_url(),
registry_token_url()). Every go_multi_arch_image call site, the chart pushes
and the proxy-supervisor template test, the e2e go_test (x_defs) and
//bazel/proxy_pin read it; the //proxy workspace carries a byte-identical copy
(proxy/bazel/registry.bzl). Workflows, verifiers and e2e scripts read it through
scripts/image-registry.sh (strict parse, no defaults); IMAGE_REGISTRY /
PROXY_IMAGE in the workflows are now derived into $GITHUB_ENV.
scripts/check-registry-config.sh (ci + proxy shell jobs) asserts the setting
parses, the proxy copy matches, the aether-proxy pin agrees, and no literal
survives outside a written-down allow-list; //bazel/img:registry_test pins the
shell reader against the Starlark helpers.

scripts/ghcr-lib.sh -> scripts/registry-lib.sh (ghcr-lib.sh is a shim; every
ghcr_* name is an alias): REGISTRY_HOST-parameterised, per-host token endpoint
(ghcr /token, quay /v2/auth), and registry_referrers (OCI 1.1; a 404 means "no
API", never "no signatures"). registry_signature_layout[_direct] now also
reports `referrer` for a cosign sign-bundle referrer (an attestation bundle or a
buildx attestation does not count). check-ghcr-lookup.sh ->
check-registry-lookup.sh with a fake quay; check-signature-layout.sh gains the
referrer cases.

Every rendered coordinate is unchanged (image_push/image_load/oci_push/helm
push targets queried before and after). Chart patch versions bumped because
their BUILD files changed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* chart: 0.95.6 (main took 0.95.5 with the #995 proxy pin)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
bpalermo added a commit that referenced this pull request Sep 27, 2026
…fetch, so proxy.golang.org flakes stop failing jobs (#1001) (#1016)

* ci: persist Bazel's repository cache across runs and retry the first fetch, so proxy.golang.org flakes stop failing jobs (#1001)

The repository cache was already restored (setup-bazel repository-cache:
true) but keyed on the root MODULE.bazel alone, shared with the proxy
workspace's jobs, and saved by whichever job finished first. A job that
fetched little -- or a proxy job -- could write the entry every later job
restored as an exact hit and never re-saved, which is how #995's netns job
fetched googleapis/api from proxy.golang.org with a 1.9 GB cache freshly
restored.

- Key on MODULE.bazel + MODULE.bazel.lock + go.mod + go.sum (root) and
  proxy/MODULE.bazel + proxy/MODULE.bazel.lock (proxy), in separate
  cache-version namespaces (root-1 / proxy-1).
- One saver per workflow (ci/main `diff`, the proxy build matrix per arch),
  whose warm-up fetches for all of //...; every other job cache-save: false.
- scripts/ci-bazel-warmup.sh: `bazel build --nobuild` as each job's first
  Bazel step, retried 3x with 20s/40s backoff only on a repository-fetch
  error, never talking to BuildBuddy. scripts/check-ci-bazel-warmup.sh
  pins the contract with a stub bazel in the `shell` job.
- docs/runbook.md: "CI: external repository fetches".

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* ci: empty commit — second CI run to prove the repository-cache restore (#1001)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant