When resolving Terraform modules from registry, Trivy does not utilize remote service discovery #7982
marcinbelczewski
started this conversation in
Bugs
Replies: 1 comment
-
That's right, Trivy does not currently support remote service discovery. |
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
This is the same problem as described in closed discussion #7777 however, here I can provide all the necessary details.
When scanning Terraform code containing definition of a module source from the private Terraform registry, Trivy assumes certain endpoints URLs, which are invalid for example for Terraform registries deployed on JFrog Artifactory.
Desired Behavior
Trivy is able to utilize Terraform HTTP API's Remote Service Discovery to resolve endpoints of private Terraform registries, with URL schemes different than those of public Terraform Registry.
Actual Behavior
Trivy fails with HTTP 404 because it assumes private Terraform registries will have URL scheme exactly the same as public Terraform Registry.
Reproduction Steps
As can be seen, Trivy assumes
https://repo.example.com/v1/modules/
URL scheme for the registry to download the module, however, the actual URL scheme can be learned by utilizing Terraform Registry HTTP API Remote Service Discovery:As can be seen above, the correct URL scheme to download the module should be:
https://repo.example.com/artifactory/api/terraform/v1/modules/
rather than
https://repo.example.com/v1/modules/
Trivy used.Trivy should preferrably utilize the same discovery mechanism that Terraform CLI does:
DiscoverServiceUrl method from terraform-svchost package
Terraform CLI code for endpoints discovery
Operating System
MacOs 14
Version
2024-11-21T19:34:40+01:00 INFO Loaded file_path="trivy.yaml" Version: 0.57.0 Check Bundle: Digest: sha256:b381d8e123c2568845a65f751635033051b076e66c460ab0037b4084845c19de DownloadedAt: 2024-11-21 08:44:39.470903 +0000 UTC
Checklist
trivy clean --all
Beta Was this translation helpful? Give feedback.
All reactions