From db2ae3459599dcd5cb634da11d3d17840c464ecc Mon Sep 17 00:00:00 2001 From: Schnuecks <27301329+Schnuecks@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:27:48 +0100 Subject: [PATCH 1/2] CI: weekly scan of the published image CI only scans an image while it is built. A weekly Trivy scan of the latest release catches vulnerabilities found later, before the next pull request. --- .github/workflows/image-scan.yml | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/image-scan.yml diff --git a/.github/workflows/image-scan.yml b/.github/workflows/image-scan.yml new file mode 100644 index 0000000..728d243 --- /dev/null +++ b/.github/workflows/image-scan.yml @@ -0,0 +1,72 @@ +name: Image scan + +# Wöchentlicher Trivy-Scan des veröffentlichten Images (Tag "latest"). Die CI scannt ein Image +# nur beim Bau; eine später bekannt gewordene Lücke in einem veröffentlichten Image bliebe sonst +# bis zum nächsten Pull Request unbemerkt. Ein kritischer Fund mit verfügbarem Fix lässt den +# Lauf fehlschlagen, das löst eine Benachrichtigung aus. +# Kritische und hohe Funde erscheinen außerdem unter Security -> Code scanning und schließen +# sich dort selbst, sobald ein neues Release sie behebt. +# Ein Pull Request, der diese Datei ändert, führt den Scan einmal zur Probe aus. + +on: + schedule: + - cron: "23 5 * * 2" # dienstags, nach dem Dependabot-Lauf am Montag + workflow_dispatch: + pull_request: + paths: + - .github/workflows/image-scan.yml + +permissions: + contents: read + packages: read + security-events: write + +jobs: + scan: + runs-on: ubuntu-24.04 + steps: + - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Veröffentlichtes Image holen + id: image + run: | + ref="ghcr.io/${GITHUB_REPOSITORY,,}:latest" + docker pull "$ref" + echo "ref=$ref" >> "$GITHUB_OUTPUT" + # Kritische und hohe Funde für Security -> Code scanning (nicht bei Probeläufen in Pull + # Requests: deren Token darf keine Security-Events schreiben) + - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + if: github.event_name != 'pull_request' + with: + image-ref: ${{ steps.image.outputs.ref }} + severity: CRITICAL,HIGH + ignore-unfixed: true + format: sarif + output: trivy.sarif + exit-code: "0" + - uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + if: github.event_name != 'pull_request' + with: + sarif_file: trivy.sarif + category: image-scan + # Übersicht kritischer und hoher Funde, für die es einen Fix gibt … + - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ steps.image.outputs.ref }} + severity: CRITICAL,HIGH + ignore-unfixed: true + format: table + exit-code: "0" + skip-setup-trivy: true + # … nur kritische lassen den Lauf fehlschlagen + - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ steps.image.outputs.ref }} + severity: CRITICAL + ignore-unfixed: true + format: table + exit-code: "1" + skip-setup-trivy: true From e3892678f059835729dd58be682b76f0e3dce9a3 Mon Sep 17 00:00:00 2001 From: Schnuecks <27301329+Schnuecks@users.noreply.github.com> Date: Wed, 28 Oct 2026 13:29:59 +0100 Subject: [PATCH 2/2] Install Trivy in the first scan step, which also runs on pull requests --- .github/workflows/image-scan.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/image-scan.yml b/.github/workflows/image-scan.yml index 728d243..052cdef 100644 --- a/.github/workflows/image-scan.yml +++ b/.github/workflows/image-scan.yml @@ -36,6 +36,14 @@ jobs: ref="ghcr.io/${GITHUB_REPOSITORY,,}:latest" docker pull "$ref" echo "ref=$ref" >> "$GITHUB_OUTPUT" + # Übersicht kritischer und hoher Funde, für die es einen Fix gibt … + - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + image-ref: ${{ steps.image.outputs.ref }} + severity: CRITICAL,HIGH + ignore-unfixed: true + format: table + exit-code: "0" # Kritische und hohe Funde für Security -> Code scanning (nicht bei Probeläufen in Pull # Requests: deren Token darf keine Security-Events schreiben) - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 @@ -47,20 +55,12 @@ jobs: format: sarif output: trivy.sarif exit-code: "0" + skip-setup-trivy: true - uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 if: github.event_name != 'pull_request' with: sarif_file: trivy.sarif category: image-scan - # Übersicht kritischer und hoher Funde, für die es einen Fix gibt … - - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 - with: - image-ref: ${{ steps.image.outputs.ref }} - severity: CRITICAL,HIGH - ignore-unfixed: true - format: table - exit-code: "0" - skip-setup-trivy: true # … nur kritische lassen den Lauf fehlschlagen - uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 with: