Skip to content

Commit e49398f

Browse files
authored
Merge pull request #948 from secureCodeBox/dependencies/upgrading-trivy-to-0.23.0
[SCB-Bot] Upgraded trivy from 0.22.0 to 0.24.2
2 parents cd2f588 + 7b55ea3 commit e49398f

16 files changed

Lines changed: 312 additions & 93 deletions

File tree

‎scanners/trivy/.helm-docs.gotmpl‎

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,23 @@ To learn more about the Trivy scanner itself visit [Trivy's GitHub Repository](h
3737

3838
The following security scan configuration example are based on the [Trivy Documentation](https://aquasecurity.github.io/trivy/), please take a look at the original documentation for more configuration examples.
3939

40-
- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
41-
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
42-
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
43-
- Ignore unfixed vulnerabilities:`trivy image --ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
44-
45-
:::caution
46-
Due to [limitations in the trivy argument parser](https://github.com/secureCodeBox/secureCodeBox/issues/796), scanning anything other than docker images (e.g., Git repositories) requires some extra parameters.
47-
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
48-
```yaml
49-
- "--no-progress"
50-
- "--format"
51-
- "json"
52-
- "--output"
53-
- "/home/securecodebox/trivy-results.json"
54-
```
40+
### Trivy Container Image Scan
41+
42+
Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
43+
- scanType: "trivy-image"
44+
- parameters: `[YOUR_IMAGE_NAME]`
45+
- scanType: "trivy-filesystem"
46+
- parameters: `[YOUR_PATH_TO_FILES]`
47+
- scanType: "trivy-repo"
48+
- parameters: `[YOUR_GITHUB_REPO]`
49+
50+
A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).
51+
52+
Simply specify an image name (and a tag) when you use the scanType `trivy-image`. But there are also some additional configuration options e.g:
53+
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
54+
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
55+
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
56+
- Ignore unfixed vulnerabilities:`--ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
5557

5658
A complete scan definition for the secureCodeBox repository may look something like this:
5759
```yaml
@@ -60,22 +62,15 @@ kind: Scan
6062
metadata:
6163
name: "trivy-scb"
6264
spec:
63-
scanType: "trivy"
65+
scanType: "trivy-image"
6466
parameters:
65-
- "repo"
66-
- "--no-progress"
67-
- "--format"
68-
- "json"
69-
- "--output"
70-
- "/home/securecodebox/trivy-results.json"
71-
- "https://github.com/secureCodeBox/secureCodeBox"
67+
- bkimminich/juice-shop:v10.2.0
7268
```
73-
:::
7469

7570
### Scanning Many Targets
7671
By default, the docker container of trivy will download new rulesets when starting the process.
7772
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
78-
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/v0.20.2/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
73+
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/latest/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
7974
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
8075
If this fits your use case, you can deploy a rule service with the following template:
8176
```yaml
@@ -140,7 +135,7 @@ metadata:
140135
# Don't forget to update the namespace if necessary
141136
namespace: default
142137
spec:
143-
scanType: "trivy"
138+
scanType: "trivy-image"
144139
parameters:
145140
- "client"
146141
# Again, add the extra parameters here (required to make the parser work)
@@ -158,12 +153,10 @@ spec:
158153
```
159154

160155
If you want to scan anything other than docker images, you currently [cannot use the client-server mode](https://github.com/aquasecurity/trivy/issues/634) described above.
161-
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
156+
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
162157
In practice, this is a difficult problem because the most natural method for providing these files in kubernetes, ConfigMaps, has a size limit of 1 MB, while the vulnerability database is over 200 MB in size (28 MB after compression).
163158
Your best bet would thus be to serve the files from your own servers and load them into the scanner [using an initContainer](https://docs.securecodebox.io/docs/api/crds/scan#initcontainers-optional), taking care to keep the databases on your server up to date.
164-
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.
165-
166-
159+
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
167160
{{- end }}
168161

169162
{{- define "extra.chartConfigurationSection" -}}

‎scanners/trivy/Chart.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description: A Helm chart for the trivy security scanner that integrates with th
88
type: application
99
# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
1010
version: v3.1.0-alpha1
11-
appVersion: "0.22.0"
11+
appVersion: "0.24.2"
1212
kubeVersion: ">=v1.11.0-0"
1313
annotations:
1414
versionApi: https://api.github.com/repos/aquasecurity/trivy/releases/latest

‎scanners/trivy/README.md‎

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Trivy"
33
category: "scanner"
44
type: "Container"
55
state: "released"
6-
appVersion: "0.22.0"
6+
appVersion: "0.24.2"
77
usecase: "Container Vulnerability Scanner"
88
---
99

@@ -54,21 +54,23 @@ helm upgrade --install trivy secureCodeBox/trivy
5454

5555
The following security scan configuration example are based on the [Trivy Documentation](https://aquasecurity.github.io/trivy/), please take a look at the original documentation for more configuration examples.
5656

57-
- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
58-
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
59-
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
60-
- Ignore unfixed vulnerabilities:`trivy image --ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
57+
### Trivy Container Image Scan
6158

62-
:::caution
63-
Due to [limitations in the trivy argument parser](https://github.com/secureCodeBox/secureCodeBox/issues/796), scanning anything other than docker images (e.g., Git repositories) requires some extra parameters.
64-
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
65-
```yaml
66-
- "--no-progress"
67-
- "--format"
68-
- "json"
69-
- "--output"
70-
- "/home/securecodebox/trivy-results.json"
71-
```
59+
Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
60+
- scanType: "trivy-image"
61+
- parameters: `[YOUR_IMAGE_NAME]`
62+
- scanType: "trivy-filesystem"
63+
- parameters: `[YOUR_PATH_TO_FILES]`
64+
- scanType: "trivy-repo"
65+
- parameters: `[YOUR_GITHUB_REPO]`
66+
67+
A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).
68+
69+
Simply specify an image name (and a tag) when you use the scanType `trivy-image`. But there are also some additional configuration options e.g:
70+
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
71+
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
72+
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
73+
- Ignore unfixed vulnerabilities:`--ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
7274

7375
A complete scan definition for the secureCodeBox repository may look something like this:
7476
```yaml
@@ -77,22 +79,15 @@ kind: Scan
7779
metadata:
7880
name: "trivy-scb"
7981
spec:
80-
scanType: "trivy"
82+
scanType: "trivy-image"
8183
parameters:
82-
- "repo"
83-
- "--no-progress"
84-
- "--format"
85-
- "json"
86-
- "--output"
87-
- "/home/securecodebox/trivy-results.json"
88-
- "https://github.com/secureCodeBox/secureCodeBox"
84+
- bkimminich/juice-shop:v10.2.0
8985
```
90-
:::
9186
9287
### Scanning Many Targets
9388
By default, the docker container of trivy will download new rulesets when starting the process.
9489
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
95-
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/v0.20.2/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
90+
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/latest/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
9691
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
9792
If this fits your use case, you can deploy a rule service with the following template:
9893
```yaml
@@ -157,7 +152,7 @@ metadata:
157152
# Don't forget to update the namespace if necessary
158153
namespace: default
159154
spec:
160-
scanType: "trivy"
155+
scanType: "trivy-image"
161156
parameters:
162157
- "client"
163158
# Again, add the extra parameters here (required to make the parser work)
@@ -175,10 +170,10 @@ spec:
175170
```
176171
177172
If you want to scan anything other than docker images, you currently [cannot use the client-server mode](https://github.com/aquasecurity/trivy/issues/634) described above.
178-
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
173+
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
179174
In practice, this is a difficult problem because the most natural method for providing these files in kubernetes, ConfigMaps, has a size limit of 1 MB, while the vulnerability database is over 200 MB in size (28 MB after compression).
180175
Your best bet would thus be to serve the files from your own servers and load them into the scanner [using an initContainer](https://docs.securecodebox.io/docs/api/crds/scan#initcontainers-optional), taking care to keep the databases on your server up to date.
181-
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.
176+
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
182177
183178
## Requirements
184179

‎scanners/trivy/docs/README.ArtifactHub.md‎

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,23 @@ helm upgrade --install trivy secureCodeBox/trivy
6161

6262
The following security scan configuration example are based on the [Trivy Documentation](https://aquasecurity.github.io/trivy/), please take a look at the original documentation for more configuration examples.
6363

64-
- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
65-
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
66-
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
67-
- Ignore unfixed vulnerabilities:`trivy image --ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
68-
69-
:::caution
70-
Due to [limitations in the trivy argument parser](https://github.com/secureCodeBox/secureCodeBox/issues/796), scanning anything other than docker images (e.g., Git repositories) requires some extra parameters.
71-
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
72-
```yaml
73-
- "--no-progress"
74-
- "--format"
75-
- "json"
76-
- "--output"
77-
- "/home/securecodebox/trivy-results.json"
78-
```
64+
### Trivy Container Image Scan
65+
66+
Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
67+
- scanType: "trivy-image"
68+
- parameters: `[YOUR_IMAGE_NAME]`
69+
- scanType: "trivy-filesystem"
70+
- parameters: `[YOUR_PATH_TO_FILES]`
71+
- scanType: "trivy-repo"
72+
- parameters: `[YOUR_GITHUB_REPO]`
73+
74+
A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).
75+
76+
Simply specify an image name (and a tag) when you use the scanType `trivy-image`. But there are also some additional configuration options e.g:
77+
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
78+
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
79+
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
80+
- Ignore unfixed vulnerabilities:`--ignore-unfixed ruby:2.4.0` By default, Trivy also detects unpatched/unfixed vulnerabilities. This means you can't fix these vulnerabilities even if you update all packages. If you would like to ignore them, use the `--ignore-unfixed` option.
7981

8082
A complete scan definition for the secureCodeBox repository may look something like this:
8183
```yaml
@@ -84,22 +86,15 @@ kind: Scan
8486
metadata:
8587
name: "trivy-scb"
8688
spec:
87-
scanType: "trivy"
89+
scanType: "trivy-image"
8890
parameters:
89-
- "repo"
90-
- "--no-progress"
91-
- "--format"
92-
- "json"
93-
- "--output"
94-
- "/home/securecodebox/trivy-results.json"
95-
- "https://github.com/secureCodeBox/secureCodeBox"
91+
- bkimminich/juice-shop:v10.2.0
9692
```
97-
:::
9893
9994
### Scanning Many Targets
10095
By default, the docker container of trivy will download new rulesets when starting the process.
10196
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
102-
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/v0.20.2/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
97+
Trivy [supports a client-server mode](https://aquasecurity.github.io/trivy/latest/advanced/modes/client-server/) where one process downloads a copy of the rule database and provides it to the others.
10398
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
10499
If this fits your use case, you can deploy a rule service with the following template:
105100
```yaml
@@ -164,7 +159,7 @@ metadata:
164159
# Don't forget to update the namespace if necessary
165160
namespace: default
166161
spec:
167-
scanType: "trivy"
162+
scanType: "trivy-image"
168163
parameters:
169164
- "client"
170165
# Again, add the extra parameters here (required to make the parser work)
@@ -182,10 +177,10 @@ spec:
182177
```
183178
184179
If you want to scan anything other than docker images, you currently [cannot use the client-server mode](https://github.com/aquasecurity/trivy/issues/634) described above.
185-
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
180+
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
186181
In practice, this is a difficult problem because the most natural method for providing these files in kubernetes, ConfigMaps, has a size limit of 1 MB, while the vulnerability database is over 200 MB in size (28 MB after compression).
187182
Your best bet would thus be to serve the files from your own servers and load them into the scanner [using an initContainer](https://docs.securecodebox.io/docs/api/crds/scan#initcontainers-optional), taking care to keep the databases on your server up to date.
188-
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.
183+
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
189184
190185
## Requirements
191186
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
SPDX-FileCopyrightText: the secureCodeBox authors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
This example shows how to use the `trivy filesystem` scan with the secureCodeBox. You can use a `ìnitContainer` and also `volumeMounts` to point to the filesystem you want to scan.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-FileCopyrightText: the secureCodeBox authors
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
apiVersion: "execution.securecodebox.io/v1"
6+
kind: Scan
7+
metadata:
8+
name: "trivy-filesystem"
9+
spec:
10+
scanType: "trivy-filesystem"
11+
# Define a volume and mount it at /repo in the scan container to have a filesystem in place
12+
volumes:
13+
- name: repo
14+
emptyDir: {}
15+
volumeMounts:
16+
- name: repo
17+
mountPath: "/repo/"
18+
# Define an init container to run the git clone for us
19+
initContainers:
20+
- name: "git-clone"
21+
image: bitnami/git
22+
# Specify that the "repo" volume should also be mounted on the
23+
# initContainer
24+
volumeMounts:
25+
- name: repo
26+
mountPath: "/repo/"
27+
# Clone to /repo in the init container
28+
command:
29+
- git
30+
- clone
31+
# Add access token to the URL for authenticated HTTPS clone
32+
- "https://github.com/yourOrg/yourRepo"
33+
- /repo/
34+
parameters:
35+
- "/repo"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
SPDX-FileCopyrightText: the secureCodeBox authors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
This example shows how to use the `trivy image` scan with the secureCodeBox.
File renamed without changes.

scanners/trivy/examples/juice-shop/scan.yaml renamed to scanners/trivy/examples/image-juice-shop/scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ metadata:
99
labels:
1010
organization: "OWASP"
1111
spec:
12-
scanType: "trivy"
12+
scanType: "trivy-image"
1313
parameters:
1414
- "bkimminich/juice-shop:v10.2.0"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
SPDX-FileCopyrightText: the secureCodeBox authors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
This example shows how to use the `trivy image` scan with the secureCodeBox.

0 commit comments

Comments
 (0)