Skip to content

Commit 7298dc6

Browse files
committed
Adds Trivy
Scans Go dependencies on push, pull request, and on a schedule. Issue: [sc-17407]
1 parent 467c778 commit 7298dc6

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/trivy-scan.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Uses Trivy to scan every pull request, rejecting those with severe, fixable vulnerabilities.
2+
# Scans on PR to main and weekly with same behavior.
3+
name: Trivy
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- main
9+
push:
10+
branches:
11+
- main
12+
# Scan schedule is same as codeql-analysis job.
13+
schedule:
14+
- cron: '10 18 * * 2'
15+
16+
jobs:
17+
scan:
18+
permissions:
19+
# for github/codeql-action/upload-sarif to upload SARIF results
20+
security-events: write
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
# Run trivy and log detected and fixed vulnerabilities
28+
# This report should match the uploaded code scan report below
29+
# and is a convenience/redundant effort for those who prefer to
30+
# read logs and/or if anything goes wrong with the upload.
31+
- name: Log all detected vulnerabilities
32+
uses: aquasecurity/trivy-action@master
33+
with:
34+
scan-type: fs
35+
hide-progress: true
36+
ignore-unfixed: true
37+
38+
# Upload actionable results to the GitHub Security tab.
39+
# Pull request checks fail according to repository settings.
40+
# - https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
41+
# - https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning
42+
- name: Report actionable vulnerabilities
43+
uses: aquasecurity/trivy-action@master
44+
with:
45+
scan-type: fs
46+
ignore-unfixed: true
47+
format: 'sarif'
48+
output: 'trivy-results.sarif'
49+
50+
- name: Upload Trivy scan results to GitHub Security tab
51+
uses: github/codeql-action/upload-sarif@v2
52+
with:
53+
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)