-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
bug(misconf): Inconsistent in the issue count If terraform variables are not passed #7099
Comments
I don't agree that this is a problem. Since we can't evaluate the |
Hmm you're right, I thought we could support the case where we evaluate what we can (excluding the missing tf-vars for-each). But it seems as you mentioned that terraform deems it to be an invalid configuration so it's probably best that we follow the same. I do think however, we should show a log output to help the user understand that their input has an issue. Silently dropping looks misleading as it signals we were unable to find any misconfiguration. WDYT? |
@simar7 I agree about better logging. There are a couple of other places where the output could be improved. For example here: 2024-07-04T11:40:15+05:30 DEBUG [misconf] 40:15.433552948 terraform.scanner Scanning [&{%!s(*mapfs.file=&{ [] {. 256 2147484096 {13950371612937561924 505949398 0x794e200} <nil>} {{{0 0} {[] {} 0xc0016760c0} map[vpc.tf:0xc0010d8110] 0}}}) }] at '.'...
|
I think a tool like Trivy has to prominently fail when there's any issue with the inputs. I just happened across this ticket while refactoring some code which used the remote backend to use the HTTP backend, and suddenly started getting a ton of “CRITICAL” warnings from things like network ACLs which had been in use for years, which was puzzling as builds on our main branches were not reporting any issues. After spending some time bisecting my changes, the key factor appears to be a few places where we were using Fortunately they're false-positives but that could potentially have been serious. This was also complicated by the fact that these were managed by the |
Hi @acdha ! Could you please provide an example using |
I'm working on that but it's a large project and since Trivy takes ~70 seconds to scan it the reduction process is taking longer than I'd hoped. I'll update next week. |
Discussed in #7095
Originally posted by cybersa July 4, 2024
Description
There is a inconsistent in the issue count if terraform variables are not passed.
For Example:
Consider this terraform script main.tf:
If I run trivy scan against above main.tf, there is no HIGH and CRITICAL issues.
trivy config --misconfig-scanners terraform -s "HIGH,CRITICAL" main.tf
If I pass below tfvars file into trivy config, there are 3 CRITICAL issues.
vars.tfvars
command:
trivy config --misconfig-scanners terraform --tf-vars vars.tfvars -s "HIGH,CRITICAL" main.tf
Above command returns 3 CRITICAL issues.
Desired Behavior
Scan result should be consistent even if tfvars file is not passed. Because issue is on this line
map_public_ip_on_launch = true
and it is hardcoded in the terraform script.Actual Behavior
Scan result is inconsistent.
Reproduction Steps
Reproduction steps are in the Description field.
Target
Filesystem
Scanner
Misconfiguration
Output Format
None
Mode
Standalone
Debug Output
Operating System
Ubuntu 20.04
Version
Checklist
trivy clean --all
The text was updated successfully, but these errors were encountered: