sandbox

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sandbox limits filesystem effects of child commands.

Coverage is honest but partial by nature: Landlock does not mediate chmod, chown, xattr, utime, or fcntl metadata mutations, and old ABIs miss truncate. Enforcement is fail-closed: when the platform cannot sandbox, the wrapped command refuses to run (exit 126) with an actionable message instead of running unrestricted.

Index

Constants

View Source
const (
	EnvMode    = "ORB_SANDBOX_MODE"
	EnvRoot    = "ORB_SANDBOX_ROOT"
	EnvCommand = "ORB_SANDBOX_CMD"
	EnvSelf    = "ORB_SANDBOX_SELF"
	EnvShell   = "ORB_SANDBOX_SHELL"
)

Variables

This section is empty.

Functions

func SelfRestrict

func SelfRestrict(mode Mode, root string) error

SelfRestrict installs a Landlock ruleset on the calling OS thread and its children. The caller must hold runtime.LockOSThread and exec immediately after: Landlock and no_new_privs bind to the thread, not the process.

func Wrap

func Wrap(mode Mode, root, shell, command string, env map[string]string) (string, map[string]string)

Wrap replaces command without requoting it through the platform launcher. Both restrictive modes keep /dev and os.TempDir() writable so ordinary shell idioms (2>/dev/null, mktemp) work; workspace-write additionally opens root.

Types

type Mode

type Mode string
const (
	ModeReadOnly         Mode = "read-only"
	ModeWorkspaceWrite   Mode = "workspace-write"
	ModeDangerFullAccess Mode = "danger-full-access"
)

Jump to

Keyboard shortcuts

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