-
Notifications
You must be signed in to change notification settings - Fork 238
ci: add sigstore e2e test suite #2062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stealthybox
wants to merge
6
commits into
main
Choose a base branch
from
sigstore-testing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a1b706d
hack: add sigstore e2e test harness
stealthybox 858404e
hack: match local ARCH for ci scripts
stealthybox ec741e7
hack: cover existing cosign verification in e2e
stealthybox 82b5210
hack: cover trusted-root auto-detection in e2e
stealthybox a1dba3f
cosign: auto-detect trusted root components
stealthybox 48ccc62
cosign: unit-test trusted-root auto-detection
stealthybox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| keys/ | ||
| pki/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Sigstore test harness | ||
| # Usage: | ||
| # make -f hack/sigstore-test/Makefile up # create cluster + registry | ||
| # make -f hack/sigstore-test/Makefile sigstore # install sigstore stack | ||
| # make -f hack/sigstore-test/Makefile build # build and load source-controller | ||
| # make -f hack/sigstore-test/Makefile cosign # fetch cosign v2 and v3 binaries | ||
| # make -f hack/sigstore-test/Makefile test # run signing/verification tests | ||
| # make -f hack/sigstore-test/Makefile all # do everything | ||
| # make -f hack/sigstore-test/Makefile down # tear down | ||
| # | ||
| # kind-cluster.yaml is committed with the default cluster name | ||
| # (sigstore-test) and registry ports (5555, 5557). To target a different | ||
| # cluster name or ports, render an override out-of-tree first: | ||
| # | ||
| # make -f hack/sigstore-test/Makefile kind-config \ | ||
| # CLUSTER_NAME=foo KIND_CONFIG_PATH=/tmp/foo.yaml | ||
| # KIND_CONFIG_PATH=/tmp/foo.yaml make -f hack/sigstore-test/Makefile up | ||
|
|
||
| SCRIPT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
|
||
| .PHONY: all kind-config up registries sigstore tsa down build cosign test | ||
|
|
||
| all: up registries sigstore tsa cosign build test | ||
|
|
||
| # Optional: re-render kind-cluster.yaml from the template. Only needed when | ||
| # overriding CLUSTER_NAME / REG_LOCALHOST_PORT / REG2_LOCALHOST_PORT. | ||
| kind-config: | ||
| bash $(SCRIPT_DIR)/render-kind-config.sh | ||
|
|
||
| up: | ||
| bash $(SCRIPT_DIR)/kind-up.sh | ||
|
|
||
| registries: | ||
| bash $(SCRIPT_DIR)/registries-up.sh | ||
|
|
||
| sigstore: | ||
| bash $(SCRIPT_DIR)/setup-sigstore.sh | ||
|
|
||
| tsa: | ||
| bash $(SCRIPT_DIR)/setup-tsa.sh | ||
|
|
||
| down: | ||
| bash $(SCRIPT_DIR)/kind-down.sh | ||
|
|
||
| build: | ||
| bash $(SCRIPT_DIR)/build-and-load.sh | ||
|
|
||
| cosign: | ||
| bash $(SCRIPT_DIR)/fetch-cosign.sh | ||
|
|
||
| test: | ||
| bash $(SCRIPT_DIR)/test-signing.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env bash | ||
| # Build source-controller and load it into the kind cluster. | ||
| set -euo pipefail | ||
|
|
||
| CLUSTER_NAME="${CLUSTER_NAME:-sigstore-test}" | ||
| IMG="${IMG:-test/source-controller}" | ||
| TAG="${TAG:-latest}" | ||
| ARCH=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/amd64/') | ||
| BUILD_PLATFORM="${BUILD_PLATFORM:-linux/${ARCH}}" | ||
|
|
||
| REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
|
|
||
| echo ">>> building source-controller image" | ||
| cd "${REPO_ROOT}" | ||
| make docker-build IMG="${IMG}" TAG="${TAG}" BUILD_PLATFORMS="${BUILD_PLATFORM}" BUILD_ARGS=--load | ||
|
|
||
| echo ">>> loading image into kind cluster ${CLUSTER_NAME}" | ||
| kind load docker-image --name "${CLUSTER_NAME}" "${IMG}:${TAG}" | ||
|
|
||
| echo ">>> deploying source-controller" | ||
| make dev-deploy IMG="${IMG}" TAG="${TAG}" | ||
|
|
||
| # dev-deploy reapplies the same :latest tag, so the Deployment spec is | ||
| # unchanged and an already-running pod will keep the old image. Force a | ||
| # rollout so re-runs of this script pick up the freshly loaded binary. | ||
| kubectl -n source-system rollout restart deploy/source-controller | ||
|
|
||
| echo ">>> waiting for source-controller rollout" | ||
| kubectl -n source-system rollout status deploy/source-controller --timeout=2m | ||
|
|
||
| echo ">>> source-controller deployed" | ||
| kubectl -n source-system get pods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #!/usr/bin/env bash | ||
| # Fetch a cosign v3 binary for the local sigstore test harness. | ||
| # | ||
| # CI guidance: when running this harness from a GitHub Actions workflow, do | ||
| # NOT run this script. Install cosign with the official action instead, which | ||
| # puts `cosign` on PATH where test-signing.sh expects it: | ||
| # | ||
| # - uses: sigstore/cosign-installer@v3 | ||
| # | ||
| # sigstore/cosign-installer only accepts `cosign-release`, `install-dir`, and | ||
| # `use-sudo` inputs. Each released version of the action hardcodes a default | ||
| # `cosign-release` (v3.0.6 at time of writing), so letting dependabot's | ||
| # github-actions ecosystem bump the action ref is what advances cosign. Avoid | ||
| # pinning `cosign-release:` unless you need a specific version, because | ||
| # dependabot does not edit `with:` input values. | ||
| # | ||
| # This script is a local-dev fallback that downloads cosign directly from | ||
| # GitHub releases. If a `cosign` (or `cosign-v3`) is already on PATH the | ||
| # download is skipped and the on-PATH binary is symlinked into ./bin. | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| BIN_DIR="${SCRIPT_DIR}/bin" | ||
| mkdir -p "${BIN_DIR}" | ||
|
|
||
| OS="$(uname -s | tr '[:upper:]' '[:lower:]')" | ||
| ARCH="$(uname -m)" | ||
| case "${ARCH}" in | ||
| x86_64|amd64) ARCH="amd64" ;; | ||
| aarch64|arm64) ARCH="arm64" ;; | ||
| *) echo "unsupported arch: ${ARCH}"; exit 1 ;; | ||
| esac | ||
|
|
||
| # cosign v3 (latest). Update via dependabot when invoked from CI through | ||
| # sigstore/cosign-installer. | ||
| COSIGN_V3_VERSION="${COSIGN_V3_VERSION:-v3.0.6}" | ||
| COSIGN_V3_URL="https://github.com/sigstore/cosign/releases/download/${COSIGN_V3_VERSION}/cosign-${OS}-${ARCH}" | ||
|
|
||
| # fetch_binary stages a binary at ${dest} unless one of the following is true: | ||
| # - a binary named like ${dest} (or one of the extra PATH aliases in $4..) is | ||
| # already on PATH (e.g. `cosign` installed by sigstore/cosign-installer) | ||
| # - the file already exists (cached local copy) | ||
| # In the on-PATH cases the binary is symlinked into ./bin rather than fetched. | ||
| fetch_binary() { | ||
| local name="$1" url="$2" dest="$3" | ||
| shift 3 | ||
| local candidates=("$(basename "${dest}")" "$@") | ||
| local on_path="" | ||
| local c | ||
| for c in "${candidates[@]}"; do | ||
| on_path="$(command -v "${c}" || true)" | ||
| if [ -n "${on_path}" ] && [ "${on_path}" != "${dest}" ]; then | ||
| echo ">>> ${name} satisfied by '${c}' on PATH at ${on_path}; skipping download" | ||
| ln -sf "${on_path}" "${dest}" | ||
| break | ||
| fi | ||
| on_path="" | ||
| done | ||
| if [ -z "${on_path}" ]; then | ||
| if [ -f "${dest}" ]; then | ||
| echo ">>> ${name} already exists at ${dest}" | ||
| else | ||
| echo ">>> downloading ${name} from ${url}" | ||
| curl -fSL -o "${dest}" "${url}" | ||
| chmod +x "${dest}" | ||
| fi | ||
| fi | ||
| "${dest}" version 2>&1 | head -3 | ||
| echo "" | ||
| } | ||
|
|
||
| # v3 is also satisfied by a plain `cosign` on PATH, which is what | ||
| # sigstore/cosign-installer provides. | ||
| fetch_binary "cosign-v3" "${COSIGN_V3_URL}" "${BIN_DIR}/cosign-v3" cosign | ||
|
|
||
| echo "=== Cosign binary ready ===" | ||
| echo " v3: ${BIN_DIR}/cosign-v3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| nodes: | ||
| - role: control-plane | ||
| kubeadmConfigPatches: | ||
| - | | ||
| kind: ClusterConfiguration | ||
| apiServer: | ||
| extraArgs: | ||
| service-account-jwks-uri: "https://kubernetes.default.svc.cluster.local/openid/v1/jwks" | ||
| containerdConfigPatches: | ||
| - |- | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5555"] | ||
| endpoint = ["http://sigstore-test-registry:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."sigstore-test-registry:5000"] | ||
| endpoint = ["http://sigstore-test-registry:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5557"] | ||
| endpoint = ["http://sigstore-test-registry2:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."sigstore-test-registry2:5000"] | ||
| endpoint = ["http://sigstore-test-registry2:5000"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| kind: Cluster | ||
| apiVersion: kind.x-k8s.io/v1alpha4 | ||
| nodes: | ||
| - role: control-plane | ||
| kubeadmConfigPatches: | ||
| - | | ||
| kind: ClusterConfiguration | ||
| apiServer: | ||
| extraArgs: | ||
| service-account-jwks-uri: "https://kubernetes.default.svc.cluster.local/openid/v1/jwks" | ||
| containerdConfigPatches: | ||
| - |- | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${REG_LOCALHOST_PORT}"] | ||
| endpoint = ["http://${CLUSTER_NAME}-registry:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${CLUSTER_NAME}-registry:5000"] | ||
| endpoint = ["http://${CLUSTER_NAME}-registry:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${REG2_LOCALHOST_PORT}"] | ||
| endpoint = ["http://${CLUSTER_NAME}-registry2:5000"] | ||
| [plugins."io.containerd.grpc.v1.cri".registry.mirrors."${CLUSTER_NAME}-registry2:5000"] | ||
| endpoint = ["http://${CLUSTER_NAME}-registry2:5000"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff in this file should vanish after rebasing, as we split
OCIRepositoryVerificationintoOCIRepositoryVerificationandHelmChartVerification