You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/references/configuration/cli/trivy_config.md
+1
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ trivy config [flags] DIR
17
17
--compliance string compliance report to generate
18
18
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
19
19
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
20
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
20
21
--enable-modules strings [EXPERIMENTAL] module names to enable
21
22
--exit-code int specify exit code when any security issues are found
Copy file name to clipboardExpand all lines: docs/docs/references/configuration/cli/trivy_filesystem.md
+1
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ trivy filesystem [flags] PATH
27
27
--compliance string compliance report to generate
28
28
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
29
29
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
30
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
30
31
--custom-headers strings custom headers in client mode
31
32
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
32
33
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
Copy file name to clipboardExpand all lines: docs/docs/references/configuration/cli/trivy_image.md
+1
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,7 @@ trivy image [flags] IMAGE_NAME
41
41
--compliance string compliance report to generate (docker-cis-1.6.0)
42
42
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
43
43
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
44
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
44
45
--custom-headers strings custom headers in client mode
45
46
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
46
47
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
--compliance string compliance report to generate (k8s-nsa-1.0,k8s-cis-1.23,eks-cis-1.4,rke2-cis-1.24,k8s-pss-baseline-0.1,k8s-pss-restricted-0.1)
38
38
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
39
39
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
40
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
40
41
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
41
42
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
42
43
--detection-priority string specify the detection priority:
--commit string pass the commit hash to be scanned
28
28
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
29
29
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
30
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
30
31
--custom-headers strings custom headers in client mode
31
32
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
32
33
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
Copy file name to clipboardExpand all lines: docs/docs/references/configuration/cli/trivy_rootfs.md
+1
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ trivy rootfs [flags] ROOTDIR
29
29
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
30
30
--config-check strings specify the paths to the Rego check files or to the directories containing them, applying config files
31
31
--config-data strings specify paths from which data for the Rego checks will be recursively loaded
32
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
32
33
--custom-headers strings custom headers in client mode
33
34
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
34
35
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
Copy file name to clipboardExpand all lines: docs/docs/references/configuration/cli/trivy_vm.md
+1
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ trivy vm [flags] VM_IMAGE
25
25
--cache-ttl duration cache TTL when using redis as cache backend
26
26
--checks-bundle-repository string OCI registry URL to retrieve checks bundle from (default "ghcr.io/aquasecurity/trivy-checks:0")
27
27
--compliance string compliance report to generate
28
+
--config-file-schemas strings specify paths to JSON configuration file schemas to determine that a file matches some configuration and pass the schema to Rego checks for type checking
28
29
--custom-headers strings custom headers in client mode
29
30
--db-repository string OCI repository to retrieve trivy-db from (default "ghcr.io/aquasecurity/trivy-db:2")
30
31
--dependency-tree [EXPERIMENTAL] show dependency origin tree of vulnerable packages
2022-06-06T11:01:21.142+0100 INFO Detected config files: 8
112
112
113
113
Dockerfile (dockerfile)
@@ -343,6 +343,61 @@ You can load checks bundle as OCI Image from a Container Registry using the `--c
343
343
trivy config --checks-bundle-repository myregistry.local/mychecks --namespaces user myapp
344
344
```
345
345
346
+
347
+
### Scan arbitrary JSON and YAML configurations
348
+
By default, scanning JSON and YAML configurations is disabled, since Trivy does not contain built-in checks for these configurations. To enable it, pass the `json` or `yaml` to `--misconfig-scanners`. See [Enabling a subset of misconfiguration scanners](#enabling-a-subset-of-misconfiguration-scanners) for more information. Trivy will pass each file as is to the checks input.
349
+
350
+
351
+
!!! example
352
+
```bash
353
+
$ cat iac/serverless.yaml
354
+
service: serverless-rest-api-with-pynamodb
355
+
356
+
frameworkVersion: ">=2.24.0"
357
+
358
+
plugins:
359
+
- serverless-python-requirements
360
+
...
361
+
362
+
$ cat serverless.rego
363
+
# METADATA
364
+
# title: Serverless Framework service name not starting with "aws-"
365
+
# description: Ensure that Serverless Framework service names start with "aws-"
366
+
# schemas:
367
+
# - input: schema["serverless-schema"]
368
+
# custom:
369
+
# id: SF001
370
+
# severity: LOW
371
+
package user.serverless001
372
+
373
+
deny[res] {
374
+
not startswith(input.service, "aws-")
375
+
res := result.new(
376
+
sprintf("Service name %q is not allowed", [input.service]),
377
+
input.service
378
+
)
379
+
}
380
+
381
+
$ trivy config --misconfig-scanners=json,yaml --config-check ./serverless.rego --check-namespaces user ./iac
Ensure that Serverless Framework service names start with "aws-"
390
+
```
391
+
392
+
You can also pass schemas using the `config-file-schemas` flag. Trivy will use these schemas for file filtering and type checking in Rego checks. If the file does not match any of the passed schemas, it will be ignored.
If the schema is specified in the check metadata and is in the directory specified in the `--config-check` argument, it will be automatically loaded as specified [here](./custom/schema.md#custom-checks-with-custom-schemas), and will only be used for type checking in Rego.
400
+
346
401
### Passing custom data
347
402
You can pass directories including your custom data through `--data` option.
348
403
This can be repeated for specifying multiple directories.
@@ -363,12 +418,12 @@ This can be repeated for specifying multiple packages.
363
418
trivy config --config-check ./my-check --namespaces main --namespaces user ./configs
364
419
```
365
420
366
-
### Private terraform registries
367
-
Trivy can download terraform code from private registries.
421
+
### Private Terraform registries
422
+
Trivy can download Terraform code from private registries.
368
423
To pass credentials you must use the `TF_TOKEN_` environment variables.
369
424
You cannot use a `.terraformrc` or `terraform.rc` file, these are not supported by trivy yet.
370
425
371
-
From the terraform[docs](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials):
426
+
From the Terraform [docs](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials):
372
427
373
428
> Environment variable names should have the prefix TF_TOKEN_ added to the domain name, with periods encoded as underscores.
374
429
> For example, the value of a variable named `TF_TOKEN_app_terraform_io` will be used as a bearer authorization token when the CLI makes service requests to the hostname `app.terraform.io`.
0 commit comments