Skip to content

Vulnerability Scan #150

Vulnerability Scan

Vulnerability Scan #150

---
# 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:
group: default
outputs:
apps: ${{ steps.inventory.outputs.apps }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Get App Inventory
uses: ./.github/actions/app-inventory
id: inventory
grype:
name: Setup Grype
runs-on:
group: default
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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
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@8d2fce09422cd6037e577f4130e9b925e9a37175 # v7.3.1
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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
key: grype-db-${{ steps.cache.outputs.key }}
path: ~/.cache/grype/db
vulnerability-scan:
name: Vulnerability Scan (${{ matrix.app }})
needs:
- apps
- grype
runs-on:
group: default
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@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
key: grype-db-${{ steps.cache.outputs.key }}
path: ~/.cache/grype/db
- name: Scan
uses: anchore/scan-action@8d2fce09422cd6037e577f4130e9b925e9a37175 # v7.3.1
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@6bc82e05fd0ea64601dd4b465378bbcf57de0314 # v4.32.1
with:
category: container:${{ matrix.app }}
sarif_file: ${{ steps.scan.outputs.sarif }}