Skip to content

Commit e0984a7

Browse files
authored
Migrate all scans to reusable workflow using Grype (#5251)
- centralize all scan jobs to use the reusable workflow - essentially removes trivy and switches everything to grype - for the reusable workflow: add `only-fixed:` input with default value of true
1 parent 4176e1d commit e0984a7

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

.github/workflows/alpha.yaml

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,13 @@ jobs:
133133
path: .image.env
134134
- name: Scan rqlite for vulnerabilities
135135
id: scan
136-
uses: aquasecurity/trivy-action@master
136+
uses: ./.github/workflows/scan-image-grype.yml
137137
with:
138-
image-ref: "docker.io/kotsadm/rqlite:${{ steps.dotenv.outputs.RQLITE_TAG }}"
139-
format: 'template'
140-
template: '@/contrib/sarif.tpl'
141-
output: 'rqlite-scan-output.sarif'
142-
exit-code: '0'
143-
ignore-unfixed: true
144-
severity: 'CRITICAL,HIGH,MEDIUM'
138+
image: "docker.io/kotsadm/rqlite:${{ steps.dotenv.outputs.RQLITE_TAG }}"
139+
severity-cutoff: 'medium'
140+
fail-build: false
141+
output-file: 'rqlite-scan-output.sarif'
142+
only-fixed: true
145143
- name: Print scan report
146144
run: cat rqlite-scan-output.sarif
147145
- name: Upload scan report
@@ -162,15 +160,13 @@ jobs:
162160
path: .image.env
163161
- name: Scan minio for vulnerabilities
164162
id: scan
165-
uses: aquasecurity/trivy-action@master
163+
uses: ./.github/workflows/scan-image-grype.yml
166164
with:
167-
image-ref: "docker.io/kotsadm/minio:${{ steps.dotenv.outputs.MINIO_TAG }}"
168-
format: 'template'
169-
template: '@/contrib/sarif.tpl'
170-
output: 'minio-scan-output.sarif'
171-
exit-code: '0'
172-
ignore-unfixed: true
173-
severity: 'CRITICAL,HIGH,MEDIUM'
165+
image: "docker.io/kotsadm/minio:${{ steps.dotenv.outputs.MINIO_TAG }}"
166+
severity-cutoff: 'medium'
167+
fail-build: false
168+
output-file: 'minio-scan-output.sarif'
169+
only-fixed: true
174170
- name: Print scan report
175171
run: cat minio-scan-output.sarif
176172
- name: Upload scan report
@@ -191,15 +187,13 @@ jobs:
191187
path: .image.env
192188
- name: Scan dex for vulnerabilities
193189
id: scan
194-
uses: aquasecurity/trivy-action@master
190+
uses: ./.github/workflows/scan-image-grype.yml
195191
with:
196-
image-ref: "docker.io/kotsadm/dex:${{ steps.dotenv.outputs.DEX_TAG }}"
197-
format: 'template'
198-
template: '@/contrib/sarif.tpl'
199-
output: 'dex-scan-output.sarif'
200-
exit-code: '0'
201-
ignore-unfixed: true
202-
severity: 'CRITICAL,HIGH,MEDIUM'
192+
image: "docker.io/kotsadm/dex:${{ steps.dotenv.outputs.DEX_TAG }}"
193+
severity-cutoff: 'medium'
194+
fail-build: false
195+
output-file: 'dex-scan-output.sarif'
196+
only-fixed: true
203197
- name: Print scan report
204198
run: cat dex-scan-output.sarif
205199
- name: Upload scan report
@@ -216,15 +210,13 @@ jobs:
216210
uses: actions/checkout@v4
217211
- name: Scan kurl-proxy for vulnerabilities
218212
id: scan
219-
uses: aquasecurity/trivy-action@master
213+
uses: ./.github/workflows/scan-image-grype.yml
220214
with:
221-
image-ref: 'docker.io/kotsadm/kurl-proxy:alpha'
222-
format: 'template'
223-
template: '@/contrib/sarif.tpl'
224-
output: 'kurl-proxy-scan-output.sarif'
225-
exit-code: '0'
226-
ignore-unfixed: true
227-
severity: 'CRITICAL,HIGH,MEDIUM'
215+
image: 'docker.io/kotsadm/kurl-proxy:alpha'
216+
severity-cutoff: 'medium'
217+
fail-build: false
218+
output-file: 'kurl-proxy-scan-output.sarif'
219+
only-fixed: true
228220
- name: Print scan report
229221
run: cat kurl-proxy-scan-output.sarif
230222
- name: Upload scan report
@@ -245,15 +237,13 @@ jobs:
245237
path: .image.env
246238
- name: Scan replicated/local-volume-provider for vulnerabilities
247239
id: scan
248-
uses: aquasecurity/trivy-action@master
240+
uses: ./.github/workflows/scan-image-grype.yml
249241
with:
250-
image-ref: "docker.io/replicated/local-volume-provider:${{ steps.dotenv.outputs.LVP_TAG }}"
251-
format: 'template'
252-
template: '@/contrib/sarif.tpl'
253-
output: 'scan-output.sarif'
254-
exit-code: '0'
255-
ignore-unfixed: true
256-
severity: 'CRITICAL,HIGH,MEDIUM'
242+
image: "docker.io/replicated/local-volume-provider:${{ steps.dotenv.outputs.LVP_TAG }}"
243+
severity-cutoff: 'medium'
244+
fail-build: false
245+
output-file: 'scan-output.sarif'
246+
only-fixed: true
257247
- name: Print scan report
258248
run: cat scan-output.sarif
259249
- name: Upload scan report
@@ -270,15 +260,13 @@ jobs:
270260
uses: actions/checkout@v4
271261
- name: Scan kotsadm for vulnerabilities
272262
id: scan
273-
uses: aquasecurity/trivy-action@master
263+
uses: ./.github/workflows/scan-image-grype.yml
274264
with:
275-
image-ref: 'docker.io/kotsadm/kotsadm:alpha'
276-
format: 'template'
277-
template: '@/contrib/sarif.tpl'
278-
output: 'kotsadm-scan-output.sarif'
279-
exit-code: '0'
280-
ignore-unfixed: true
281-
severity: 'CRITICAL,HIGH,MEDIUM'
265+
image: 'docker.io/kotsadm/kotsadm:alpha'
266+
severity-cutoff: 'medium'
267+
fail-build: false
268+
output-file: 'kotsadm-scan-output.sarif'
269+
only-fixed: true
282270
- name: Print scan report
283271
run: cat kotsadm-scan-output.sarif
284272
- name: Upload scan report
@@ -295,15 +283,13 @@ jobs:
295283
uses: actions/checkout@v4
296284
- name: Scan migrations for vulnerabilities
297285
id: scan
298-
uses: aquasecurity/trivy-action@master
286+
uses: ./.github/workflows/scan-image-grype.yml
299287
with:
300-
image-ref: 'docker.io/kotsadm/kotsadm-migrations:alpha'
301-
format: 'template'
302-
template: '@/contrib/sarif.tpl'
303-
output: 'kotsadm-migration-scan-output.sarif'
304-
exit-code: '0'
305-
ignore-unfixed: true
306-
severity: 'CRITICAL,HIGH,MEDIUM'
288+
image: 'docker.io/kotsadm/kotsadm-migrations:alpha'
289+
severity-cutoff: 'medium'
290+
fail-build: false
291+
output-file: 'kotsadm-migration-scan-output.sarif'
292+
only-fixed: true
307293
- name: Print scan report
308294
run: cat kotsadm-migration-scan-output.sarif
309295
- name: Upload scan report

.github/workflows/scan-image-grype.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ on:
3737
type: string
3838
default: 'container-scan-'
3939
description: 'Prefix to use for the SARIF category name'
40+
only-fixed:
41+
required: false
42+
type: boolean
43+
default: true
44+
description: 'Specify whether to only report vulnerabilities that have a fix available'
4045

4146
permissions: {} # Remove all permissions by default
4247

@@ -99,6 +104,14 @@ jobs:
99104
echo "Error: category-prefix can only contain alphanumeric characters, hyphens, and underscores"
100105
exit 1
101106
fi
107+
108+
- name: Validate only-fixed
109+
run: |
110+
if [[ ! "${{ inputs.only-fixed }}" =~ ^(true|false)$ ]]; then
111+
echo "Error: Invalid only-fixed value '${{ inputs.only-fixed }}'"
112+
echo "Value must be either 'true' or 'false'"
113+
exit 1
114+
fi
102115
103116
scan:
104117
name: Scan Image Grype SARIF
@@ -137,6 +150,7 @@ jobs:
137150
output-format: sarif
138151
output-file: "${{ inputs.output-file }}"
139152
by-cve: true
153+
only-fixed: "${{ inputs.only-fixed }}"
140154

141155
- name: Check scan status
142156
if: steps.scan.outcome == 'failure'

0 commit comments

Comments
 (0)