Skip to content

Scheduled CVE vulnerability scan of published images. #43

Scheduled CVE vulnerability scan of published images.

Scheduled CVE vulnerability scan of published images. #43

name: vulnerability-scan
run-name: Scheduled CVE vulnerability scan of published images.
env:
REGISTRY: ghcr.io
on:
workflow_dispatch:
inputs:
summary:
description: 'Summary of the scheduled scan.'
required: false
default: 'Trivy CVE scan of published images.'
tag:
description: 'Tag to scan.'
required: false
default: '6.x'
jobs:
setup-matrix:
runs-on: ubuntu-latest
steps:
- name: Set summary
run: echo "${{ github.event.inputs.summary }}" >> $GITHUB_STEP_SUMMARY
- if: github.event.inputs.tag == '5.x'
uses: druzsan/setup-matrix@v2
with:
matrix: |
images: ${{ vars.IMAGES }}
exclude:
- images: mailpit
- if: github.event.inputs.tag != '5.x'
uses: druzsan/setup-matrix@v2
with:
matrix: |
images: ${{ vars.IMAGES }}
- id: setup-matrix
run: echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
set-sha-ref:
runs-on: ubuntu-latest
steps:
- name: checkout
id: checkout
uses: actions/checkout@main
with:
ref: ${{ github.event.inputs.tag }}
outputs:
ref: ${{ steps.checkout.outputs.ref }}
commit: ${{ steps.checkout.outputs.commit }}
vulnerability-scan:
runs-on: ubuntu-latest
needs: [setup-matrix, set-sha-ref]
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
steps:
- name: Scan for vulnerabilities
id: scan
uses: crazy-max/ghaction-container-scan@v3
with:
image: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.images }}:${{ github.event.inputs.tag }}
dockerfile: ./images/${{ matrix.images }}
- name: Upload SARIF file
if: ${{ steps.scan.outputs.sarif != '' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
ref: refs/heads/${{ needs.set-sha-ref.outputs.ref }}
sha: ${{ needs.set-sha-ref.outputs.commit }}