Skip to content

Commit a087d67

Browse files
authored
Change trivy to multiple scanTypes
Signed-off-by: Jannik Hollenbach <jannik.hollenbach@iteratec.com>
1 parent 95039d6 commit a087d67

4 files changed

Lines changed: 56 additions & 7 deletions

File tree

‎scanners/trivy/examples/juice-shop/scan.yaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ metadata:
99
labels:
1010
organization: "OWASP"
1111
spec:
12-
scanType: "trivy"
12+
scanType: "trivy-image"
1313
parameters:
14-
- "image"
1514
- "bkimminich/juice-shop:v10.2.0"

‎scanners/trivy/examples/mediawiki/scan.yaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ kind: Scan
77
metadata:
88
name: "trivy-mediawiki"
99
spec:
10-
scanType: "trivy"
10+
scanType: "trivy-image"
1111
parameters:
12-
- "image"
1312
- "mediawiki:stable"

‎scanners/trivy/integration-tests/trivy.test.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ test(
1111
async () => {
1212
const { categories, severities, count } = await scan(
1313
"trivy-juice-shop",
14-
"trivy",
15-
"image",
14+
"trivy-image",
1615
["bkimminich/juice-shop:v10.2.0"],
1716
90
1817
);

‎scanners/trivy/templates/trivy-scan-type.yaml‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
apiVersion: "execution.securecodebox.io/v1"
66
kind: ScanType
77
metadata:
8-
name: "trivy{{ .Values.scanner.nameAppend | default ""}}"
8+
name: "trivy-image{{ .Values.scanner.nameAppend | default ""}}"
99
spec:
1010
extractResults:
1111
type: trivy-json
@@ -32,6 +32,58 @@ spec:
3232
imagePullPolicy: {{ .Values.scanner.image.pullPolicy }}
3333
command:
3434
- "trivy"
35+
- "image"
36+
# Suppress progress bar, as it pollutes non interactive terminal logs
37+
- "--no-progress"
38+
- "--format"
39+
- "json"
40+
- "--output"
41+
- "/home/securecodebox/trivy-results.json"
42+
resources:
43+
{{- toYaml .Values.scanner.resources | nindent 16 }}
44+
securityContext:
45+
{{- toYaml .Values.scanner.securityContext | nindent 16 }}
46+
env:
47+
{{- toYaml .Values.scanner.env | nindent 16 }}
48+
volumeMounts:
49+
{{- toYaml .Values.scanner.extraVolumeMounts | nindent 16 }}
50+
{{- if .Values.scanner.extraContainers }}
51+
{{- toYaml .Values.scanner.extraContainers | nindent 12 }}
52+
{{- end }}
53+
volumes:
54+
{{- toYaml .Values.scanner.extraVolumes | nindent 12 }}
55+
---
56+
apiVersion: "execution.securecodebox.io/v1"
57+
kind: ScanType
58+
metadata:
59+
name: "trivy-filesystem{{ .Values.scanner.nameAppend | default ""}}"
60+
spec:
61+
extractResults:
62+
type: trivy-json
63+
location: "/home/securecodebox/trivy-results.json"
64+
jobTemplate:
65+
spec:
66+
{{- if .Values.scanner.ttlSecondsAfterFinished }}
67+
ttlSecondsAfterFinished: {{ .Values.scanner.ttlSecondsAfterFinished }}
68+
{{- end }}
69+
backoffLimit: {{ .Values.scanner.backoffLimit }}
70+
{{- if .Values.scanner.activeDeadlineSeconds }}
71+
activeDeadlineSeconds: {{ .Values.scanner.activeDeadlineSeconds }}
72+
{{- end }}
73+
template:
74+
spec:
75+
restartPolicy: OnFailure
76+
affinity:
77+
{{- toYaml .Values.scanner.affinity | nindent 12 }}
78+
tolerations:
79+
{{- toYaml .Values.scanner.tolerations | nindent 12 }}
80+
containers:
81+
- name: trivy
82+
image: "{{ .Values.scanner.image.repository }}:{{ .Values.scanner.image.tag | default .Chart.AppVersion }}"
83+
imagePullPolicy: {{ .Values.scanner.image.pullPolicy }}
84+
command:
85+
- "trivy"
86+
- "filesystem"
3587
# Suppress progress bar, as it pollutes non interactive terminal logs
3688
- "--no-progress"
3789
- "--format"

0 commit comments

Comments
 (0)