bug(misconf): terraform local cache is ignored #6603
Labels
kind/bug
Categorizes issue or PR as related to a bug.
scan/misconfiguration
Issues relating to misconfiguration scanning
Milestone
Discussed in #6552
Originally posted by cawolf April 24, 2024
Description
When using trivy for our terraform configuration, we ran into an issue regarding the local terraform cache located in
.terraform
. Trivy 0.50.2 seems to ignore the local cache completely, and instead tries to fetch the modules remotely. In our special case, this leads to a subsequent error (we are using the GitLab terraform registry, which is currently not supported by trivy), which makes trivy not runnable for us.After some debugging, we found that the filesystem used to open the
.terraform/modules/modules.json
file is filtered down to terraform files only (".tf", ".tf.json", ".tfvars"), and thus is not able to open the modules.json file ever. Naively fixing the filepkg/iac/detection/detect.go:247
to also contain the modules.json file fixes the problem locally for us.Desired Behavior
The terraform cache in
.terraform
should be used.Actual Behavior
The terraform cache in
.terraform
is ignored, the debug log outputs:Reproduction Steps
terraform version
terraform init
trivy config .
Operating System
Ubuntu 22.04.4 LTS
Version
Checklist
trivy image --reset
The text was updated successfully, but these errors were encountered: