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
@@ -6,7 +6,7 @@ In addition to built-in policies, you can write your own custom policies, as you
6
6
7
7
Simply specify a directory containing IaC files such as Terraform, CloudFormation, Azure ARM templates, Helm Charts and Dockerfile.
8
8
9
-
```bash
9
+
```bash
10
10
$ trivy config [YOUR_IaC_DIRECTORY]
11
11
```
12
12
@@ -365,7 +365,7 @@ Trivy can download terraform code from private registries.
365
365
To pass credentials you must use the `TF_TOKEN_` environment variables.
366
366
You cannot use a `.terraformrc` or `terraform.rc` file, these are not supported by trivy yet.
367
367
368
-
From the terraform docs:
368
+
From the terraform [docs](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials):
369
369
370
370
> Environment variable names should have the prefix TF_TOKEN_ added to the domain name, with periods encoded as underscores.
371
371
> 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`.
@@ -380,31 +380,147 @@ If multiple variables evaluate to the same hostname, Trivy will choose the envir
380
380
381
381
382
382
### Skipping resources by inline comments
383
-
Some configuration file formats (e.g. Terraform) support inline comments.
384
383
385
-
In cases where trivy can detect comments of a specific format immediately adjacent to resource definitions, it is possible to filter/ignore findings from a single point of resource definition (in contrast to `.trivyignore`, which has a directory-wide scope on all of the files scanned).
384
+
Trivy supports ignoring misconfigured resources by inline comments for Terraform configuration files only.
385
+
386
+
In cases where Trivy can detect comments of a specific format immediately adjacent to resource definitions, it is possible to ignore findings from a single source of resource definition (in contrast to `.trivyignore`, which has a directory-wide scope on all of the files scanned). The format for these comments is `trivy:ignore:<rule>` immediately following the format-specific line-comment [token](https://developer.hashicorp.com/terraform/language/syntax/configuration#comments).
386
387
387
-
The format for these comments is `trivy:ignore:<Vulnerability ID>` immediately following the format-specific line-comment token.
388
-
You can add multiple ignores on the same comment line.
388
+
The ignore rule must contain one of the possible check IDs that can be found in its metadata: ID, short code or alias. The `id` from the metadata is not case-sensitive, so you can specify, for example, `AVD-AWS-0089` or `avd-aws-0089`.
389
389
390
-
For example, to filter a misconfiguration ID "AVD-GCP-0051" in a Terraform HCL file:
390
+
For example, to ignore a misconfiguration ID `AVD-GCP-0051` in a Terraform HCL file:
You can also specify a long ID, which is formed as follows: `<provider>-<service>-<short-code>`.
410
+
411
+
As an example, consider the following check metadata:
412
+
413
+
```yaml
414
+
# custom:
415
+
# id: AVD-AWS-0089
416
+
# avd_id: AVD-AWS-0089
417
+
# provider: aws
418
+
# service: s3
419
+
# severity: LOW
420
+
# short_code: enable-logging
421
+
```
422
+
423
+
Long ID would look like the following: `aws-s3-enable-logging`.
424
+
425
+
#### Expiration Date
426
+
427
+
You can specify the expiration date of the ignore rule in `yyyy-mm-dd` format. This is a useful feature when you want to make sure that an ignored issue is not forgotten and worth revisiting in the future. For example:
The `aws-ec2-no-public-ingress-sgr` check will be ignored only for the `aws_security_group_rule` resource with port number `5432`. It is important to note that the ignore rule should not enclose the attribute value in quotes, despite the fact that the port is represented as a string.
460
+
461
+
If you want to ignore multiple resources on different attributes, you can specify multiple ignore rules:
Currently nested attributes are not supported. For example you will not be able to reference the `each.key` attribute.
499
+
500
+
#### Ignoring module issues
501
+
502
+
Issues in third-party modules cannot be ignored using the method described above, because you may not have access to modify the module source code. In such a situation you can add ignore rules above the module block, for example:
503
+
504
+
```tf
505
+
#trivy:ignore:aws-s3-enable-logging
506
+
module "s3_bucket" {
507
+
source = "terraform-aws-modules/s3-bucket/aws"
508
+
509
+
bucket = "my-s3-bucket"
510
+
}
511
+
```
512
+
513
+
An example of ignoring checks for a specific bucket in a module:
0 commit comments