From 2707e580edd24ff393ca89e7e9c1695bb6d318e4 Mon Sep 17 00:00:00 2001 From: Maik Hummel <6891349+beevelop@users.noreply.github.com> Date: Fri, 4 Dec 2026 15:43:49 +0100 Subject: [PATCH] fix(ci): scan published nginx images with Trivy --- .github/workflows/docker.yml | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f7b41b2..e39a48c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,6 +25,9 @@ jobs: main: runs-on: ubuntu-24.04 timeout-minutes: 30 + outputs: + image: ${{ steps.image.outputs.name }} + digest: ${{ steps.release.outputs.digest }} steps: - name: Check out the repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -32,7 +35,11 @@ jobs: persist-credentials: false - name: Set image name - run: printf 'IMAGE=%s\n' "${GITHUB_REPOSITORY/docker-/}" >> "$GITHUB_ENV" + id: image + run: | + image="${GITHUB_REPOSITORY/docker-/}" + printf 'IMAGE=%s\n' "$image" >> "$GITHUB_ENV" + printf 'name=%s\n' "$image" >> "$GITHUB_OUTPUT" - name: Set up QEMU uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 @@ -83,11 +90,34 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - name: Report critical and high CVEs with Docker Scout - if: env.PUBLISH == 'true' - uses: docker/scout-action@b265cd48f8a1451d2680815b3e8dc4ed65ee16e7 # v1.30.0 + scan: + name: Scan published image + needs: main + if: github.event_name != 'pull_request' && needs.main.outputs.digest != '' + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + contents: read + security-events: write + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Scan the published digest + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 + with: + version: v0.77.0 + image-ref: ${{ needs.main.outputs.image }}@${{ needs.main.outputs.digest }} + scanners: vuln + severity: CRITICAL,HIGH + limit-severities-for-sarif: 'true' + exit-code: '0' + format: sarif + output: scan.sarif + + - name: Upload scan results + uses: github/codeql-action/upload-sarif@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5 with: - command: cves - image: ${{ env.IMAGE }}@${{ steps.release.outputs.digest }} - only-severities: critical,high - exit-code: false + sarif_file: scan.sarif