From bbc5a85444ec86b7bb26d6db27803d199431a8e6 Mon Sep 17 00:00:00 2001 From: Nikita Pivkin Date: Sat, 4 Jan 2025 00:51:40 +0600 Subject: [PATCH] fix(misconf): disable git terminal prompt on tf module load (#8026) Signed-off-by: nikpivkin --- pkg/iac/scanners/terraform/parser/resolvers/remote.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/iac/scanners/terraform/parser/resolvers/remote.go b/pkg/iac/scanners/terraform/parser/resolvers/remote.go index d70edde8c3b7..f23483b413bd 100644 --- a/pkg/iac/scanners/terraform/parser/resolvers/remote.go +++ b/pkg/iac/scanners/terraform/parser/resolvers/remote.go @@ -72,8 +72,6 @@ func (r *remoteResolver) download(ctx context.Context, opt Options, dst string) return err } - var opts []getter.ClientOption - // Overwrite the file getter so that a file will be copied getter.Getters["file"] = &getter.FileGetter{Copy: true} @@ -87,7 +85,13 @@ func (r *remoteResolver) download(ctx context.Context, opt Options, dst string) Pwd: opt.WorkingDir, Getters: getter.Getters, Mode: getter.ClientModeAny, - Options: opts, + } + + terminalPrompt := os.Getenv("GIT_TERMINAL_PROMPT") + if err := os.Setenv("GIT_TERMINAL_PROMPT", "0"); err != nil { + opt.Logger.Error("Failed to set env", log.String("name", "GIT_TERMINAL_PROMPT"), log.Err(err)) + } else { + defer os.Setenv("GIT_TERMINAL_PROMPT", terminalPrompt) } if err := client.Get(); err != nil {