diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 8adf838d..93d4cc18 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -1,15 +1,15 @@ name: Security on: - push: - branches: [main] - pull_request: - branches: [main] + schedule: + - cron: "0 1 * * *" jobs: scan: name: Scan for known vulnerabilities runs-on: ubuntu-latest + env: + TRIVY_RESULTS: 'trivy-results.sarif' steps: - uses: actions/checkout@v3 @@ -18,3 +18,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'