This would be especially useful when scanning Terraform Plan JSON, since we are converting it to HCL and have no way to track the location of the error.
We can add, for example, a cause field on logging that contains the source code of the location where the error occurred:
2024-09-28T09:47:17+06:00 DEBUG [terraform parser] Parsing module="root" file_path="main.tf"
2024-09-28T09:47:17+06:00 ERROR [terraform parser] Error parsing file module="root" file_path="main.tf"
cause="\tbucket = <" err="main.tf:2,11-12: Invalid expression; Expected the start of an expression, but found an invalid expression token."
I got the same error when running trivy config ./plan.json and it's my first time running trivy after using tfsec for years. Looking forward to this fix. Thank you for creating the issue.
This would be especially useful when scanning Terraform Plan JSON, since we are converting it to HCL and have no way to track the location of the error.
We can add, for example, a cause field on logging that contains the source code of the location where the error occurred:
Originally posted by @nikpivkin in https://github.com/aquasecurity/trivy/discussions/7608#discussioncomment-10781373