-
Notifications
You must be signed in to change notification settings - Fork 1
47 lines (40 loc) · 1.43 KB
/
repo-scan.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Vulnerability scan of the repo
on:
push:
branches: [main]
pull_request:
jobs:
repo-scan:
name: 'Trivy repo scan'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
trivy-config: "trivy-config.yaml"
env:
# env variables seems to be a more reliable way to configure trivy than inputs
TRIVY_FORMAT: table # we cannot use the GitHub-integrated sarif format without GitHub advanced security
TRIVY_OUTPUT: trivy-report.txt
TRIVY_EXIT_CODE: 1
- shell: bash
if: always()
# Print result so that one doesn't need to download zip files to see the result
run: |
cat trivy-report.txt
echo "Trivy report:" >> $GITHUB_STEP_SUMMARY
echo '~~~' >> $GITHUB_STEP_SUMMARY
cat trivy-report.txt >> $GITHUB_STEP_SUMMARY
echo '~~~' >> $GITHUB_STEP_SUMMARY
if echo "$REPORT_WITHOUT_TABLES" | grep -E '(HIGH|CRITICAL): [1-9]' > /dev/null; then
echo "::error::Found HIGH or CRITICAL vulnerabilities"
fi
- name: Upload report artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: trivy-report.txt
path: trivy-report.txt