Skip to content

Commit f1c270f

Browse files
authored
ci: add trivy filesystem scanning workflow (#148)
This commit provides a basic GHA to enable Trivy FS scanning on the main branch that can be invoked ad-hoc or through a `cron` schedule. It scans from the root of repo and reports on `CRITICAL` or `HIGH` vulnerabilities that have fixes available. It will also scan for secrets. It will always exit with status code 0 and upload its results to the GitHub Security tab. The workflow is configured to fire every Sunday at 6:00 AM UTC and also supports manually invoking it. I personally did not see any reason to run this on pull_requests and/or pushes to `main` branches as vulnerabilities could be disclosed / fixes made available **at any time**. Therefore, having it set on a weekly schedule as well as supported ad-hoc runs seems a reasonable way to manage. Addtionally, the build has an `if:` conditional to prevent the `schedule` runs from running on forks in an attempt to be a good/responsible github citizen. Signed-off-by: Andy Stoneberg <[email protected]>
1 parent 89271a2 commit f1c270f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Trivy Filesystem Code Scanning
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * 0' # Every Sunday at 6:00 AM UTC
6+
workflow_dispatch:
7+
8+
9+
permissions:
10+
actions: read
11+
security-events: write
12+
13+
jobs:
14+
build:
15+
if: github.event_name == 'workflow_dispatch' || ( github.event_name == 'schedule' && github.repository == 'kubeflow/dashboard' )
16+
name: Trivy Filesystem Code Scan
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Run Trivy vulnerability scanner in fs mode
23+
uses: aquasecurity/[email protected]
24+
with:
25+
scan-type: 'fs'
26+
format: 'sarif'
27+
severity: 'CRITICAL,HIGH,MEDIUM'
28+
ignore-unfixed: true
29+
output: 'trivy-fs-scan-results.sarif'
30+
31+
- name: Upload Trivy scan results to GitHub Security tab
32+
uses: github/codeql-action/upload-sarif@v3
33+
with:
34+
sarif_file: 'trivy-fs-scan-results.sarif'

0 commit comments

Comments
 (0)