SBOM/SCA Trivy #3
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
## Scan a docker image -> get a SARIF/SBOM report | |
name: SBOM/SCA Trivy | |
on: | |
workflow_dispatch: | |
inputs: | |
docker_image: | |
description: 'The Docker image to scan' | |
required: true | |
default: 'appsecco/dvna:sqlite' | |
# env: | |
# REGISTRY: ghcr.io | |
# IMAGE_NAME: ${{ github.repository }} | |
# SHA: ${{ github.event.pull_request.head.sha || github.event.after }} | |
jobs: | |
trivy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
security-events: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
## Optional: login if your image is private | |
# - name: Login to Dockerhub | |
# uses: docker/login-action@v3 | |
# with: | |
# username: ${{ secrets.DOCKERHUB_USERNAME }} | |
# password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# - name: Login to GHCR | |
# uses: docker/login-action@v3 | |
# with: | |
# registry: ${{ env.REGISTRY }} | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
# Pull the github input image or use the default | |
- name: Pull the image | |
run: docker pull ${{ github.event.inputs.docker_image }} | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: ${{ github.event.inputs.docker_image }} | |
format: 'json' | |
output: sca_trivy.json | |
#exit-code: '1' | |
#ignore-unfixed: true | |
# severity: 'CRITICAL,HIGH' | |
scanners: 'vuln' | |
- name: Run Trivy SBOM scanner | |
uses: aquasecurity/[email protected] | |
with: | |
image-ref: ${{ github.event.inputs.docker_image }} | |
format: 'spdx-json' | |
output: sca_trivy.spdx.json | |
- name: Upload SARIF file as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sca_trivy.json | |
path: sca_trivy.json | |
- name: Upload SARIF file as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sca_trivy.spdx.json | |
path: sca_trivy.spdx.json | |
# Only available on Github Enterprise or public repositories | |
# - name: Upload SARIF file | |
# uses: github/codeql-action/upload-sarif@v3 | |
# with: | |
# sarif_file: sca_trivy.sarif | |
# category: Security/SCA | |
- name: SBOM upload | |
uses: advanced-security/[email protected] |