Skip to content

Vulnerability Scan #234

Vulnerability Scan

Vulnerability Scan #234

---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Vulnerability Scan
on:
schedule:
- cron: 30 1 * * *
workflow_dispatch:
permissions:
contents: read
jobs:
apps:
name: Get App Inventory
runs-on: ubuntu-latest
outputs:
apps: ${{ steps.inventory.outputs.apps }}
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- name: Get App Inventory
uses: ./.github/actions/app-inventory
id: inventory
grype:
name: Setup Grype
runs-on: ubuntu-latest
steps:
- name: Create Cache Key
id: cache
run: |-
echo "key=$(date -u +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Restore Database
id: database-restore
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
key: grype-db-${{ steps.cache.outputs.key }}
path: ~/.cache/grype/db
- if: ${{ always() && steps.database-restore.outputs.cache-hit != 'true' }}
name: Install Grype
uses: anchore/scan-action/download-grype@568b89d27fc18c60e56937bff480c91c772cd993 # v7.1.0
id: grype
- if: ${{ always() && steps.database-restore.outputs.cache-hit != 'true' }}
name: Update Database
run: |-
${{ steps.grype.outputs.cmd }} db update
- if: ${{ always() && steps.database-restore.outputs.cache-hit != 'true' }}
name: Cache Database
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
key: grype-db-${{ steps.cache.outputs.key }}
path: ~/.cache/grype/db
vulnerability-scan:
name: Vulnerability Scan (${{ matrix.app }})
needs:
- apps
- grype
runs-on: ubuntu-latest
strategy:
matrix:
app: ${{ fromJSON(needs.apps.outputs.apps) }}
max-parallel: 4
fail-fast: false
permissions:
security-events: write
contents: read
steps:
- name: Retreive Cache Key
id: cache
run: |-
echo "key=$(date -u +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Restore Database
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
key: grype-db-${{ steps.cache.outputs.key }}
path: ~/.cache/grype/db
- name: Scan
uses: anchore/scan-action@568b89d27fc18c60e56937bff480c91c772cd993 # v7.1.0
id: scan
with:
fail-build: false
image: ghcr.io/${{ github.repository_owner }}/${{ matrix.app }}:rolling
severity-cutoff: high
- name: Upload Report
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
with:
category: container:${{ matrix.app }}
sarif_file: ${{ steps.scan.outputs.sarif }}