Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing of heredocs does not allow arbitrary strings #119

Closed
edmundcraske-bjss opened this issue Sep 13, 2023 · 2 comments
Closed

Parsing of heredocs does not allow arbitrary strings #119

edmundcraske-bjss opened this issue Sep 13, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@edmundcraske-bjss
Copy link

I originally raised this at amplify-education#141 but I guess as you use this fork for checkov then maybe it needs fixing here first?

I am hitting an issue with https://github.com/bridgecrewio/checkov/ throwing a parsing error where a .tf file containing an aws_codebuild_project resource has a buildspec attribute defined using a heredoc that contains a shell script, and some of the lines in the shell script are long, and split using the \ as continuation character. In some cases there is a " opened and not closed until another line, and I am getting an unhandled exception (seen when setting LOG_LEVEL=DEBUG):

  File "/opt/homebrew/Cellar/checkov/2.3.330/libexec/lib/python3.11/site-packages/checkov/terraform/modules/module_utils.py", line 74, in load_or_die_quietly
    raw_data = hcl2.load(f)
               ^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/checkov/2.3.330/libexec/lib/python3.11/site-packages/hcl2/api.py", line 15, in load
    return loads(file.read())
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/checkov/2.3.330/libexec/lib/python3.11/site-packages/hcl2/api.py", line 82, in loads
    raise ValueError(f"Line has unclosed quote marks: {line}")

But I'm not sure that the parser should even be parsing the heredoc, let alone having an issue with quotes in a bash script contained within a perfectly valid string where the Terraform code definitely works... Any suggestions?

@gruebel
Copy link

gruebel commented Sep 25, 2023

hey @edmundcraske-bjss thanks for reaching out.

We do a pre-testing of quotes, because we have issues with TF templates, which are invalid and result in an infinte loop processing. Can you add a simple example, which results in the mentioned error?

@gruebel gruebel added the bug Something isn't working label Sep 25, 2023
@gruebel
Copy link

gruebel commented Nov 12, 2023

feel free to reach out with an example to better debug it 🙂

@gruebel gruebel closed this as completed Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants