fix: Merge conflicts

This commit is contained in:
Abhisek Datta
2026-01-12 12:34:57 +05:30
parent 51c68c4cc4
commit d48ba68847
3 changed files with 36 additions and 5 deletions
+1
View File
@@ -25,6 +25,7 @@ require (
go.yaml.in/yaml/v3 v3.0.4
golang.org/x/term v0.34.0
google.golang.org/grpc v1.72.0
gopkg.in/yaml.v3 v3.0.1
)
require (
+31 -1
View File
@@ -270,8 +270,17 @@ func (f *proxyFlow) executeWithProxyForNonInteractiveTTY(
nil,
)
result, err := executor.ApplySandbox(ctx, cmd, f.pm.Name())
if err != nil {
return fmt.Errorf("failed to apply sandbox: %w", err)
}
defer result.Close()
// Only run the command if the sandbox didn't already execute it
if result.ShouldRun() {
log.Debugf("Running command with args: %s: %v", cmd.Path, cmd.Args[1:])
err = cmd.Run()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
@@ -302,7 +311,27 @@ func (f *proxyFlow) executeWithProxy(
return ui.GetConfirmationOnMalwareWithReader(malwarePackages, interaction.Reader())
}
sessionConfig := pty.NewSessionConfig(parsedCmd.Command.Exe, parsedCmd.Command.Args, env)
cmd := exec.CommandContext(ctx, parsedCmd.Command.Exe, parsedCmd.Command.Args...)
result, err := executor.ApplySandbox(ctx, cmd, f.pm.Name())
if err != nil {
return fmt.Errorf("failed to apply sandbox: %w", err)
}
if !result.ShouldRun() {
return fmt.Errorf("sandbox executed command cannot be used with PTY session. Please use non-interactive TTY mode instead.")
}
// Extract the command executable and arguments from the sandboxed command
// for use to create the PTY session.
cmdExe := cmd.Path
cmdArgs := cmd.Args[1:]
log.Debugf("Running command with args: %s: %v", cmdExe, cmdArgs)
// Create the PTY session with the sandbox command
// This is not compatible with sandbox that executes the command directly within the sandbox
// because internally we use ptyx.Spawn() to create the process with PTY support.
sessionConfig := pty.NewSessionConfig(cmdExe, cmdArgs, env)
sess, err := pty.NewSession(ctx, sessionConfig)
if err != nil {
@@ -399,6 +428,7 @@ func (f *proxyFlow) executeWithProxy(
os.Exit(exitErr.Code)
}
return err
}
+4 -4
View File
@@ -34,15 +34,15 @@ func WithSandbox(sb sandbox.Sandbox) applySandboxOpt {
func ApplySandbox(ctx context.Context, cmd *exec.Cmd, pmName string, opts ...applySandboxOpt) (*sandbox.ExecutionResult, error) {
cfg := config.Get()
if !cfg.Config.Sandbox.Enabled {
return sandbox.NewExecutionResult(), nil
}
applyConfig := &applySandboxConfig{}
for _, opt := range opts {
opt(applyConfig)
}
if !cfg.Config.Sandbox.Enabled {
return sandbox.NewExecutionResult(), nil
}
registry, err := sandbox.NewProfileRegistry()
if err != nil {
return nil, fmt.Errorf("failed to create profile registry: %w", err)