Terraform private module scanning - trivy can't get token from TF_TOKEN env var when hostname contains a "-" character #6067
Closed
adam-carruthers
started this conversation in
Bugs
Replies: 1 comment
-
Hi @adam-carruthers ! Track #6068 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Here is the trivy code that finds the token for private terraform registry modules:
https://github.com/aquasecurity/trivy-iac/blob/3d8e412cf0ab0c8ad0296df8a01363a3ed7efe85/pkg/scanners/terraform/parser/resolvers/registry.go#L58
This correctly changes the
.
characters in hostnames to_
- but that's not the only transformation that needs to be done. It also needs to look for a second env var with the-
characters as__
. From the terraform docs:I really need this change, because I pass the token through the
TF_TOKEN
variable, but the hostname has a-
and I am using Ubuntu that doesn't allow-
in environment variables, so trivy can't find myDesired Behavior
When I used my environment variable
TF_TOKEN_some__site_with_hash_com
trivy recognised it as the terraform private registry token forsome-site.with.hash.com
Actual Behavior
Trivy didn't recognise my environment variable and I couldn't connect it to the private registry.
Reproduction Steps
export TF_TOKEN_some__site_with_hash_com=abcdef
trivy config --skip-dirs .terraform -d .
Target
Filesystem
Scanner
Misconfiguration
Output Format
None
Mode
Standalone
Debug Output
Operating System
Ubuntu
Version
Checklist
trivy image --reset
Beta Was this translation helpful? Give feedback.
All reactions