-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add persistence to trivy plugin for caching databases (#266)
* enable trivy db persistence * set securityContext.privileged to false in trivy plugin * apply a Job for downloading vulnerability database * add flag to download java db on job * fix trivy job command * bump chart version to 0.8.4-rc4
- Loading branch information
Showing
10 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2024 Undistro Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
{{- if .Values.scan.plugins.trivy.persistence.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: trivy-download-db | ||
spec: | ||
ttlSecondsAfterFinished: 0 | ||
template: | ||
spec: | ||
volumes: | ||
- name: trivy-db | ||
persistentVolumeClaim: | ||
claimName: trivy-db | ||
containers: | ||
- name: trivy-download-db | ||
image: "{{ .Values.scan.plugins.trivy.image.repository }}:{{ .Values.scan.plugins.trivy.image.tag }}" | ||
imagePullPolicy: IfNotPresent | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
privileged: false | ||
volumeMounts: | ||
- mountPath: /tmp/trivy-cache | ||
name: trivy-db | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
time trivy image \ | ||
--debug \ | ||
--no-progress \ | ||
--cache-dir=/tmp/trivy-cache \ | ||
{{- if .Values.scan.plugins.trivy.insecure }} | ||
--insecure \ | ||
{{- end }} | ||
{{- if .Values.scan.plugins.trivy.persistence.downloadJavaDB }} | ||
--download-java-db-only \ | ||
{{- end }} | ||
--download-db-only | ||
env: | ||
- name: SSL_CERT_DIR | ||
value: "/etc/ssl/:/run/secrets/kubernetes.io/serviceaccount/" | ||
{{- if .Values.httpsProxy }} | ||
- name: HTTPS_PROXY | ||
value: {{ .Values.httpsProxy | quote }} | ||
- name: NO_PROXY | ||
value: {{ .Values.noProxy | quote }} | ||
{{- end }} | ||
restartPolicy: OnFailure | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2024 Undistro Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
{{- if .Values.scan.plugins.trivy.persistence.enabled }} | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: trivy-db | ||
spec: | ||
{{- if .Values.scan.plugins.trivy.persistence.storageClass }} | ||
storageClassName: {{ .Values.scan.plugins.trivy.persistence.storageClass | quote }} | ||
{{- end }} | ||
accessModes: | ||
- {{ .Values.scan.plugins.trivy.persistence.accessMode }} | ||
resources: | ||
requests: | ||
storage: {{ .Values.scan.plugins.trivy.persistence.storageRequest | quote }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters