Skip to content

Commit 98d3310

Browse files
committed
Add trivy action to catch CVEs
Issue: [sc-17241]
1 parent 98d3c5f commit 98d3310

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/trivy-scan.yaml

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

0 commit comments

Comments
 (0)