feat(terraform): support nested HCL identifier parsing by grouping variable paths and preserving relative subpaths#7428
Merged
cx-artur-ribeiro merged 16 commits intomasterfrom Apr 14, 2025
Conversation
…preserving relative subpaths
Contributor
… false positive result
…5917-fix-terraform-parser
…heckmarx/kics into AST-65917-fix-terraform-parser
…5917-fix-terraform-parser
…heckmarx/kics into AST-65917-fix-terraform-parser
Contributor
cx-rui-araujo
left a comment
There was a problem hiding this comment.
@cx-artur-ribeiro please check my comment
JonasCordsen
pushed a commit
to JonasCordsen/kics
that referenced
this pull request
Jun 11, 2025
…riable paths and preserving relative subpaths (Checkmarx#7428) * Support nested HCL identifier parsing by grouping variable paths and preserving relative subpaths * Add a new data_source test to cover the new functions defined
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Reason for Proposed Changes
In the added unit test
negative8.tf,we encountered an issue where the variable identifier referencing the resource aws_cloudfront_origin_access_identity caused the parser to throw an error during variable resolution:The parser couldn't resolve the policy on the payload, leading to the detection of a false positive:
Proposed Changes
identifiers = [aws_cloudfront_origin_access_identity.support_site_origin_access_identity.iam_arn]It expects an actual object with nested fields, not a string like:
"aws_cloudfront_origin_access_identity.support_site_origin_access_identity.iam_arn"Otherwise, we get the "Unsupported attribute" error. Thats why the root path is removed in this case, as we can see on line 319:
Related Issues
I submit this contribution under the Apache-2.0 license.