|
| 1 | +name: Trivy Scan |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + trivy-scan: |
| 10 | + runs-on: ubuntu-22.04 |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + - name: Run Trivy vulnerability scanner (table output) |
| 14 | + uses: aquasecurity/[email protected] |
| 15 | + with: |
| 16 | + # scan the filesystem, rather than building a Docker image prior - the |
| 17 | + # downside is we won't catch dependencies that are only installed in the |
| 18 | + # image, but the upside is we'll only catch vulnerabilities that are |
| 19 | + # explicitly in the our dependencies |
| 20 | + scan-type: 'fs' |
| 21 | + scanners: 'vuln' |
| 22 | + format: 'table' |
| 23 | + exit-code: 1 |
| 24 | + ignore-unfixed: true |
| 25 | + vuln-type: 'os,library' |
| 26 | + severity: 'CRITICAL,HIGH' |
| 27 | + trivyignores: .trivyignore |
| 28 | + - name: Run Trivy vulnerability scanner (SARIF) |
| 29 | + uses: aquasecurity/[email protected] |
| 30 | + with: |
| 31 | + scan-type: 'fs' |
| 32 | + scanners: 'vuln' |
| 33 | + # Note: The SARIF format ignores severity and uploads all vulns for |
| 34 | + # later triage. The table-format step above is used to fail the build |
| 35 | + # if there are any critical or high vulnerabilities. |
| 36 | + # See https://github.com/aquasecurity/trivy-action/issues/95 |
| 37 | + format: 'sarif' |
| 38 | + output: 'trivy-results.sarif' |
| 39 | + ignore-unfixed: true |
| 40 | + vuln-type: 'os,library' |
| 41 | + trivyignores: .trivyignore |
| 42 | + if: always() && github.repository == 'grafana/grafana' |
| 43 | + - name: Upload Trivy scan results to GitHub Security tab |
| 44 | + uses: github/codeql-action/upload-sarif@v3 |
| 45 | + with: |
| 46 | + sarif_file: 'trivy-results.sarif' |
| 47 | + if: always() && github.repository == 'grafana/grafana' |
0 commit comments