Skip to content

Commit

Permalink
ci: report vulnerabilities and fail on HIGH,CRITICAL (#152)
Browse files Browse the repository at this point in the history
Add an additional Trivy execution that raises an error on HIGH and CRITICAL vulnerabilities.
It also uploads the vulnerability report to the CI run and the GitHub Security dashboard.
  • Loading branch information
cjdcordeiro authored Oct 14, 2024
1 parent 5974449 commit 3880d2b
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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'

0 comments on commit 3880d2b

Please sign in to comment.