From cb081348fae55ed2dc4ef1e0b711b997e51c0f29 Mon Sep 17 00:00:00 2001 From: Abhisek Datta Date: Thu, 8 Jan 2026 16:35:22 +0530 Subject: [PATCH] fix: Misc cleanup fixes --- guard/guard.go | 7 ++----- internal/flows/proxy_flow.go | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/guard/guard.go b/guard/guard.go index fc85608..1f578aa 100644 --- a/guard/guard.go +++ b/guard/guard.go @@ -221,18 +221,15 @@ func (g *packageManagerGuard) continueExecution(ctx context.Context, pc *package cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - // Apply sandbox if enabled pmName := g.packageManager.Name() result, err := executor.ApplySandbox(ctx, cmd, pmName) if err != nil { return fmt.Errorf("failed to apply sandbox: %w", err) } - defer result.Close() // Clean up sandbox resources - // Only run the command if the sandbox didn't already execute it + defer result.Close() + if result.ShouldRun() { - // We will fail based on executed command's exit code. This is important - // because other tools (scripts, CI etc.) may depend on this exit code. return cmd.Run() } diff --git a/internal/flows/proxy_flow.go b/internal/flows/proxy_flow.go index 917ef10..208a411 100644 --- a/internal/flows/proxy_flow.go +++ b/internal/flows/proxy_flow.go @@ -242,13 +242,13 @@ func (f *proxyFlow) executeWithProxy(ctx context.Context, parsedCmd *packagemana cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - // Apply sandbox if enabled (sandbox preserves proxy environment variables already set on cmd.Env) pmName := f.pm.Name() result, err := executor.ApplySandbox(ctx, cmd, pmName) if err != nil { return fmt.Errorf("failed to apply sandbox: %w", err) } - defer result.Close() // Clean up sandbox resources + + defer result.Close() log.Debugf("Executing command: %s %v", parsedCmd.Command.Exe, parsedCmd.Command.Args) log.Debugf("Proxy environment: HTTP_PROXY=%s, HTTPS_PROXY=%s, NODE_EXTRA_CA_CERTS=%s", proxyURL, proxyURL, caCertPath)