-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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): log causes of HCL file parsing errors #7634
Conversation
Signed-off-by: nikpivkin <[email protected]>
@simar7 I'm concerned that a few lines will make it hard to see where the error occurred. Should we display the whole resource? Or, if the resource is large, just the top part of it and the range of lines where the error occurred, for example: cause="resource \"aws_s3_bucket\" \"test\" {}\n... bucket = <" |
TBH this was my concern as well. The CLI log output isn't the best way to show such information. I think the best would be to display a code snippet along with start/end line numbers. It would be similar (for the code snippet) for what we do with secret scanning output. |
In that case we should respect the quiet flag and pass it to IaC scanners. Or is there a helper function in Trivy that does not print to stdout if the quiet flag is passed? |
What's the quote flag you're referring to? I think since this is part of the debug output stream, it is fine to be verbose to the extent where we display a code snippet and start/end line numbers as we discussed. That amount of info is sufficient enough for a user to be able to determine where the resource lies. |
@simar7 My typo, I meant the flag |
If logging is not the appropriate place, then the only thing left is directly to stdout, which Trivy only does for reports. |
I don't have any better idea at this time. We can implement the log output with the start/end line for now and improve it later if need be. |
@nikpivkin I updated the PR, is there anything we need prior to merging it in? |
No, I forgot to mark this as ready for review after testing |
Description
Related issues
Checklist