feat(terraform): add variable support for Terraform Plan #7222
Labels
kind/bug
Categorizes issue or PR as related to a bug.
scan/misconfiguration
Issues relating to misconfiguration scanning
Milestone
Currently, Trivy does not handle variables that are stored in Terraform Plan in any way.
Discussed in #7178
Originally posted by cybersa July 17, 2024
Description
Consider this terraform file and terraform vars file:
s3.tf:
vars.tf
I ran these command one by one:
trivy config --tf-vars vars.tfvars --misconfig-scanners "terraform" s3.tf
Not any issues. (Because condition count validated to false)
Then I used this command to generate terraform plan as a snapshot
terraform plan --var-file vars.tfvars --out tfplan
Then I ran trivy command against terraform snapshot:
trivy config --misconfig-scanners "terraformplan-snapshot" tfplan
3 open issues.
Then I ran trivy command against terraform snapshot but this time with tfvars file.
trivy config --tf-vars vars.tfvars --misconfig-scanners "terraformplan-snapshot" tfplan
No open issues this time.
Important thing is I can run terraform apply command against tfplan without passing tfvars file and it is working as excepted But it is not the case with trivy.
terraform apply tfplan
Desired Behavior
There should not be any open issues.
Actual Behavior
Inconsistent in the issue count between terraform and terraformplan-snapshot scanner
Reproduction Steps
Reproduction steps are in the descriptions.
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: