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

SearchKey on Terraform queries point to same line with multiple resources of the same type #2010

Closed
joaomartinscx opened this issue Feb 8, 2021 · 0 comments · Fixed by #3471
Assignees
Labels
bug Something isn't working go Pull requests that update Go code terraform Terraform query

Comments

@joaomartinscx
Copy link
Contributor

Expected Behavior

With multiple resources of the same type, each occurrence should point to the respective lines of the resource.

Actual Behavior

The results always point to the first occurrence, even with a different searchKey.

Steps to Reproduce the Problem

Take, for example, the query "S3 bucket without encryption at REST" or this snippet for that query:

CxPolicy[result] {
	bucket := input.document[i].resource.aws_s3_bucket[name]
        object.get(bucket,"server_side_encryption_configuration","undefined") == "undefined"

	result := {
		"documentId": input.document[i].id,
		"searchKey": sprintf("aws_s3_bucket[%s]", [name]),
		"issueType": "MissingAttribute",
		"keyExpectedValue": "'aws_s3_bucket.server_side_encryption_configuration' exists",
		"keyActualValue": "'aws_s3_bucket.server_side_encryption_configuration' is missing",
	}
}

Then run the query against this sample:

resource "aws_s3_bucket" "b" {
        bucket = "my-tf-test-bucket"
        acl    = "private"
}
 
resource "aws_s3_bucket" "a" {
  bucket = "my-another-tf-test-bucket"
  acl    = "private"
}

Two occurrences should result by the execution, one that points to the line where aws_s3_bucket named a is, and another pointed to the resource named b. Instead, both lines are pointing to the first resource, b.

Specifications

  • Version: 1.1.2
  • Platform: Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Pull requests that update Go code terraform Terraform query
Projects
None yet
3 participants