Help us shape the future of Go! Take the 2026 Go Developer Survey

sandbox

package
v0.13.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sandbox confines agent-selected commands with Landlock. The worker re-executes itself with a landlock-exec subcommand, which calls Restrict and then execs the real program, because Go cannot run code between fork and exec.

On macOS, Seatbelt (sandbox-exec) provides the equivalent confinement for the opt-in "seatbelt" execution isolation mode; see seatbelt.go.

Index

Constants

View Source
const SeatbeltExecutable = "/usr/bin/sandbox-exec"

SeatbeltExecutable is the macOS tool that applies a Seatbelt profile and execs the confined program.

Variables

This section is empty.

Functions

func ABI

func ABI() (int, error)

ABI reports the Landlock ABI version of the running kernel, or 0 when the kernel does not support Landlock or it is disabled.

func Restrict

func Restrict(runRoot string) error

Restrict confines the calling thread to the system toolchain paths plus full access under runRoot. It is irreversible and inherited across exec, so call it from the thread that will exec the confined program.

func RestrictWithPaths

func RestrictWithPaths(runRoot string, readExecPaths, readWritePaths []string) error

RestrictWithPaths additionally grants full access to operator-selected writable state directories. Both path lists must come from trusted runtime configuration, never agent-controlled command arguments.

func RestrictWithReadExec

func RestrictWithReadExec(runRoot string, readExecPaths []string) error

RestrictWithReadExec confines the calling thread like Restrict and grants read/execute access to operator-selected toolchain paths. The caller must derive these paths from the worker environment, never agent input.

func RunExec added in v0.13.16

func RunExec(args []string) int

runLandlockExec confines this process to the run root and replaces it with the requested program. The parent already prepared the environment.

func SeatbeltArgs added in v0.13.8

func SeatbeltArgs(paths SeatbeltPaths, program string, args []string) ([]string, error)

SeatbeltArgs returns sandbox-exec arguments that confine program to the given paths. The caller runs SeatbeltExecutable with these arguments.

func SeatbeltAvailable added in v0.13.8

func SeatbeltAvailable() error

SeatbeltAvailable fails off macOS: Seatbelt is a macOS mechanism.

Types

type SeatbeltPaths added in v0.13.8

type SeatbeltPaths struct {
	// Root receives full access, like the Landlock run root.
	Root string
	// ReadWrite are additional trusted state and cache directories.
	ReadWrite []string
	// DenyRead are directories the command must not read, such as secrets.
	DenyRead []string
}

SeatbeltPaths are the trusted paths a Seatbelt-confined command may use. Every path must come from runtime configuration, never agent input.

Jump to

Keyboard shortcuts

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