Skip to content

Trivy Image Vulnerability Scan #11

Trivy Image Vulnerability Scan

Trivy Image Vulnerability Scan #11

name: Trivy Image Vulnerability Scan
on:
push:
branches:
- main
paths:
- 'Dockerfile'
- 'go.mod'
- 'go.sum'
- 'cmd/epp/**'
- 'pkg/**'
- 'internal/**'
- 'api/**'
- 'apix/**'
- 'version/**'
- 'sidecars/**'
pull_request:
branches:
- main
paths:
- 'Dockerfile'
- 'go.mod'
- 'go.sum'
- 'cmd/epp/**'
- 'pkg/**'
- 'internal/**'
- 'api/**'
- 'apix/**'
- 'version/**'
- 'sidecars/**'
schedule:
# Run weekly on Monday at 00:00 UTC to catch new CVEs
- cron: '0 0 * * 1'
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
trivy-scan:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Harden Runner
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Build EPP image
run: |
docker build \
--build-arg COMMIT_SHA=${{ github.sha }} \
--build-arg BUILD_REF=${{ github.ref }} \
-t gwie-epp:scan \
-f Dockerfile .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: 'gwie-epp:scan'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@865f5f5c36632f18690a3d569fa0a764f2da0c3e # v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
- name: Run Trivy scanner (table output for PR comment)
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: 'gwie-epp:scan'
format: 'table'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
exit-code: '1'