-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0641463
commit 6d3eb4f
Showing
3 changed files
with
174 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -32,49 +32,41 @@ Be sure to replace the `ORGANIZATION` placeholder with the name used for your or | |
<!--getting:end--> | ||
|
||
<!--body:start--> | ||
## Compatibility Notes | ||
Like most other Chainguard Images, the Cosign image has few-to-zero CVEs and does not run as the root user. | ||
|
||
## Getting Started | ||
You can use the Cosign image to sign and verify container images via Docker or through automated workflows such as GitHub Actions. | ||
|
||
### Verifying a container image signature | ||
To verify an image signature, use the image to run Cosign's `verify` command. As of Cosign 2.0, Cosign defaults to using Sigstore's keyless mode, you'll need to also specify the OIDC issuer and signer identity to tell Cosign who you trust for the verification process. | ||
|
||
## Image Variants | ||
|
||
Our `latest` tag uses the most recent build of the [Wolfi Cosign](https://github.com/wolfi-dev/os/blob/main/cosign.yaml) package. The following tagged variant is available without authentication: | ||
|
||
- `latest`: This is an image for running `cosign` commands. It does not include a shell or other applications. | ||
|
||
### Cosign Version | ||
This will automatically pull the image to your local system and execute the command `cosign version`: | ||
For convenience, you can export those values as environment variables in your shell, and then tell Docker to pass those environment variables into the running Cosign container: | ||
|
||
```shell | ||
docker run --rm cgr.dev/chainguard/cosign version | ||
export COSIGN_CERTIFICATE_OIDC_ISSUER=https://token.actions.githubusercontent.com | ||
export COSIGN_CERTIFICATE_IDENTITY=https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main | ||
``` | ||
|
||
You should see output similar to this: | ||
The following example uses the Cosign image to verify the signature of the Cosign image itself: | ||
|
||
``` | ||
______ ______ _______. __ _______ .__ __. | ||
/ | / __ \ / || | / _____|| \ | | | ||
| ,----'| | | | | (----`| | | | __ | \| | | ||
| | | | | | \ \ | | | | |_ | | . ` | | ||
| `----.| `--' | .----) | | | | |__| | | |\ | | ||
\______| \______/ |_______/ |__| \______| |__| \__| | ||
cosign: A tool for Container Signing, Verification and Storage in an OCI registry. | ||
... | ||
Platform: linux/arm64 | ||
docker run --rm \ | ||
-e COSIGN_CERTIFICATE_OIDC_ISSUER \ | ||
-e COSIGN_CERTIFICATE_IDENTITY \ | ||
cgr.dev/chainguard/cosign \ | ||
verify cgr.dev/chainguard/cosign | ||
``` | ||
|
||
|
||
|
||
## Usage | ||
|
||
### Signing a container image | ||
|
||
For example, from GitHub Actions: | ||
The following GitHub Action will log into the registry, push an image, and then sign it with Cosign: | ||
|
||
|
||
```yaml | ||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
env: | ||
IMAGE: ghcr.io/${{ github.repository }} | ||
DOCKER_CONFIG: .docker-tmp | ||
|
@@ -85,7 +77,7 @@ jobs: | |
id-token: write | ||
packages: write | ||
steps: | ||
- name: Login to registry | ||
- name: Log in to registry | ||
run: | | ||
set -x | ||
mkdir -p "${DOCKER_CONFIG}" | ||
|
@@ -96,8 +88,8 @@ jobs: | |
- name: Push image with docker | ||
run: | | ||
set -x | ||
docker pull alpine:latest | ||
docker tag alpine:latest "${IMAGE}" | ||
docker pull cgr.dev/chainguard/wolfi-base | ||
docker tag cgr.dev/chainguard/wolfi-base "${IMAGE}" | ||
docker push "${IMAGE}" | ||
- name: Sign image with cosign | ||
run: | | ||
|
@@ -112,35 +104,103 @@ jobs: | |
-a sha=${{ github.sha }} \ | ||
-a run_id=${{ github.run_id }} \ | ||
-a run_attempt=${{ github.run_attempt }} | ||
``` | ||
### Attesting to an image's SBOM | ||
Another common use case for Cosign is attesting to an image's SBOM (software bill of materials). The following command creates an attestation of type `spdxjson` for an image based on the provided SBOM file and image digest: | ||
|
||
```shell | ||
docker run --rm cgr.dev/chainguard/cosign attest --type spdxjson \ | ||
--predicate example-image.spdx.json \ | ||
sha256:7f95c5aa7e789ad51737e03021586949346f38ced1533ecdcb2ef2b9104137ac | ||
``` | ||
|
||
### Verifying a container image signature | ||
A detailed guide on how to sign an SBOM with Cosign is available on [Chainguard Academy](https://edu.chainguard.dev/open-source/sigstore/cosign/how-to-sign-an-sbom-with-cosign/). | ||
|
||
To verify an image signature, use the image to run Cosign's `verify` command. Since as of Cosign 2.0, Cosign defaults to using Sigstore's keyless mode, you'll need to also specify the OIDC issuer and signer identity to tell Cosign who you trust for the verification process. | ||
|
||
For convenience, you can export those values as environment variables in your shell, and then tell Docker to pass those environment variables into the running Cosign container. | ||
### Verifying an Attestation | ||
|
||
For example, to use the Cosign image to verify the signature of the Cosign image itself: | ||
Cosign can also be used to verify the identity of the person or entity issuing an attestation. To verify that an attestation was issued by a specific entity, we use the `cosign verify-attestation` command, specifying the email address of the issuer: | ||
|
||
```shell | ||
export COSIGN_CERTIFICATE_OIDC_ISSUER=https://token.actions.githubusercontent.com | ||
export COSIGN_CERTIFICATE_IDENTITY=https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main | ||
cosign verify-attestation \ | ||
--certificate-oidc-issuer=https://github.com/login/oauth \ | ||
--type https://spdx.dev/Document \ | ||
[email protected] \ | ||
sha256:7f95c5aa7e789ad51737e03021586949346f38ced1533ecdcb2ef2b9104137ac | ||
``` | ||
|
||
docker run --rm \ | ||
-e COSIGN_CERTIFICATE_OIDC_ISSUER \ | ||
-e COSIGN_CERTIFICATE_IDENTITY \ | ||
cgr.dev/chainguard/cosign \ | ||
verify cgr.dev/chainguard/cosign | ||
If the identity is successfully verified, an initial message similar to the following is printed to stderr: | ||
|
||
```shell | ||
Verification for user/example-image@sha256:545a731e803b917daf44e292b03b427427f8090c4e6c4a704e4c18d56c38539f -- | ||
The following checks were performed on each of these signatures: | ||
- The cosign claims were validated | ||
- Existence of the claims in the transparency log was verified offline | ||
- The code-signing certificate was verified using trusted certificate authority certificates | ||
Certificate subject: <[email protected]> | ||
Certificate issuer URL: https://github.com/login/oauth | ||
``` | ||
|
||
## Detailed Environment Information | ||
## Configuration | ||
|
||
The following environment variables are required when verifying a container image signature: | ||
|
||
- `COSIGN_CERTIFICATE_OIDC_ISSUER`: Trusted OIDC issuer, example: `https://token.actions.githubusercontent.com` | ||
- `COSIGN_CERTIFICATE_IDENTITY`: Trusted certificate identity, example: `https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main` | ||
|
||
### Detailed Environment Information | ||
|
||
To obtain detailed information about the environment, you can run the `cosign env` command: | ||
|
||
```shell | ||
docker run --rm cgr.dev/chainguard/cosign env --show-descriptions=false | ||
``` | ||
|
||
You'll get output similar to this, containing the environment variables used to configure Cosign: | ||
|
||
```shell | ||
ACTIONS_ID_TOKEN_REQUEST_TOKEN= | ||
ACTIONS_ID_TOKEN_REQUEST_URL= | ||
BUILDKITE_AGENT_ACCESS_TOKEN= | ||
BUILDKITE_AGENT_ENDPOINT= | ||
BUILDKITE_AGENT_LOG_LEVEL= | ||
BUILDKITE_JOB_ID= | ||
COSIGN_DOCKER_MEDIA_TYPES= | ||
COSIGN_EXPERIMENTAL= | ||
COSIGN_MAX_ATTACHMENT_SIZE= | ||
COSIGN_PASSWORD= | ||
COSIGN_PKCS11_IGNORE_CERTIFICATE= | ||
COSIGN_PKCS11_MODULE_PATH= | ||
COSIGN_PKCS11_PIN= | ||
COSIGN_REPOSITORY= | ||
GITHUB_HOST= | ||
GITHUB_TOKEN= | ||
GITLAB_HOST= | ||
GITLAB_TOKEN= | ||
GOOGLE_SERVICE_ACCOUNT_NAME= | ||
SIGSTORE_CT_LOG_PUBLIC_KEY_FILE= | ||
SIGSTORE_ID_TOKEN= | ||
SIGSTORE_REKOR_PUBLIC_KEY= | ||
SIGSTORE_ROOT_FILE= | ||
SIGSTORE_TSA_CERTIFICATE_FILE= | ||
SOURCE_DATE_EPOCH= | ||
SPIFFE_ENDPOINT_SOCKET= | ||
COSIGN_CERTIFICATE_OIDC_ISSUER=****** | ||
COSIGN_CERTIFICATE_IDENTITY=****** | ||
``` | ||
|
||
## Documentation and Resources | ||
|
||
- [Chainguard Academy: An Introduction to Cosign](https://edu.chainguard.dev/open-source/sigstore/cosign/an-introduction-to-cosign/) | ||
- [Blog Post: Chainguard announces new Sigstore Images to bring critical software supply chain tooling to enterprises](https://www.chainguard.dev/unchained/chainguard-announces-new-sigstore-images-to-bring-critical-software-supply-chain-tooling-to-enterprises) | ||
- [Chainguard Academy: How to Sign an SBOM with Cosign](https://edu.chainguard.dev/open-source/sigstore/cosign/how-to-sign-an-sbom-with-cosign/) | ||
- [Chainguard Academy: Verifying Chainguard Images and Metadata Signatures with Cosign](https://edu.chainguard.dev/chainguard/chainguard-images/verifying-chainguard-images-and-metadata-signatures-with-cosign/) | ||
|
||
- [Video: Signing and Verifying Container Images With Sigstore Cosign and Kyverno ](https://www.youtube.com/watch?v=HLb1Q086u6M) | ||
|
||
<!--body:end--> | ||
|
||
## Contact Support | ||
|
This file contains 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 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