sandbox

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sandbox confines the commands the agent runs.

The agent has a shell. On a machine that also holds your files, your keys, and your network, that is a lot of reach for something driven by a model following instructions from a web page it just read.

Nothing here needs root. It uses what an unprivileged user already has: bubblewrap when installed, and Linux user namespaces when not. Where neither is available it says so rather than pretending — a sandbox you believe in but do not have is worse than none.

Index

Constants

This section is empty.

Variables

View Source
var DefaultHidden = []string{
	"~/.ssh",
	"~/.aws",
	"~/.gnupg",
	"~/.config/gh",
	"~/.antares/.env",
	"~/.kube",
	"~/.docker/config.json",
}

DefaultHidden is what stays out of a sandbox unless someone says otherwise. These are the paths an agent has no business reading, and the ones an injected instruction would go for first.

Functions

func Command

func Command(mode Mode, p Policy, name string, args ...string) (*exec.Cmd, error)

Command builds an exec.Cmd that runs the given program confined.

The returned command is ready to start; the caller still sets Dir, Env, and the pipes.

func Describe

func Describe(mode Mode, p Policy) string

Describe explains in one sentence what a mode actually does, for the places that have to tell a person what protection they have.

Types

type Mode

type Mode string

Mode names how much confinement to apply.

const (
	// None runs commands directly.
	None Mode = "none"
	// Auto picks the strongest mechanism available and falls back quietly.
	Auto Mode = "auto"
	// Bubblewrap confines filesystem and network. Needs bwrap installed.
	Bubblewrap Mode = "bubblewrap"
	// Namespace blocks the network with a user namespace. Needs no tools, but
	// leaves the filesystem alone.
	Namespace Mode = "namespace"
)

func Available

func Available() []Mode

Available reports which mechanisms this machine can actually use.

func Resolve

func Resolve(mode Mode) (Mode, string)

Resolve turns a configured mode into one that will work here, and explains the choice. An unavailable mode falls back rather than failing: refusing to run commands because a sandbox is missing helps nobody.

type Policy

type Policy struct {
	// Workspace is writable. Everything else is read-only under bubblewrap.
	Workspace string
	// AllowNetwork leaves the network reachable. Off means no network at all,
	// not a filtered one.
	AllowNetwork bool
	// ReadOnly adds paths the command may read but not change.
	ReadOnly []string
	// Hidden names paths to keep out of the sandbox entirely — credentials,
	// mostly.
	Hidden []string
}

Policy is what a confined command may reach.

Jump to

Keyboard shortcuts

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