sandbox

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Isolation Level
	Mounts    []Mount
	Deny      []string // paths to mask (e.g. ~/.ssh)
	Timeout   time.Duration
	CPULimit  time.Duration // RLIMIT_CPU (0 = backend default)
	MemLimit  uint64        // RLIMIT_AS in bytes (0 = backend default)
	MaxFDs    uint32        // RLIMIT_NOFILE (0 = backend default)
}

Config holds sandbox creation parameters.

type Level

type Level int

Level defines the isolation level for a sandbox.

const (
	Strict     Level = iota // No network, minimal fs, short TTL
	Standard                // No network, mounted dirs only
	Network                 // Network allowed, mounted dirs only
	Privileged              // Full access (for trusted skills)
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel converts a string to a Level.

func (Level) String

func (l Level) String() string

type Mount

type Mount struct {
	Source   string
	Target   string
	ReadOnly bool
}

Mount describes a filesystem mount for the sandbox.

type Sandbox

type Sandbox interface {
	Exec(ctx context.Context, name string, args []string) (*exec.Cmd, error)
	PostStart(pid int) error // apply rlimits etc. after process starts
	Destroy() error
}

Sandbox provides isolated execution of commands.

func New

func New(cfg Config) (Sandbox, error)

New creates a platform-appropriate sandbox. It tries platform-specific backends first (Apple Containers on macOS, namespaces on Linux) and falls back to process-level isolation.

Jump to

Keyboard shortcuts

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