Files
OliveTin/service/internal/executor/executor_windows.go
jamesread d020eb06fe feature: Exec array support for safer command execution
- Add Exec []string field to Action struct for direct execution
- Support exec arrays that execute commands without shell wrapping
- Add shell argument safety validation to prevent unsafe argument types
- Block URL, email, raw_string_multiline with Shell execution
- Direct exec execution is preferred over Shell for better security
- Backport of exec-feature to release/2k
2025-10-26 16:48:34 +00:00

33 lines
680 B
Go

//go:build windows
// +build windows
package executor
import (
"context"
"os"
"os/exec"
)
func (e *Executor) Kill(execReq *InternalLogEntry) error {
return execReq.Process.Kill()
}
func wrapCommandInShell(ctx context.Context, finalParsedCommand string) *exec.Cmd {
winCodepage := os.Getenv("OT_WIN_FLAG_U")
if winCodepage == "0" {
return exec.CommandContext(ctx, "cmd", "/C", finalParsedCommand)
} else {
return exec.CommandContext(ctx, "cmd", "/u", "/C", finalParsedCommand)
}
}
func wrapCommandDirect(ctx context.Context, execArgs []string) *exec.Cmd {
if len(execArgs) == 0 {
return nil
}
return exec.CommandContext(ctx, execArgs[0], execArgs[1:]...)
}