mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-15 18:45:33 +00:00
- 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
33 lines
680 B
Go
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:]...)
|
|
}
|