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

feat(misconf): Improve terraform plan JSON error logging #7630

Closed
simar7 opened this issue Oct 2, 2024 · 1 comment · Fixed by #7634
Closed

feat(misconf): Improve terraform plan JSON error logging #7630

simar7 opened this issue Oct 2, 2024 · 1 comment · Fixed by #7634
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning
Milestone

Comments

@simar7
Copy link
Member

simar7 commented Oct 2, 2024

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."

Originally posted by @nikpivkin in #7608 (reply in thread)

@simar7 simar7 added kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning labels Oct 2, 2024
@simar7 simar7 changed the title fix(misconf): Improve terraform plan JSON error logging feat(misconf): Improve terraform plan JSON error logging Oct 2, 2024
@simar7 simar7 added this to the v0.57.0 milestone Oct 2, 2024
@nitrocode
Copy link

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.

@simar7 simar7 modified the milestones: v0.57.0, v0.58.0 Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. scan/misconfiguration Issues relating to misconfiguration scanning
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

3 participants