-
Notifications
You must be signed in to change notification settings - Fork 7
191 lines (174 loc) Β· 5.58 KB
/
trivy.yml
File metadata and controls
191 lines (174 loc) Β· 5.58 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Trivy Image and Dependency Scan
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [main]
push:
branches: [main]
permissions:
contents: read
pull-requests: write
actions: read
security-events: write
jobs:
trivy:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Chainguard Container Registry
uses: docker/login-action@v4
with:
registry: cgr.dev
username: ${{ secrets.CHAINGUARD_USERNAME }}
password: ${{ secrets.CHAINGUARD_PASSWORD }}
- name: Build image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: false
load: true
tags: pyatlan-trivy:latest
- name: Trivy image scan (table)
uses: aquasecurity/trivy-action@0.34.2
with:
image-ref: pyatlan-trivy:latest
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'table'
output: 'trivy-image.txt'
severity: 'CRITICAL,HIGH'
exit-code: '0'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
- name: Show Trivy image table
if: always()
shell: bash
run: |
echo "Trivy image scan (table)";
if [ -f trivy-image.txt ]; then
cat trivy-image.txt;
else
echo "No trivy-image.txt output found.";
fi
- name: Trivy image scan (SARIF)
uses: aquasecurity/trivy-action@0.34.2
with:
image-ref: pyatlan-trivy:latest
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-image.sarif'
severity: 'CRITICAL,HIGH'
exit-code: '0'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
- name: Trivy dependency scan (uv.lock, table)
uses: aquasecurity/trivy-action@0.34.2
with:
scan-type: fs
scan-ref: uv.lock
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'table'
output: 'trivy-deps.txt'
severity: 'CRITICAL,HIGH'
exit-code: '0'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
- name: Show Trivy dependency table
if: always()
shell: bash
run: |
echo "Trivy dependency scan (table)";
if [ -f trivy-deps.txt ]; then
cat trivy-deps.txt;
else
echo "No trivy-deps.txt output found.";
fi
- name: Trivy dependency scan (uv.lock, SARIF)
uses: aquasecurity/trivy-action@0.34.2
with:
scan-type: fs
scan-ref: uv.lock
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'sarif'
output: 'trivy-deps.sarif'
severity: 'CRITICAL,HIGH'
exit-code: '0'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
- name: Upload Trivy image results
if: github.event.repository.security_and_analysis.advanced_security.status == 'enabled'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-image.sarif'
category: 'trivy-image'
- name: Upload Trivy dependency results
if: github.event.repository.security_and_analysis.advanced_security.status == 'enabled'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-deps.sarif'
category: 'trivy-deps'
- name: Publish Trivy summary
if: always()
shell: bash
run: |
{
echo "## Trivy Image Scan (pyatlan-trivy:latest)";
echo "";
if [ -f trivy-image.txt ]; then
echo '```';
cat trivy-image.txt;
echo '```';
else
echo "No image scan output found.";
fi
echo "";
echo "## Trivy Dependency Scan (uv.lock)";
echo "";
if [ -f trivy-deps.txt ]; then
echo '```';
cat trivy-deps.txt;
echo '```';
else
echo "No dependency scan output found.";
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Fail on High/Critical vulnerabilities (image)
uses: aquasecurity/trivy-action@0.34.2
with:
image-ref: pyatlan-trivy:latest
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '1'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
- name: Fail on High/Critical vulnerabilities (uv.lock)
uses: aquasecurity/trivy-action@0.34.2
with:
scan-type: fs
scan-ref: uv.lock
scanners: 'vuln'
version: 'v0.69.0'
ignore-unfixed: true
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '1'
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2