Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 23 additions & 30 deletions scanners/trivy/.helm-docs.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,23 @@ To learn more about the Trivy scanner itself visit [Trivy's GitHub Repository](h

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.

- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
- 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.

:::caution
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.
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
```yaml
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
```
### Trivy Container Image Scan

Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
- scanType: "trivy-image"
- parameters: `[YOUR_IMAGE_NAME]`
- scanType: "trivy-filesystem"
- parameters: `[YOUR_PATH_TO_FILES]`
- scanType: "trivy-repo"
- parameters: `[YOUR_GITHUB_REPO]`

A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).

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:
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
- 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.

A complete scan definition for the secureCodeBox repository may look something like this:
```yaml
Expand All @@ -60,22 +62,15 @@ kind: Scan
metadata:
name: "trivy-scb"
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "repo"
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
- "https://github.com/secureCodeBox/secureCodeBox"
- bkimminich/juice-shop:v10.2.0
```
:::

### Scanning Many Targets
By default, the docker container of trivy will download new rulesets when starting the process.
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
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.
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.
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
If this fits your use case, you can deploy a rule service with the following template:
```yaml
Expand Down Expand Up @@ -140,7 +135,7 @@ metadata:
# Don't forget to update the namespace if necessary
namespace: default
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "client"
# Again, add the extra parameters here (required to make the parser work)
Expand All @@ -158,12 +153,10 @@ spec:
```

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.
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
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).
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.
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.


Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
{{- end }}

{{- define "extra.chartConfigurationSection" -}}
Expand Down
2 changes: 1 addition & 1 deletion scanners/trivy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: A Helm chart for the trivy security scanner that integrates with th
type: application
# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
version: v3.1.0-alpha1
appVersion: "0.22.0"
appVersion: "0.24.2"
kubeVersion: ">=v1.11.0-0"
annotations:
versionApi: https://api.github.com/repos/aquasecurity/trivy/releases/latest
Expand Down
51 changes: 23 additions & 28 deletions scanners/trivy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Trivy"
category: "scanner"
type: "Container"
state: "released"
appVersion: "0.22.0"
appVersion: "0.24.2"
usecase: "Container Vulnerability Scanner"
---

Expand Down Expand Up @@ -54,21 +54,23 @@ helm upgrade --install trivy secureCodeBox/trivy

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.

- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
- 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.
### Trivy Container Image Scan

:::caution
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.
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
```yaml
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
```
Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
- scanType: "trivy-image"
- parameters: `[YOUR_IMAGE_NAME]`
- scanType: "trivy-filesystem"
- parameters: `[YOUR_PATH_TO_FILES]`
- scanType: "trivy-repo"
- parameters: `[YOUR_GITHUB_REPO]`

A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).

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:
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
- 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.

A complete scan definition for the secureCodeBox repository may look something like this:
```yaml
Expand All @@ -77,22 +79,15 @@ kind: Scan
metadata:
name: "trivy-scb"
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "repo"
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
- "https://github.com/secureCodeBox/secureCodeBox"
- bkimminich/juice-shop:v10.2.0
```
:::
### Scanning Many Targets
By default, the docker container of trivy will download new rulesets when starting the process.
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
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.
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.
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
If this fits your use case, you can deploy a rule service with the following template:
```yaml
Expand Down Expand Up @@ -157,7 +152,7 @@ metadata:
# Don't forget to update the namespace if necessary
namespace: default
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "client"
# Again, add the extra parameters here (required to make the parser work)
Expand All @@ -175,10 +170,10 @@ spec:
```
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.
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
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).
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.
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
## Requirements
Expand Down
51 changes: 23 additions & 28 deletions scanners/trivy/docs/README.ArtifactHub.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,23 @@ helm upgrade --install trivy secureCodeBox/trivy

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.

- Filter the vulnerabilities by severities `trivy image --severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `trivy image --vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `trivy image --skip-update python:3.4-alpine3.9`
- 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.

:::caution
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.
Please append the following extra arguments **after** specifying the mode (e.g., `repo`) but **before** specifying the target for the scan:
```yaml
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
```
### Trivy Container Image Scan

Currently we support the follwing 3 scanTypes, corresponding to the trivy scanning modes:
- scanType: "trivy-image"
- parameters: `[YOUR_IMAGE_NAME]`
- scanType: "trivy-filesystem"
- parameters: `[YOUR_PATH_TO_FILES]`
- scanType: "trivy-repo"
- parameters: `[YOUR_GITHUB_REPO]`

