[Terraform] resolve attributes depending on conditions #5680
Replies: 3 comments 1 reply
-
Hi @SujithPS0604 ! The right-hand side of the conditional statement is also evaluated: resource "github_repository" "name" {
name = "example"
description = "My awesome codebase"
visibility = false ? "public" : "private"
} For example in this case Could you please share the configurations so that I can investigate this. Do you have the |
Beta Was this translation helpful? Give feedback.
-
Hello @nikpivkin :)
even if I simply use |
Beta Was this translation helpful? Give feedback.
-
Thanks @SujithPS0604 ! I created issue #5686 |
Beta Was this translation helpful? Give feedback.
-
Description
defsec does not evaluate the second part of a conditional operator
Example:
Here whatever the condition is, defsec is only scanning the configuration of the first part of the condition. Here it is analyzing
data.aws_iam_policy_document.access_policy_document_prod.json
.Output:
trivy config . --severity "HIGH" -d
Here there is no failure, as the policy
data.aws_iam_policy_document.access_policy_document_prod.json
is clean from issues.But if I move the second part to the first part, it is showing all the issues of
data.aws_iam_policy_document.access_policy_document.json
.Example:
Output:
trivy config . --severity "HIGH" -d
here, the number of config files scanned also increased, and is showing issues with the policy.
So, by default, is is always analyzing the first part of the condition only. Even if I switch the condition, it is still analyzing the first part.
Desired Behavior
It should analyze both the part of the condition, irrespective of the position at which it is in.
Actual Behavior
It is analyzing only the first part of the condition.
Reproduction Steps
1.In a terraform file, write a conditional expression, which will choose either one data block or the other data block. 2. Run the `trivy config` and observe it is showing the issues from the first part of the expression only
Target
Filesystem
Scanner
Misconfiguration
Output Format
None
Mode
Standalone
Debug Output
Operating System
macOS Sonoma
Version
Checklist
trivy image --reset
Beta Was this translation helpful? Give feedback.
All reactions