Add sbom generation #272
Workflow file for this run
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
name: trivy | |
on: | |
push: | |
branches: | |
- 3.4-22.04/edge | |
- dpe-5350-3.4 # tmp to test new action. | |
pull_request: | |
jobs: | |
build: | |
uses: ./.github/workflows/build.yaml | |
scan: | |
name: Trivy scan and sbom generation | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install rockcraft (for skopeo) | |
run: | | |
sudo snap install rockcraft --classic --edge | |
- name: Get Artifact Name | |
id: artifact | |
run: | | |
BASE_ARTIFACT=$(make help | grep 'Artifact: ') | |
echo "base_artifact_name=${BASE_ARTIFACT#'Artifact: '}" >> $GITHUB_OUTPUT | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: charmed-spark | |
path: charmed-spark | |
- name: Import locally | |
run: | | |
# Unpack artifact | |
mv charmed-spark/${{ steps.artifact.outputs.base_artifact_name }} . | |
sudo rockcraft.skopeo --insecure-policy copy \ | |
docker-archive:${{ steps.artifact.outputs.base_artifact_name }} \ | |
docker-daemon:trivy/charmed-spark:test | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: 'trivy/charmed-spark:test' | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
severity: 'MEDIUM,HIGH,CRITICAL' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
if: always() | |
with: | |
sarif_file: 'trivy-results.sarif' | |
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph | |
uses: aquasecurity/[email protected] | |
with: | |
scan-type: 'fs' | |
format: 'github' | |
output: 'dependency-results.sbom.json' | |
image-ref: 'trivy/charmed-spark:test' | |
github-pat: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload trivy report as a Github artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: trivy-sbom-report | |
path: '${{ github.workspace }}/dependency-results.sbom.json' | |
retention-days: 90 |