|
|
@@ -18,12 +18,12 @@ runs:
|
|
|
steps:
|
|
|
|
|
|
- name: Install cosign
|
|
|
- uses: sigstore/cosign-installer@v2
|
|
|
+ uses: sigstore/cosign-installer@42ab207638e63e893c6ead51f15e19ac3e46e6cc # v2
|
|
|
with:
|
|
|
cosign-release: v1.13.6
|
|
|
|
|
|
- name: Install Syft
|
|
|
- uses: anchore/sbom-action/download-syft@v0.7.0
|
|
|
+ uses: anchore/sbom-action/download-syft@f86d330ae046b4a16d86ccc1d9c92e16fefcf304 # v0.7.0
|
|
|
|
|
|
- name: Check Cosign install
|
|
|
shell: bash
|
|
|
@@ -48,33 +48,42 @@ runs:
|
|
|
- name: Get docker image tag
|
|
|
id: container_info
|
|
|
shell: bash
|
|
|
- run: echo "digest=$(crane digest ${{ inputs.image-name }}:${{ inputs.image-tag }})" >> $GITHUB_OUTPUT
|
|
|
+ env:
|
|
|
+ IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
+ IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
+ run: echo "digest=$(crane digest ${IMAGE_NAME}:${IMAGE_TAG})" >> $GITHUB_OUTPUT
|
|
|
|
|
|
- name: Sign image
|
|
|
shell: bash
|
|
|
env:
|
|
|
COSIGN_EXPERIMENTAL: "1"
|
|
|
- run: cosign sign -a GITHUB_ACTOR=${{ github.triggering_actor }} "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
|
|
|
+ IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
+ CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
+ GITHUB_TRIGGERING_ACTOR: ${{ github.triggering_actor }}
|
|
|
+ run: cosign sign -a GITHUB_ACTOR=${GITHUB_TRIGGERING_ACTOR} "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
|
|
|
- name: Attach SBOM to image
|
|
|
shell: bash
|
|
|
id: sbom
|
|
|
env:
|
|
|
COSIGN_EXPERIMENTAL: "1"
|
|
|
+ IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
+ IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
+ CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
run: |
|
|
|
# Image SBOM (OS + application libs contained in the image)
|
|
|
- syft "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}" -o spdx-json=sbom.${{ inputs.image-tag }}.spdx.json
|
|
|
- cosign attest --predicate sbom.${{ inputs.image-tag }}.spdx.json --type spdx "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
|
|
|
- cosign verify-attestation --type spdx ${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }} | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
+ 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 verify-attestation --type spdx ${IMAGE_NAME}@${CONTAINER_DIGEST} | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
|
|
|
# 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.${{ inputs.image-tag }}.spdx.json
|
|
|
- cosign attest --predicate sbom.gomod.${{ inputs.image-tag }}.spdx.json --type spdx "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
|
|
|
- cosign verify-attestation --type spdx ${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }} | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
+ 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 verify-attestation --type spdx ${IMAGE_NAME}@${CONTAINER_DIGEST} | jq '.payload |= @base64d | .payload | fromjson'
|
|
|
|
|
|
- name: Generate provenance
|
|
|
- uses: philips-labs/slsa-provenance-action@v0.7.2
|
|
|
+ uses: philips-labs/slsa-provenance-action@c6e428e3b9ea5ab10fa23efc10d6cbf5f0fe62b1 # v0.7.2
|
|
|
with:
|
|
|
command: generate
|
|
|
subcommand: container
|
|
|
@@ -88,7 +97,10 @@ runs:
|
|
|
id: provenance
|
|
|
env:
|
|
|
COSIGN_EXPERIMENTAL: "1"
|
|
|
+ IMAGE_NAME: ${{ inputs.image-name }}
|
|
|
+ IMAGE_TAG: ${{ inputs.image-tag }}
|
|
|
+ CONTAINER_DIGEST: ${{ steps.container_info.outputs.digest }}
|
|
|
run: |
|
|
|
- jq '.predicate' provenance.${{ inputs.image-tag }}.intoto.jsonl > provenance-predicate.att
|
|
|
- cosign attest --predicate provenance-predicate.att --type slsaprovenance "${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}"
|
|
|
- cosign verify-attestation --type slsaprovenance ${{ inputs.image-name }}@${{ steps.container_info.outputs.digest }}
|
|
|
+ jq '.predicate' provenance.${IMAGE_TAG}.intoto.jsonl > provenance-predicate.att
|
|
|
+ cosign attest --predicate provenance-predicate.att --type slsaprovenance "${IMAGE_NAME}@${CONTAINER_DIGEST}"
|
|
|
+ cosign verify-attestation --type slsaprovenance ${IMAGE_NAME}@${CONTAINER_DIGEST}
|