Replies: 2 comments
-
|
Hi @felipeng ! Thanks for the report! Track #10047 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
If you're hitting false positives from for_each/try() resolution in static analysis, an alternative approach is to evaluate the deployed bucket's actual configuration rather than the Terraform template. Tools like Stave evaluate observation snapshots of your infrastructure (captured via AWS CLI) against security controls — so versioning.enabled is checked against the real bucket state, not the HCL expression that computes it. No parser, no false positives from complex expressions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Trivy has a false-positive when using data resource with for_each
Desired Behavior
No misconfiguration found
Actual Behavior
Finds the misconfiguration: AVD-AWS-0090 (MEDIUM): Bucket does not have versioning enabled
Reproduction Steps
Using this terraform code locals { aws-s3 = { my-bucket = { versioning_status = "Enabled" attach_policy = true policy = data.aws_iam_policy_document.policy1["dev"].json } } } #trivy:ignore:AVD-AWS-0132 trivy:ignore:AVD-AWS-0088 trivy:ignore:AVD-AWS-0089 module "aws-s3" { source = "terraform-aws-modules/s3-bucket/aws" version = "~> 4.11.0" for_each = local.aws-s3 bucket = each.key attach_policy = try(each.value.attach_policy, false) policy = try(each.value.policy, null) versioning = { status = try(each.value.versioning_status, "Disabled") } } data "aws_iam_policy_document" "policy1" { for_each = toset(["dev"]) } data "aws_iam_policy_document" "policy2" { for_each = toset(["dev"]) } Run: `trivy config .` Trivy has a false-positive with "AVD-AWS-0090 (MEDIUM): Bucket does not have versioning enabled". Even the data-policy2 is not being used in the `module` for_each loop. For some reason if comment out the "data policy2 block" works correctly (no misconfiguration found)Target
None
Scanner
Misconfiguration
Output Format
None
Mode
Standalone
Debug Output
Checklist
trivy clean --allBeta Was this translation helpful? Give feedback.
All reactions