question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unbalanced eval brackets causes TF parser loop

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
arielkrucommented, Feb 3, 2021

@robeden Good idea, I’m not sure about it but I’ll check that out

1reaction
metahertzcommented, Feb 3, 2021

🤘 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found