From 87f375117212a99afae9b93bdd69c48c8edb2a8e Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Thu, 30 Jan 2025 00:53:07 -0600 Subject: [PATCH] chore(terraform): add accessors to underlying raw hcl values (#8306) --- pkg/iac/scanners/terraform/parser/parser.go | 4 ++++ pkg/iac/terraform/attribute.go | 4 ++++ pkg/iac/terraform/block.go | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/pkg/iac/scanners/terraform/parser/parser.go b/pkg/iac/scanners/terraform/parser/parser.go index 48ed799155ea..3427fa08f72f 100644 --- a/pkg/iac/scanners/terraform/parser/parser.go +++ b/pkg/iac/scanners/terraform/parser/parser.go @@ -90,6 +90,10 @@ func (p *Parser) newModuleParser(moduleFS fs.FS, moduleSource, modulePath, modul return mp } +func (p *Parser) Files() map[string]*hcl.File { + return p.underlying.Files() +} + func (p *Parser) ParseFile(_ context.Context, fullPath string) error { isJSON := strings.HasSuffix(fullPath, ".tf.json") diff --git a/pkg/iac/terraform/attribute.go b/pkg/iac/terraform/attribute.go index 9c5536357283..8462492fce05 100644 --- a/pkg/iac/terraform/attribute.go +++ b/pkg/iac/terraform/attribute.go @@ -61,6 +61,10 @@ func NewAttribute(attr *hcl.Attribute, ctx *context.Context, module string, pare } } +func (a *Attribute) HCLAttribute() *hcl.Attribute { + return a.hclAttribute +} + func (a *Attribute) GetMetadata() iacTypes.Metadata { return a.metadata } diff --git a/pkg/iac/terraform/block.go b/pkg/iac/terraform/block.go index 4e9f794e914c..e88cf14de4fe 100644 --- a/pkg/iac/terraform/block.go +++ b/pkg/iac/terraform/block.go @@ -123,6 +123,10 @@ func NewBlock(hclBlock *hcl.Block, ctx *context.Context, moduleBlock *Block, par return &b } +func (b *Block) HCLBlock() *hcl.Block { + return b.hclBlock +} + func (b *Block) ID() string { return b.id }