Skip to content

trivy-scan

trivy-scan #602

Workflow file for this run

name: "trivy-scan"
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
trivy-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
# contexts: [ 'roadside-forms-frontend/frontend_web_app', 'python/prohibition_web_svc','python/form_handler' ]
include:
- contexts: roadside-forms-frontend/frontend_web_app
image_names: rsbc-roadside-forms-frontend
sarif_file: trivy-frontend.sarif
docker_file: roadside-forms-frontend/frontend_web_app/Dockerfile
- contexts: python
image_names: rsbc-roadside-forms-backend-api
sarif_file: trivy-backend.sarif
docker_file: python/prohibition_web_svc/Dockerfile
- contexts: python
image_names: rsbc-roadside-forms-form-handler
sarif_file: trivy-form-handler.sarif
docker_file: python/form_handler/Dockerfile
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build
uses: docker/build-push-action@v3
with:
context: ${{matrix.contexts}}
file: ${{matrix.docker_file}}
push: false
load: true
tags: ${{matrix.image_names}}:latest
- name: Run Trivy vulnerability scanner- Alert for Critical
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
if: always()
with:
scan-type: image
image-ref: ${{matrix.image_names}}:latest
format: 'table'
exit-code: '1'
ignore-unfixed: true
severity: CRITICAL
- name: Run Trivy vulnerability scanner- save to sarif file
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
if: always()
with:
scan-type: image
image-ref: ${{matrix.image_names}}:latest
format: 'sarif'
ignore-unfixed: true
template: "@/contrib/sarif.tpl"
output: ${{matrix.sarif_file}}
severity: CRITICAL,HIGH,MEDIUM,LOW
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: ${{matrix.sarif_file}}