checkov
checkov copied to clipboard
fix(terraform): Fix possible exception when for_each data has boolean values
User description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
Fixes #6731.
When for_each is used over data with boolean values, an exception can occur. See tests in this PR for what relevant Terraform might look like.
This fix prevents the logic from looking at an attribute's value for additional string interpolation expressions to process when it doesn't need to. Example: If we already processed monitoring="${each.value.monitoring_boolean}"
, we don't need to check the value of instance_type again for more interpolation expressions.
Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] I have added tests that prove my feature, policy, or fix is effective and works
- [x] New and existing tests pass locally with my changes
Generated description
Dear maintainer, below is a concise technical summary of the changes proposed in this PR:
Fix an exception in ForeachAbstractHandler
when processing boolean values in Terraform for_each
data. Modify the logic to avoid unnecessary checks for string interpolation expressions. Update test resources to include boolean monitoring
attributes, ensuring the fix is effective.
Topic | Details | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Test Updates | Add tests for boolean monitoring attributes in Terraform resources to validate the fix.Modified files (3)
Latest Contributors(1)
| |||||||||
Boolean Handling | Fix an exception in ForeachAbstractHandler when processing boolean values in Terraform for_each data.Modified files (1)
Latest Contributors(2)
|