shell

package
v1.10.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCommandNotAllowed = errors.New("shell: command not in allowlist")

Functions

This section is empty.

Types

type Config

type Config struct {
	Allowlist []string // permitted base command names, e.g. ["ls","grep","cat"]
	WorkDir   string   // working directory; defaults to "."
}

type RunResult

type RunResult struct {
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
	ExitCode int    `json:"exit_code"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Service, error)

func (*Service) Run

func (s *Service) Run(ctx context.Context, command string, args []string) (RunResult, error)

Run executes command (looked up by base name from PATH) only if it is in the allowlist. A non-zero exit code is surfaced in RunResult, not as an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL