Documentation
¶
Index ¶
Constants ¶
const ( // DefaultTimeout is the default command execution timeout DefaultTimeout = 2 * time.Minute // MaxTimeout is the maximum allowed timeout MaxTimeout = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command represents a safe command configuration
type Executor ¶
type Executor interface {
// Command creates a new exec.Cmd instance for the given command and arguments.
Command(name string, args ...string) *exec.Cmd
// CommandContext creates a new context-aware exec.Cmd instance.
CommandContext(ctx context.Context, name string, args ...string) *exec.Cmd
}
Executor creates exec.Cmd instances. This abstraction allows for dependency injection, enabling test-specific command creation logic (e.g., setting up a PATH with mock binaries) without modifying production code.
type RealExecutor ¶
type RealExecutor struct{}
RealExecutor is the production implementation of the Executor interface, which uses the standard os/exec package to create commands.
func (*RealExecutor) Command ¶
func (e *RealExecutor) Command(name string, args ...string) *exec.Cmd
Command creates a standard exec.Cmd.
func (*RealExecutor) CommandContext ¶
CommandContext creates a standard context-aware exec.Cmd.
type SafeBuilder ¶
type SafeBuilder struct {
// contains filtered or unexported fields
}
SafeBuilder provides secure command execution with validation
func NewSafeBuilder ¶
func NewSafeBuilder() *SafeBuilder
NewSafeBuilder creates a new SafeBuilder instance with a RealExecutor
func NewSafeBuilderWithExecutor ¶
func NewSafeBuilderWithExecutor(exec Executor) *SafeBuilder
NewSafeBuilderWithExecutor creates a new SafeBuilder with a custom Executor