Support data sources for queries related with policies
Expected Behavior
When Parsing a Terraform file with a policy it should be able to unmarshall the policy even if its given by a variable.
Actual Behavior
4:31PM | ERROR | inspector. query executed with error, query=assets\queries\terraform\aws\iam_role_with_full_privileges ERROR:"failed to evaluate query: assets\queries\terraform\aws\iam_role_with_full_privileges:5: eval_builtin_error: json.unmarshal: invalid character '$' looking for beginning of value" scanID:CONSOLE
Query fails since it isn't able to unmarshall the policy which after parsed stays this way :
"assume_role_policy":${data.aws_iam_policy_document.iam_policy_eks.json }
Using the example below.
(Other queries are not being executed for the same reason)
Steps to Reproduce the Problem
-
Create a terraform file where the policy file is given by a variable ex:
data aws_iam_policy_document "iam_policy_eks" {statement {effect = "Allow"actions = ["sts:AssumeRole"]principals {type = "Service"identifiers = ["eks.amazonaws.com"]}}}resource aws_iam_role "iam_for_eks" {name = "${local.resource_prefix.value}-iam-for-eks"assume_role_policy = data.aws_iam_policy_document.iam_policy_eks.json} -
Run the application specifying the -p flag with the path to the terraform file and using -v or -l flag to see the logs
Specifications
- Platform: Terraform
- Provider: AWS
This will need more work, looking to implement this together with the evaluation of HCL functions