From 2dfa6a16d674fa653b45f5c9ba50926cd8cc9cb5 Mon Sep 17 00:00:00 2001 From: Rune Johansen Date: Mon, 16 Dec 2024 16:54:12 +0100 Subject: [PATCH] Move Trivy image scan to a scheduled workflow (#267) --- .github/workflows/msbuild.yml | 12 +-------- .github/workflows/trivy.yml | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/trivy.yml diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 6fe8149c..0e50e7c3 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -55,14 +55,4 @@ jobs: context: . load: true tags: pxwebapi:${{ github.sha }} - - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@0.29.0 - with: - scan-type: image - image-ref: pxwebapi:${{ github.sha }} - format: sarif - output: trivy-results.sarif - - name: Upload Trivy scan results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: trivy-results.sarif + diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml new file mode 100644 index 00000000..180855c2 --- /dev/null +++ b/.github/workflows/trivy.yml @@ -0,0 +1,48 @@ +name: Trivy Image Scan +on: + push: + branches: ["main"] + workflow_dispatch: + schedule: + - cron: "5 11 * * 0" + +permissions: + contents: read + +jobs: + docker: + permissions: + contents: read + security-events: write + actions: read + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + load: true + tags: pxwebapi:${{ github.sha }} + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@0.29.0 + with: + scan-type: image + image-ref: pxwebapi:${{ github.sha }} + format: sarif + output: trivy-results.sarif + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: trivy-results.sarif