You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like using merge() can produce an empty map if any of its elements have a direct reference that can't be resolved at scan time. For example, given the following Terraform file:
There are 3 buckets with tag definitions that refer to data.aws_region.current.name, which tfparse resolves to a null/empty value. The ok1 and ok2 buckets end up with tags that have null/empty values, but the bug1 bucket produces an entirely null set of tags.
Results of a tfparse.load_from_path() for this sample module
The fact that the merge() comes back as null is due to the HCL library not calling the function if arguments values have error (e.g. unknown variable value as in this case), which happens here .
For the specific case with the current region name, aquasecurity/trivy#7184 fixes the issue by adding a value to the presets.
Reopening to keep this as a tracking issue since the region preset only works around a subset of cases. I'm not clear on the best way forward though. Treating unresolvable values as individually null (so they could pass through a merge) is one option. Another might be to allow users to provide explicit presets at runtime, as one of the trivy maintainers suggested here.
It looks like using
merge()
can produce an empty map if any of its elements have a direct reference that can't be resolved at scan time. For example, given the following Terraform file:There are 3 buckets with tag definitions that refer to
data.aws_region.current.name
, which tfparse resolves to a null/empty value. Theok1
andok2
buckets end up with tags that have null/empty values, but thebug1
bucket produces an entirely null set of tags.Results of a tfparse.load_from_path() for this sample module
The text was updated successfully, but these errors were encountered: