Unbalanced eval brackets causes TF parser loop
See original GitHub issueDescribe the bug From this (link 1, link 2) slack conversation, a malformed eval statement with mismatched brackets can cause a loop in the TF parser. Example statement (note missing closing bracket):
s3_access_logs_prefix = "${replace(var.cdn_logging_prefix, "cdn", "s3")/${var.bucket_name}"
It is currently unknown if it is an infinite loop, but it’s at least very slow.
To Reproduce I have reproduced with this parse scenario: main.tf:
locals {
# This is intentionally missing the closing bracket
s3_access_logs_prefix = "${replace(var.cdn_logging_prefix, "cdn", "s3")/${var.bucket_name}"
}
Expected behavior expected.json:
{
"main.tf": {
"locals": [
{
"s3_access_logs_prefix": ["${replace(var.cdn_logging_prefix, 'cdn', 's3')/${var.bucket_name}"]
}
]
}
}
I wouldn’t expect extra looping in the parser.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Balanced brackets - Rosetta Code
Task: Generate a string with N opening brackets [ and with N closing brackets ], in some arbitrary order. Determine whether the generated...
Read more >SyntaxError: unexpected EOF while parsing - Stack Overflow
The SyntaxError: unexpected EOF while parsing means that the end of your source code was reached before all code blocks were completed.
Read more >Error in code, "Invalid expression. Check for missing ...
Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
Read more >SystemVerilog 3.1a Language Reference Manual - Index of /
opment process, Accellera does not independently evaluate, test, ... For this reason, Accellera and the members of its Technical Committees are not able...
Read more >Valid Parentheses | Balanced Parentheses (with Python Code)
Learn what is valid parentheses and how to check if parentheses are balanced in expression along with an example and python code.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@robeden Good idea, I’m not sure about it but I’ll check that out
🤘 Rock on! Thanks Rob, know you’ve been speaking with Barak+Ariel on the issue.
Adding a bit of context for other watchers on the issue: Parser in use by checkov is here: https://github.com/bridgecrewio/python-hcl2 Assigning @arielkru and work-in-progress