Skip to content

Trivy Container Security Scan #41

Trivy Container Security Scan

Trivy Container Security Scan #41

Workflow file for this run

name: Trivy Container Security Scan
on:
push:
branches: ["main"]
paths:
- '**/*.go'
- 'Dockerfile'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- 'package.json'
schedule:
- cron: '42 10 * * 0'
workflow_dispatch:
jobs:
build:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
# actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Build
runs-on: "ubuntu-20.04"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build an image from Dockerfile
run: |
docker build --target prod -t check-security .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0
with:
image-ref: 'check-security'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'