From 0578a7a2c040a2d5becf3f55ab6c6672f68b66b9 Mon Sep 17 00:00:00 2001 From: Cristovao Cordeiro Date: Wed, 7 Aug 2024 13:32:08 +0200 Subject: [PATCH] ci: report vulnerabilities and fail on HIGH,CRITICAL --- .github/workflows/security.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 8adf838d..964179cc 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -10,6 +10,8 @@ jobs: scan: name: Scan for known vulnerabilities runs-on: ubuntu-latest + env: + TRIVY_RESULTS: 'trivy-results.sarif' steps: - uses: actions/checkout@v3 @@ -18,3 +20,23 @@ jobs: with: scan-type: 'fs' scan-ref: '.' + format: 'sarif' + output: ${{ env.TRIVY_RESULTS }} + + - name: Upload Trivy scan results to GitHub Security tab + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: ${{ env.TRIVY_RESULTS }} + + - uses: actions/upload-artifact@v4 + with: + name: ${{ env.TRIVY_RESULTS }} + path: ${{ env.TRIVY_RESULTS }} + + - name: Raise error on HIGH,CRITICAL vulnerabilities + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + scan-ref: '.' + severity: 'CRITICAL,HIGH' + exit-code: '1'