ci(security): schedule published image scans

This commit is contained in:
Daniel Radl 2026-08-20 18:21:39 +02:00
parent f932bc52e4
commit af3065c5a7
1 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,104 @@
name: Security / Scan Published Images
permissions:
contents: read
security-events: write
on:
schedule:
# Every Monday at 03:17 UTC
- cron: "17 3 * * 1"
workflow_dispatch:
jobs:
scan:
name: Version ${{ matrix.version }} / ${{ matrix.arch }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
version: ["15", "16"]
arch: [amd64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Resolve published image versions
run: python3 ./.github/scripts/get_latest_tags.py --repo erpnext --version ${{ matrix.version }}
- name: Pull published images
run: |
docker pull --platform linux/${{ matrix.arch }} frappe/base:${FRAPPE_VERSION}
docker pull --platform linux/${{ matrix.arch }} frappe/build:${ERPNEXT_VERSION}
docker pull --platform linux/${{ matrix.arch }} frappe/erpnext:${ERPNEXT_VERSION}
- name: Create Trivy report directory
run: mkdir -p trivy-results
- name: Scan base image
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: frappe/base:${{ env.FRAPPE_VERSION }}
scanners: vuln
format: sarif
output: trivy-results/base.sarif
severity: HIGH,CRITICAL
ignore-unfixed: true
limit-severities-for-sarif: true
exit-code: 0
- name: Scan build image
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: frappe/build:${{ env.ERPNEXT_VERSION }}
scanners: vuln
format: sarif
output: trivy-results/build.sarif
severity: HIGH,CRITICAL
ignore-unfixed: true
limit-severities-for-sarif: true
exit-code: 0
skip-setup-trivy: true
- name: Scan ERPNext image
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: frappe/erpnext:${{ env.ERPNEXT_VERSION }}
scanners: vuln
format: sarif
output: trivy-results/erpnext.sarif
severity: HIGH,CRITICAL
ignore-unfixed: true
limit-severities-for-sarif: true
exit-code: 0
skip-setup-trivy: true
- name: Add Trivy result counts to summary
if: ${{ always() && hashFiles('trivy-results/*.sarif') != '' }}
shell: bash
run: |
echo "## Trivy image findings" >> "$GITHUB_STEP_SUMMARY"
echo >> "$GITHUB_STEP_SUMMARY"
for report in trivy-results/*.sarif; do
image="$(basename "$report" .sarif)"
findings="$(jq '[.runs[]?.results[]?] | length' "$report")"
echo "- **${image}:** ${findings} finding(s)" >> "$GITHUB_STEP_SUMMARY"
done
- name: Upload Trivy report artifact
if: ${{ always() && hashFiles('trivy-results/*.sarif') != '' }}
uses: actions/upload-artifact@v4
with:
name: trivy-${{ matrix.version }}-${{ matrix.arch }}
path: trivy-results/*.sarif
retention-days: 30
- name: Upload Trivy results to code scanning
if: ${{ always() && hashFiles('trivy-results/*.sarif') != '' }}
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: trivy-results
category: trivy-${{ matrix.version }}-${{ matrix.arch }}