amplify-education / python-hcl2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error parsing multiline comment

julian7 opened this issue · comments

I'm trying to use checkov, which uses python-hcl2 as terraform file parser, and I have issues with parsing multiline comments as mentioned in bridgecrewio/checkov#2933. Here's my test with checkov:

❯ seq 1 4 | xargs -I, sh -c 'echo Example ,; cat ,.tf; checkov --quiet -f ,.tf'
Example 1
resource "null_resource" "nothing" {
    triggers = [
        /* "a",
        "b" */
    ]
}
terraform scan results:

Passed checks: 0, Failed checks: 0, Skipped checks: 0, Parsing errors: 1


Example 2
resource "null_resource" "nothing" {
    triggers = [
        /* "a", "b" */ ]
}

Example 3
resource "null_resource" "nothing" {
    triggers = [
        /* "a", "b" */
    ]
}
terraform scan results:

Passed checks: 0, Failed checks: 0, Skipped checks: 0, Parsing errors: 1


Example 4
resource "null_resource" "nothing" {
    triggers = [ /* "a", "b" */
    ]
}

I've also tested triggers = [ /* "a", "b" */ ] off camera, and it was rendering well.

I'm not sure, but probably this issue is more likely about handling lists rather than comments.

Hi @julian7! Try to upgrade to v4.2.0. In #118 I added tests for multiline comments inside a tuple and the lib passes them.