From af3065c5a726880d380bbf6c2c93f242bf3041e1 Mon Sep 17 00:00:00 2001 From: Daniel Radl Date: Thu, 20 Aug 2026 18:21:39 +0200 Subject: [PATCH] ci(security): schedule published image scans --- .github/workflows/security-scan-images.yml | 104 +++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/security-scan-images.yml diff --git a/.github/workflows/security-scan-images.yml b/.github/workflows/security-scan-images.yml new file mode 100644 index 0000000..344dbdb --- /dev/null +++ b/.github/workflows/security-scan-images.yml @@ -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 }}