A complete example of each scanType are listed below in our [example docs section](https://www.securecodebox.io/docs/scanners/trivy/#examples).

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:
- Filter the vulnerabilities by severities `--severity HIGH,CRITICAL ruby:2.4.0`
- Filter the vulnerabilities by type (`os` or `library`) `--vuln-type os ruby:2.4.0`
- Skip update of vulnerability DB: `--skip-update python:3.4-alpine3.9`
- 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.

A complete scan definition for the secureCodeBox repository may look something like this:
```yaml
Expand All @@ -84,22 +86,15 @@ kind: Scan
metadata:
name: "trivy-scb"
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "repo"
- "--no-progress"
- "--format"
- "json"
- "--output"
- "/home/securecodebox/trivy-results.json"
- "https://github.com/secureCodeBox/secureCodeBox"
- bkimminich/juice-shop:v10.2.0
```
:::
### Scanning Many Targets
By default, the docker container of trivy will download new rulesets when starting the process.
As this download is performed directly from GitHub, you will run into API rate limiting issues after roughly 50 requests.
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.
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.
Due to [limitations in trivy](https://github.com/aquasecurity/trivy/issues/634), this mode currently only supports scanning container images.
If this fits your use case, you can deploy a rule service with the following template:
```yaml
Expand Down Expand Up @@ -164,7 +159,7 @@ metadata:
# Don't forget to update the namespace if necessary
namespace: default
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "client"
# Again, add the extra parameters here (required to make the parser work)
Expand All @@ -182,10 +177,10 @@ spec:
```
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.
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/).
Instead, you have to [manually download the ruleset and provide it to trivy](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/).
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).
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.
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/v0.20.2/advanced/air-gap/) for additional details on the required steps.
Consult the [trivy documentation](https://aquasecurity.github.io/trivy/latest/advanced/air-gap/) for additional details on the required steps.
## Requirements
Expand Down
7 changes: 7 additions & 0 deletions scanners/trivy/examples/filesystem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
SPDX-FileCopyrightText: the secureCodeBox authors
SPDX-License-Identifier: Apache-2.0
-->

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.
35 changes: 35 additions & 0 deletions scanners/trivy/examples/filesystem/scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: "execution.securecodebox.io/v1"
kind: Scan
metadata:
name: "trivy-filesystem"
spec:
scanType: "trivy-filesystem"
# Define a volume and mount it at /repo in the scan container to have a filesystem in place
volumes:
- name: repo
emptyDir: {}
volumeMounts:
- name: repo
mountPath: "/repo/"
# Define an init container to run the git clone for us
initContainers:
- name: "git-clone"
image: bitnami/git
# Specify that the "repo" volume should also be mounted on the
# initContainer
volumeMounts:
- name: repo
mountPath: "/repo/"
# Clone to /repo in the init container
command:
- git
- clone
# Add access token to the URL for authenticated HTTPS clone
- "https://github.com/yourOrg/yourRepo"
- /repo/
parameters:
- "/repo"
7 changes: 7 additions & 0 deletions scanners/trivy/examples/image-juice-shop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
SPDX-FileCopyrightText: the secureCodeBox authors
SPDX-License-Identifier: Apache-2.0
-->

This example shows how to use the `trivy image` scan with the secureCodeBox.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ metadata:
labels:
organization: "OWASP"
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "bkimminich/juice-shop:v10.2.0"
7 changes: 7 additions & 0 deletions scanners/trivy/examples/image-mediawiki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
SPDX-FileCopyrightText: the secureCodeBox authors
SPDX-License-Identifier: Apache-2.0
-->

This example shows how to use the `trivy image` scan with the secureCodeBox.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ kind: Scan
metadata:
name: "trivy-mediawiki"
spec:
scanType: "trivy"
scanType: "trivy-image"
parameters:
- "mediawiki:stable"
7 changes: 7 additions & 0 deletions scanners/trivy/examples/repo-github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!--
SPDX-FileCopyrightText: the secureCodeBox authors
SPDX-License-Identifier: Apache-2.0
-->

This example shows how to use the `trivy repo` scan with the secureCodeBox.
12 changes: 12 additions & 0 deletions scanners/trivy/examples/repo-github/scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0

apiVersion: "execution.securecodebox.io/v1"
kind: Scan
metadata:
name: "trivy-repo-github"
spec:
scanType: "trivy-repo"
parameters:
- "https://github.com/knqyf263/trivy-ci-test"
Loading