safedep / vet

Tool to achieve policy driven vetting of open source dependencies
https://safedep.io
Apache License 2.0
237 stars 23 forks source link

Add Support for Terraform Modules in Terraform Parser #271

Open abhisek opened 2 weeks ago

abhisek commented 2 weeks ago

The current terraform parser supports parsing .terraform.lock.hcl to extract Terraform Providers. We need to extend it to be able to collect Terraform modules as well.

See following for more details: https://github.com/safedep/vet/blob/main/pkg/parser/terraform.go

Once this support is added, vet should be able to identify a Terraform module using its internal package model. Refer models/models.go.

Handling module is not straight forward because

At present, the dependency lock file tracks only provider dependencies.

https://developer.hashicorp.com/terraform/language/files/dependency-lock

So we have a few options:

Example module definition:

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = "20.28.0"
}

We are interested only in remote modules i.e. those that do not start with . or .. Read module about module sources at: https://developer.hashicorp.com/terraform/language/modules/sources