Files
image-tools/bin/install-cosign.sh
T
Christian Manivong d139d66c3d
CI / Tests, lint (push) Successful in 18s
feat: judge, sign and verify netOrk's images in one place (NetOrk/netork#1390)
The CIS gate, the SBOM, the cosign signature and the matcher's verdict lived
in NetOrk/base-os, the head of the chain. Every link below it -- base-python,
engine, ui, satellite, the service images -- needs the same, so the tools
move here, and every image repository pins them by commit.

- image_tools: cis.py, cis_os.sh, sbom.py and verify.py from base-os. The
  image's own repository holds its cis.toml and packages.allow; both default
  to the working directory.
- bin/sign.sh signs whatever platforms a reference holds: base-os's index of
  amd64 and arm64 (EXPECT_PLATFORMS) or a dev image's single manifest
  (image_tools/platforms.py).
- bin/verify-base.sh checks every FROM image of a Dockerfile against
  cosign.pub before a build; one without a digest is refused
  (image_tools/dockerfile.py).
- bin/install-cosign.sh installs cosign v3.1.3 for amd64 and arm64 runners,
  checked against the release checksums.
- actions/verify-base, judge, sign wrap them for the workflows.
- cosign.pub is the public half of the COSIGN_PRIVATE_KEY_B64 org secret,
  the key rotated on 2026-10-22.
2026-10-22 16:23:00 +02:00

26 lines
927 B
Bash
Executable File

#!/bin/bash
# install-cosign.sh [dir]: cosign, pinned, checked against its release checksum.
#
# Bump the version and both checksums together, from the release's
# cosign_checksums.txt.
set -euo pipefail
VERSION=v3.1.3
SHA256_AMD64=4629c757b7618056f8ddd7e2625ae9fdd94c0372a65049520bc7d9df9efc7f71
SHA256_ARM64=c5d324e091826b0d7a78eb16fef316450b4eb9aaec045611c08ba06f5e73220a
dir=${1:-/usr/local/bin}
case $(uname -m) in
x86_64) arch=amd64 sha=$SHA256_AMD64 ;;
aarch64) arch=arm64 sha=$SHA256_ARM64 ;;
*) echo "no cosign checksum for $(uname -m)" >&2; exit 1 ;;
esac
if [ -x "$dir/cosign" ] && echo "$sha $dir/cosign" | sha256sum -c - >/dev/null 2>&1; then
exit 0
fi
tmp=$(mktemp)
curl -fsSLo "$tmp" "https://github.com/sigstore/cosign/releases/download/$VERSION/cosign-linux-$arch"
echo "$sha $tmp" | sha256sum -c - >/dev/null
install -m 0755 "$tmp" "$dir/cosign"
rm -f "$tmp"
echo "cosign $VERSION ($arch) in $dir"