|
|
@@ -21,7 +21,7 @@ runs:
|
|
|
# https://github.com/sigstore/cosign-installer/releases/tag/v4.0.0
|
|
|
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
|
|
|
with:
|
|
|
- cosign-release: 'v3.0.3'
|
|
|
+ cosign-release: 'v3.0.2'
|
|
|
|
|
|
- name: Install Syft
|
|
|
# https://github.com/anchore/sbom-action/releases/tag/v0.22.2
|
|
|
@@ -55,7 +55,13 @@ runs:
|
|
|
env:
|
|
|
IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
- run: echo "digest=$(crane digest ${IMAGE_NAME}:${IMAGE_TAG})" >> $GITHUB_OUTPUT
|
|
|
+ run: |
|
|
|
+ echo "::group::Crane digest lookup"
|
|
|
+ echo "Looking up digest for ${IMAGE_NAME}:${IMAGE_TAG}"
|
|
|
+ DIGEST=$(crane digest ${IMAGE_NAME}:${IMAGE_TAG})
|
|
|
+ echo "Found digest: ${DIGEST}"
|
|
|
+ echo "digest=${DIGEST}" >> $GITHUB_OUTPUT
|
|
|
+ echo "::endgroup::"
|
|
|
|
|
|
- name: Sign image
|
|
|
shell: bash
|
|
|
@@ -63,7 +69,11 @@ runs:
|
|
|
IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
GITHUB_TRIGGERING_ACTOR: ${{ github.triggering_actor }}
|
|
|
- run: cosign sign --yes -a GITHUB_ACTOR=${GITHUB_TRIGGERING_ACTOR} "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ run: |
|
|
|
+ echo "::group::Cosign sign"
|
|
|
+ echo "Signing ${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ cosign sign --yes --new-bundle-format=false --use-signing-config=false -a GITHUB_ACTOR=${GITHUB_TRIGGERING_ACTOR} "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ echo "::endgroup::"
|
|
|
|
|
|
- name: Attach SBOM to image
|
|
|
shell: bash
|
|
|
@@ -73,33 +83,53 @@ runs:
|
|
|
IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
run: |
|
|
|
+ echo "::group::Image SBOM generation"
|
|
|
# Image SBOM (OS + application libs contained in the image)
|
|
|
+ echo "Generating image SBOM for ${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
syft "${IMAGE_NAME}@${CONTAINER_DIGEST}" -o spdx-json=sbom.${IMAGE_TAG}.spdx.json
|
|
|
- # cosign attest --predicate sbom.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
- cosign attest --yes --predicate sbom.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
- # cosign verify-attestation --type spdx ${IMAGE_NAME}@${CONTAINER_DIGEST} | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Attest image SBOM"
|
|
|
+ cosign attest --yes --new-bundle-format=false --use-signing-config=false --predicate sbom.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Verify image SBOM attestation"
|
|
|
+ echo "Using certificate-identity-regexp: https://github.com/$GITHUB_REPOSITORY/.*"
|
|
|
cosign verify-attestation --type spdx ${IMAGE_NAME}@${CONTAINER_DIGEST} \
|
|
|
--certificate-identity-regexp "https://github.com/$GITHUB_REPOSITORY/.*" \
|
|
|
--certificate-oidc-issuer https://token.actions.githubusercontent.com | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Go modules SBOM generation"
|
|
|
# Go modules SBOM (dependencies from the source tree)
|
|
|
# Requires repository to be checked out before this composite action runs.
|
|
|
syft dir:. -o spdx-json=sbom.gomod.${IMAGE_TAG}.spdx.json
|
|
|
- # cosign attest --predicate sbom.gomod.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
- cosign attest --yes --predicate sbom.gomod.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Attest Go modules SBOM"
|
|
|
+ cosign attest --yes --new-bundle-format=false --use-signing-config=false --predicate sbom.gomod.${IMAGE_TAG}.spdx.json --type spdx "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Verify Go modules SBOM attestation"
|
|
|
cosign verify-attestation --type spdx ${IMAGE_NAME}@${CONTAINER_DIGEST} \
|
|
|
--certificate-identity-regexp "https://github.com/$GITHUB_REPOSITORY/.*" \
|
|
|
- --certificate-oidc-issuer https://token.actions.githubusercontent.com | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
+ --certificate-oidc-issuer https://token.actions.githubusercontent.com | jq ' .payload |= @base64d | .payload | fromjson | .subject'
|
|
|
+ echo "::endgroup::"
|
|
|
|
|
|
- name: Generate provenance
|
|
|
- # https://github.com/philips-labs/slsa-provenance-action/releases/tag/v0.7.2
|
|
|
- uses: philips-labs/slsa-provenance-action@dddb40e199ae28d4cd2f17bad7f31545556fdd3d # v0.7.2
|
|
|
- with:
|
|
|
- command: generate
|
|
|
- subcommand: container
|
|
|
- arguments: --repository "${{ inputs.image-name }}" --output-path provenance.${{ inputs.image-tag }}.intoto.jsonl --digest "${{ steps.container_info.outputs.digest }}" --tags "${{ inputs.image-tag }}"
|
|
|
+ shell: bash
|
|
|
env:
|
|
|
- COSIGN_EXPERIMENTAL: "0"
|
|
|
- GITHUB_TOKEN: "${{ github.token }}"
|
|
|
+ IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
+ IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
+ CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
+ run: |
|
|
|
+ echo "::group::Generate provenance"
|
|
|
+ ./hack/generate-provenance.sh \
|
|
|
+ --repository "${IMAGE_NAME}" \
|
|
|
+ --digest "${CONTAINER_DIGEST}" \
|
|
|
+ --tags "${IMAGE_TAG}" \
|
|
|
+ --output-path "provenance.${IMAGE_TAG}.intoto.jsonl"
|
|
|
+ echo "::endgroup::"
|
|
|
|
|
|
- name: Attach provenance
|
|
|
shell: bash
|
|
|
@@ -109,10 +139,16 @@ runs:
|
|
|
IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
run: |
|
|
|
+ echo "::group::Prepare provenance predicate"
|
|
|
jq '.predicate' provenance.${IMAGE_TAG}.intoto.jsonl > provenance-predicate.att
|
|
|
- # cosign attest --predicate provenance-predicate.att --type slsaprovenance "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
- cosign attest --yes --predicate provenance-predicate.att --type slsaprovenance "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
- # cosign verify-attestation --type slsaprovenance ${IMAGE_NAME}@${CONTAINER_DIGEST}
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Attest provenance"
|
|
|
+ cosign attest --yes --new-bundle-format=false --use-signing-config=false --predicate provenance-predicate.att --type slsaprovenance "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ echo "::endgroup::"
|
|
|
+
|
|
|
+ echo "::group::Verify provenance attestation"
|
|
|
cosign verify-attestation --type slsaprovenance ${IMAGE_NAME}@${CONTAINER_DIGEST} \
|
|
|
--certificate-identity-regexp "https://github.com/$GITHUB_REPOSITORY/.*" \
|
|
|
--certificate-oidc-issuer https://token.actions.githubusercontent.com
|
|
|
+ echo "::endgroup::"
|