Skip to content

00 trivy scan

00 trivy scan #28

name: 00 trivy scan
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
inputs:
skip-update:
description: 'Skip database-update'
required: false
type: boolean
default: true
schedule:
- cron: '6 5 * * 1'
jobs:
trivy-scan:
timeout-minutes: 15
runs-on: ubuntu-latest
permissions:
actions: read # for private repositories
contents: write
id-token: write
security-events: write # push sarif to github security
name: Security scan of ${{ github.event.repository.name }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
with:
fetch-depth: 0
repository: ${{ github.event.repository.full_name }}
ref: '${{ github.ref_name }}'
- name: Start time and timezone
run: |
echo "starttime=$(date +%s)" >> $GITHUB_ENV
sudo timedatectl set-timezone "Europe/Oslo"
- name: get versions, changelog and more
id: get-versions
uses: navikt/eresept-actions/get-versions-and-more@main
- name: Run Trivy vulnerability scanner on repository
uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # v0.24.0
env:
TRIVY_SKIP_DB_UPDATE: "${{ inputs == null || inputs.skip-update == true }}"
TRIVY_JAVA_DB_REPOSITORY: "europe-north1-docker.pkg.dev/nais-io/remote-ghcr/aquasecurity/trivy-java-db:1,public.ecr.aws/aquasecurity/trivy-java-db,ghcr.io/aquasecurity/trivy-java-db:1"
with:
scan-type: 'fs'
format: "sarif"
hide-progress: true
output: "trivy-results.sarif"
severity: 'MEDIUM,HIGH,CRITICAL'
limit-severities-for-sarif: true
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v2.19.0
with:
sarif_file: "trivy-results.sarif"
- name: Calculate execution time
run: |
END_TIME=$(date +%s)
echo "exectime=$(( $END_TIME - ${{ env.starttime }} ))" >> $GITHUB_ENV
- name: Checkout badges
uses: navikt/eresept-actions/badges-checkout@main
- name: Scan date badge
uses: navikt/eresept-actions/badges-create@main
with:
left: 'scanned'
right: '${{ steps.get-versions.outputs.current-datetime }}'
color: 'blue'
filename: 'scan-date'
logo: 'shield'
- name: Commit badges
uses: navikt/eresept-actions/badges-commit@main
- name: Summary
run: echo "### Trivy scanned latest in ${{ env.exectime }} seconds" >> $GITHUB_STEP_SUMMARY