Skip to content

Commit 9422c8d

Browse files
committed
Breaks out trivy-scheduled-scans
Runs scheduled Trivy scans on the main and REL_4_7 branches. Issue: [sc-17407]
1 parent ab6e6c9 commit 9422c8d

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ on:
99
push:
1010
branches:
1111
- master
12-
# Scan schedule is same as codeql-analysis job.
13-
schedule:
14-
- cron: '10 18 * * 2'
1512

1613
jobs:
1714
scan:
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Trivy Scheduled Scans
2+
3+
on:
4+
# Scan schedule is the same as codeql-analysis job.
5+
schedule:
6+
- cron: '0 14 * * 1'
7+
8+
jobs:
9+
scan_MAIN:
10+
if: ${{ github.repository == 'CrunchyData/postgres-operator' }}
11+
12+
permissions:
13+
# for github/codeql-action/upload-sarif to upload SARIF results
14+
security-events: write
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
# Run trivy and log detected and fixed vulnerabilities
22+
# This report should match the uploaded code scan report below
23+
# and is a convenience/redundant effort for those who prefer to
24+
# read logs and/or if anything goes wrong with the upload.
25+
- name: Log all detected vulnerabilities
26+
uses: aquasecurity/trivy-action@master
27+
with:
28+
scan-type: fs
29+
hide-progress: true
30+
ignore-unfixed: true
31+
32+
# Upload actionable results to the GitHub Security tab.
33+
# Pull request checks fail according to repository settings.
34+
# - https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/uploading-a-sarif-file-to-github
35+
# - https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning
36+
- name: Report actionable vulnerabilities
37+
uses: aquasecurity/trivy-action@master
38+
with:
39+
scan-type: fs
40+
ignore-unfixed: true
41+
format: 'sarif'
42+
output: 'trivy-results.sarif'
43+
44+
- name: Upload Trivy scan results to GitHub Security tab
45+
uses: github/codeql-action/upload-sarif@v2
46+
with:
47+
sarif_file: 'trivy-results.sarif'
48+
49+
scan_REL_4_7:
50+
if: ${{ github.repository == 'CrunchyData/postgres-operator' }}
51+
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
ref: 'REL_4_7'
58+
59+
- name: Log actionable vulnerabilities
60+
uses: aquasecurity/trivy-action@master
61+
with:
62+
scan-type: fs
63+
skip-dirs: testing
64+
hide-progress: true
65+
ignore-unfixed: true
66+
output: 'trivy-results'
67+
68+
- name: Alert Slack
69+
run: |
70+
report=`cat trivy-results`
71+
report="${report:-Nothing to Report}"
72+
curl -X POST -H 'Content-type: application/json' \
73+
--data '{"text": "postgres-operator REL_4_7 CVE Alert ```'"$report"'```"}'\
74+
${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)