Skip to content

HCLv1 does not support boolean in list #740

@cipherboy

Description

@cipherboy

In TestPolicy_Parse from Vault, we test the following denied_parameters value:

path "test/types" {
    capabilities = ["create", "sudo"]
    allowed_parameters = {
        "map" = [{"good" = "one"}]
        "int" = [1, 2]
    }
    denied_parameters = {
        "string" = ["test"]
        "bool" = [false]
    }
}

This works in HCL but not in the equivalent JSON:

    "test/types": {
      "capabilities": ["create", "sudo"],
      "allowed_parameters": {
        "map": [{"good": "one"}],
        "int": [1, 2]
      },
      "denied_parameters": {
        "string": ["test"],
        "bool": [false]
      }
    }

This results in:

    policy_test.go:494: [slice[8].Permissions.DeniedParameters.map[bool].slice[0]: <no value> != false slice[8].DeniedParametersHCL.map[bool].slice[0]: <no value> != false]

This is noted here:

hcl/json/parser/parser.go

Lines 238 to 239 in 02db497

case token.BOOL:
// TODO(arslan) should we support? not supported by HCL yet

Changing the earlier conditional:

case token.NUMBER, token.FLOAT, token.STRING:

works to fix this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions