tenable / terrascan

Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure.
https://runterrascan.io
Apache License 2.0
4.75k stars 499 forks source link

Can't parse Terraform variable field: `nullable` #1547

Open leadenmoth opened 1 year ago

leadenmoth commented 1 year ago

Description

After adding nullable = false to a variable definition, terrascan can no longer parse the file.

See https://www.terraform.io/language/values/variables#disallowing-null-input-values for documentation of the field.

Here is a minimal example:

terraform {
}

variable "in" {
  type     = string
  nullable = false
}

resource "null_resource" "test_resource" {
  triggers = {
    input_value = var.in
  }
}

What I Did

terraform validate, terraform plan, terraform apply all succeed (terraform v1.3.6)

Terrascan throws variations of the following, depending on environment:

Terrascan Sandbox

failed to scan uploaded file. error: 'failed to load iac file '/tmp/terrascan-67659632.tf'. error:
/tmp/terrascan-67659632.tf:6,3-11: Unsupported argument; An argument named "nullable" is not expected here.
'

Alpine/edge (gitlab runner)

2023-03-10T08:21:51.247Z    [31merror[0m    cli/run.go:141  scan run failed{error 26 0 failed to load iac file '/path/redacted/variables.tf'. error: /path/redacted/variables.tf:24,3-11: Unsupported argument; An argument named "nullable" is not expected here.

Additional notes

This bug was first reported in version 1.13.2 here: https://github.com/tenable/terrascan/issues/1176 It was incorrectly marked as fixed by https://github.com/tenable/terrascan/pull/1211 It is still present in 1.18.0 and similar issues are found in multiple versions e.g. here: https://github.com/tenable/terrascan/issues/1262

maxmanus96 commented 1 year ago

+1, I am using TERRAFORM_VERSION: '1.3.5'

arkeros commented 1 year ago

Any update?

mjnowen commented 10 months ago

+1 this issue is a blocker

sodds-eq commented 9 months ago

Still an issue in v1.18.11

oferchen commented 7 months ago

Still an issue v1.19.1