-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add SBOM to images * attach attestation using cosign * add container sbom verification to README.md * add sbom attestation to release pipeline * add trivy scan to release
- Loading branch information
Showing
4 changed files
with
102 additions
and
17 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 |
---|---|---|
|
@@ -140,6 +140,27 @@ jobs: | |
tags: | | ||
ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }} | ||
- name: Install Cosign | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: 'v2.4.1' | ||
|
||
- name: Create SBOM of container image | ||
uses: anchore/sbom-action@v0 | ||
with: | ||
image: ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${{ steps.build-and-push.outputs.digest }} | ||
artifact-name: py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json | ||
output-file: py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json | ||
|
||
- name: Sign image with a key and add sbom attestation | ||
run: | | ||
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${DIGEST} | ||
cosign attest --yes --key env://COSIGN_PRIVATE_KEY --predicate py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${DIGEST} | ||
env: | ||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
|
||
# To avoid the trivy-db becoming outdated, we save the cache for one day | ||
- name: Get date | ||
id: date | ||
|
@@ -167,16 +188,3 @@ jobs: | |
# So we need to change the permissions before caching the database. | ||
- name: Change permissions for trivy.db | ||
run: sudo chmod 0644 ./cache/db/trivy.db | ||
|
||
- name: Install Cosign | ||
uses: sigstore/[email protected] | ||
with: | ||
cosign-release: 'v2.4.1' | ||
|
||
- name: Sign image with a key | ||
run: | | ||
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${DIGEST} | ||
env: | ||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} |
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 |
---|---|---|
|
@@ -96,10 +96,46 @@ jobs: | |
with: | ||
cosign-release: 'v2.4.1' | ||
|
||
- name: Sign image with a key | ||
- name: Create SBOM of container image | ||
uses: anchore/sbom-action@v0 | ||
with: | ||
image: ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${{ steps.build-and-push.outputs.digest }} | ||
artifact-name: py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json | ||
output-file: py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json | ||
|
||
- name: Sign image with a key and add sbom attestation | ||
run: | | ||
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${DIGEST} | ||
cosign attest --yes --key env://COSIGN_PRIVATE_KEY --predicate py${{ matrix.python-version }}-${{ github.head_ref }}.spdx.json ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }}@${DIGEST} | ||
env: | ||
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} | ||
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} | ||
DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
|
||
# To avoid the trivy-db becoming outdated, we save the cache for one day | ||
- name: Get date | ||
id: date | ||
run: echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT | ||
|
||
- name: Restore trivy cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: cache/db | ||
key: trivy-cache-${{ steps.date.outputs.date }} | ||
restore-keys: | ||
trivy-cache- | ||
|
||
- name: Scan image using Trivy | ||
uses: aquasecurity/[email protected] | ||
env: | ||
TRIVY_CACHE_DIR: ./cache | ||
with: | ||
scan-type: image | ||
image-ref: ghcr.io/fkie-cad/logprep:py${{ matrix.python-version }}-${{ github.head_ref }} | ||
trivy-config: trivy.yaml | ||
|
||
# Trivy-db uses `0600` permissions. | ||
# But `action/cache` use `runner` user by default | ||
# So we need to change the permissions before caching the database. | ||
- name: Change permissions for trivy.db | ||
run: sudo chmod 0644 ./cache/db/trivy.db |
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