Skip to content

Commit

Permalink
Merge pull request #59 from udx/UAT-47
Browse files Browse the repository at this point in the history
SBOM Generation and Release Enhancements [UAT-47]
  • Loading branch information
fqjony authored Nov 4, 2024
2 parents 845b42b + 5cdbadf commit 82f300c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | \
sudo sh -s -- -b /usr/local/bin
- name: Trivy Scanning
- name: Trivy Vulnerability Scanning
run: |
export TRIVY_DISABLE_VEX_NOTICE=true
Expand Down Expand Up @@ -80,3 +80,22 @@ jobs:
echo "Failed to complete Trivy scan after $max_retries attempts."
exit 1
fi
- name: Trivy SBOM Generation
run: |
# Suppress verbose notices and informational messages
export TRIVY_DISABLE_VEX_NOTICE=true
trivy image --format spdx-json --output sbom.json udx-worker/udx-worker:latest 2>/dev/null
echo "SBOM Top Packages Summary:"
echo "| Package Name | Version |"
echo "|-------------------|-----------|"
# Use jq to extract name and versionInfo, excluding packages with null versions, and pipe to column for formatting

Check warning on line 94 in .github/workflows/build-and-test.yml

View workflow job for this annotation

GitHub Actions / Analyze YAML Files

94:106 [line-length] line too long (124 > 105 characters)
jq -r '.packages[] | select(.versionInfo != null) | "\(.name) | \(.versionInfo)"' sbom.json | sort | uniq | head -n 20 | column -t -s '|'

Check warning on line 95 in .github/workflows/build-and-test.yml

View workflow job for this annotation

GitHub Actions / Analyze YAML Files

95:106 [line-length] line too long (147 > 105 characters)
- name: Upload SBOM Artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.json
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ jobs:
tags: |
usabilitydynamics/udx-worker:${{ steps.gitversion.outputs.semVer }}
- name: Generate SBOM
run: |
export TRIVY_DISABLE_VEX_NOTICE=true
trivy image --format spdx-json --output sbom.json usabilitydynamics/udx-worker:${{ steps.gitversion.outputs.semVer }} 2>/dev/null

Check warning on line 68 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Analyze YAML Files

68:106 [line-length] line too long (139 > 105 characters)
# Save SBOM for later upload
id: generate-sbom

- name: Upload SBOM Artifact
uses: actions/upload-artifact@v4
with:
name: sbom
path: sbom.json

- name: Generate changelog
id: changelog
run: |
Expand Down Expand Up @@ -95,13 +108,19 @@ jobs:
git tag ${{ needs.test-pipeline.outputs.semVer }}
git push origin ${{ needs.test-pipeline.outputs.semVer }}
- name: Download SBOM Artifact
uses: actions/download-artifact@v4
with:
name: sbom

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.test-pipeline.outputs.semVer }}
body: ${{ needs.test-pipeline.outputs.changelog }}
draft: false
prerelease: false
files: sbom.json
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

Expand Down Expand Up @@ -145,5 +164,23 @@ jobs:
usabilitydynamics/udx-worker:${{ needs.test-pipeline.outputs.semVer }}
usabilitydynamics/udx-worker:latest
- name: Download SBOM Artifact
uses: actions/download-artifact@v4
with:
name: sbom

- name: Install Cosign
uses: sigstore/[email protected]

- name: Sign SBOM with Cosign
env:
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
run: |
cosign attest \
--key env://COSIGN_PRIVATE_KEY \
--type sbom \
--predicate sbom.json \
usabilitydynamics/udx-worker:${{ needs.test-pipeline.outputs.semVer }}
- name: Log out from Docker Hub
run: docker logout
3 changes: 2 additions & 1 deletion ci/git-version.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
mode: ContinuousDeployment
mode: Mainline

branches:
latest:
regex: ^latest$
tag: ''
increment: Minor
source-branches: []

Expand Down
4 changes: 4 additions & 0 deletions ci/pub.keys/cosign.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhwPdudrplq/mmIHX6UkTpCJyabn4
XSbcX5GnT8PXVW/3f7mUTOIYtQK/Rk39VlgivOf0Zq8+2LWmuOp5BAelRw==
-----END PUBLIC KEY-----

0 comments on commit 82f300c

Please sign in to comment.