Documentation
¶
Overview ¶
Package isobox runs a command inside the host's native sandbox, behind one interface. On macOS it compiles to a Seatbelt (sandbox-exec) profile; on Linux it compiles to a gVisor (runsc) invocation; on Windows it launches directly inside an AppContainer.
The backends do not enforce the same things. isobox models this explicitly as a capability set per backend, so callers can target either the portable Intersection (behaves identically everywhere) or opt into a backend's Union extras and accept documented, queryable caveats.
Index ¶
- type Backend
- type Capability
- type CapabilitySet
- func (s CapabilitySet) Has(c Capability) bool
- func (s CapabilitySet) Intersect(other CapabilitySet) CapabilitySet
- func (s CapabilitySet) Len() int
- func (s CapabilitySet) List() []Capability
- func (s CapabilitySet) Sub(other CapabilitySet) CapabilitySet
- func (s CapabilitySet) Union(other CapabilitySet) CapabilitySet
- type NetMode
- type Plan
- type Runner
- type Spec
- type Stdio
- type WriteMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend string
Backend identifies a sandbox implementation.
const ( // BackendSeatbelt is macOS Seatbelt via sandbox-exec. BackendSeatbelt Backend = "seatbelt" // BackendGvisor is Linux gVisor via runsc. BackendGvisor Backend = "gvisor" // BackendAppContainer is Windows AppContainer via in-process Win32 calls. BackendAppContainer Backend = "appcontainer" // BackendDockerEphemeral is Docker run --rm with no host mounts and a // disposable, read-only container filesystem plus tmpfs scratch. BackendDockerEphemeral Backend = "docker-ephemeral" )
type Capability ¶
type Capability string
Capability is a single, named sandboxing guarantee. A backend either supports it or it does not; this is what Union and Intersection are computed over.
const ( // CapNetDisable denies external/non-local network access. CapNetDisable Capability = "net.disable" // CapNetEnable permits network access. CapNetEnable Capability = "net.enable" // CapNetOutbound permits outbound connections but blocks listening/inbound. CapNetOutbound Capability = "net.outbound" // CapFSReadHost grants broad read access to the host filesystem. CapFSReadHost Capability = "fs.read.host" // CapFSReadScope restricts reads to an explicit allowlist. CapFSReadScope Capability = "fs.read.scope" // CapFSReadDeny grants broad reads while denying listed sensitive paths. CapFSReadDeny Capability = "fs.read.deny" // CapFSWriteDeny denies all writes to the host filesystem. CapFSWriteDeny Capability = "fs.write.deny" // CapFSWriteScope permits writes only to listed paths, persisting to the host. CapFSWriteScope Capability = "fs.write.scope" // CapFSWriteEphemeral permits writes while arranging for them to be // discarded; the host filesystem is never modified. CapFSWriteEphemeral Capability = "fs.write.ephemeral" // CapProcNoExec forbids creating a new program image after launch. CapProcNoExec Capability = "proc.no_exec" // CapKernelIsolation serves syscalls from a user-space kernel, shielding the // host kernel from the sandboxed process (reduced kernel attack surface). CapKernelIsolation Capability = "kernel.isolation" // CapIPCRestrict prevents access to host local IPC endpoints. CapIPCRestrict Capability = "ipc.restrict" // CapMachRestrict is a Seatbelt-only, macOS-specific Mach lookup restriction. CapMachRestrict Capability = "mach.restrict" // CapResCPU caps CPU usage at a fraction of the host's logical cores. CapResCPU Capability = "res.cpu" // CapResMemory caps the sandbox's memory footprint in bytes. CapResMemory Capability = "res.memory" )
func (Capability) Describe ¶
func (c Capability) Describe() string
Describe returns a human-readable description of a capability.
type CapabilitySet ¶
type CapabilitySet struct {
// contains filtered or unexported fields
}
CapabilitySet is an unordered set of capabilities with set algebra. The zero value is not usable; construct with NewCapabilitySet.
func CapsOf ¶
func CapsOf(b Backend) CapabilitySet
CapsOf returns the capability set for a backend. The returned set is a copy.
func Intersection ¶
func Intersection() CapabilitySet
Intersection returns capabilities supported by every backend. A spec built only from these behaves identically on all platforms.
func NewCapabilitySet ¶
func NewCapabilitySet(caps ...Capability) CapabilitySet
NewCapabilitySet builds a set from the given capabilities.
func Union ¶
func Union() CapabilitySet
Union returns capabilities supported by at least one backend.
func (CapabilitySet) Has ¶
func (s CapabilitySet) Has(c Capability) bool
Has reports whether the set contains c.
func (CapabilitySet) Intersect ¶
func (s CapabilitySet) Intersect(other CapabilitySet) CapabilitySet
Intersect returns the capabilities present in both sets.
func (CapabilitySet) Len ¶
func (s CapabilitySet) Len() int
Len reports the number of capabilities in the set.
func (CapabilitySet) List ¶
func (s CapabilitySet) List() []Capability
List returns the capabilities in sorted order for stable output.
func (CapabilitySet) Sub ¶
func (s CapabilitySet) Sub(other CapabilitySet) CapabilitySet
Sub returns the capabilities in s that are absent from other.
func (CapabilitySet) Union ¶
func (s CapabilitySet) Union(other CapabilitySet) CapabilitySet
Union returns the capabilities present in either set.
type NetMode ¶
type NetMode int
NetMode controls network access. The zero value denies external/non-local access.
type Plan ¶
type Plan struct {
// Backend is the implementation that will run the command.
Backend Backend
// Argv is the exact process isobox will exec (e.g. sandbox-exec ... or runsc ...).
Argv []string
// Profile is the generated Seatbelt SBPL profile, AppContainer preview text,
// or "" for backends that only have argv.
Profile string
// Uses is the set of capabilities this plan actually exercises.
Uses CapabilitySet
// Caveats records where the active backend deviates from the spec's intent
// (degraded or differently-enforced semantics). Empty means a faithful match.
Caveats []string
// contains filtered or unexported fields
}
Plan is the compiled, inspectable result of preparing a Spec for a backend. It is produced without running anything, so it can be unit-tested and shown to the user before execution.
func (*Plan) FilesystemVirtualization ¶
FilesystemVirtualization returns the planned filesystem virtualization mechanism, or "" when the plan uses no extra filesystem layer.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner compiles specs for one backend and runs them.
func NewBackend ¶
NewBackend returns a Runner for a specific backend regardless of host OS. This lets you compile and inspect a plan for a non-native backend (e.g. preview the Windows AppContainer grants from a Mac). Running it still requires the native backend to exist on the host.
func (*Runner) Capabilities ¶
func (r *Runner) Capabilities() CapabilitySet
Capabilities reports what this runner's backend can enforce.
type Spec ¶
type Spec struct {
// Args is the command and its arguments. Args[0] is the executable.
Args []string
// Dir is the working directory for the command. Empty inherits the caller's.
Dir string
// Env is the environment as KEY=VALUE entries. Nil inherits the caller's.
Env []string
// Net selects the network policy.
Net NetMode
// Write selects the filesystem write policy.
Write WriteMode
// Writable lists paths the sandbox may write when Write == WriteScope or
// Write == WriteOverlay.
Writable []string
// Readable, when non-empty, restricts reads to these paths (plus the
// minimum needed to load the executable). Empty grants broad host reads.
Readable []string
// ReadDeny lists sensitive paths to carve out of broad/scoped reads when a
// backend supports read deny rules.
ReadDeny []string
// NoExec forbids creating a new program image after the initial command
// starts. It does not forbid fork/clone without exec.
NoExec bool
// AllowTemp additionally permits writes to the OS temp dir when
// Write == WriteScope or Write == WriteOverlay. Many tools need a writable
// temp; it is opt-in except profiles may enable it.
AllowTemp bool
// MachAllow lists Mach service global-names the sandbox may look up despite
// the default Mach-lookup denial. It is a Seatbelt-only allowance
// (mach.restrict); other backends ignore it with a caveat. Use it
// for macOS programs that need directory services — for example
// "com.apple.system.opendirectoryd.libinfo" so getpwnam-based user lookup
// resolves names instead of falling back to raw uids.
MachAllow []string
// CPUs limits CPU usage to this many logical cores; fractional values are
// allowed (1.5 = one and a half cores). Zero means no CPU limit. Backends
// that cannot cap CPU report a caveat (and Strict rejects it).
CPUs float64
// MemoryBytes limits the sandbox's memory footprint, in bytes. Zero means
// no memory limit. Backends that cannot cap memory report a caveat (and
// Strict rejects it).
MemoryBytes int64
// Strict rejects any capability outside Intersection(), guaranteeing
// identical enforcement across backends instead of degrading per platform.
Strict bool
}
Spec is a backend-independent description of a confined command. Backends do not share the same capability set, so non-portable choices are reported as caveats, or rejected outright when Strict is set.
func (Spec) Capabilities ¶
func (s Spec) Capabilities() CapabilitySet
Capabilities returns the capability set this spec requests.
type Stdio ¶
Stdio wires the sandboxed process's standard streams. The zero value uses the caller's os.Stdin/Stdout/Stderr.
type WriteMode ¶
type WriteMode int
WriteMode controls filesystem writes. The zero value denies all writes.
const ( // WriteNone denies every write to the host filesystem. Zero value. WriteNone WriteMode = iota // WriteScope permits writes under Spec.Writable and optional temp roots. WriteScope // WriteEphemeral permits writes anywhere but discards them; host untouched. WriteEphemeral // WriteOverlay persists writes under Spec.Writable and optional temp roots, // while writes elsewhere are ephemeral when the backend can provide an // overlay/shadow filesystem and denied otherwise. WriteOverlay )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
isobox
command
Command isobox runs a command inside a host-native or portability-workaround sandbox backend: Seatbelt on macOS, gVisor on Linux, AppContainer on Windows, and optional ephemeral container backends where available.
|
Command isobox runs a command inside a host-native or portability-workaround sandbox backend: Seatbelt on macOS, gVisor on Linux, AppContainer on Windows, and optional ephemeral container backends where available. |
|
isobox-sshd
command
Command isobox-sshd launches an SSH server inside an isobox sandbox so you can ssh in and explore the confinement interactively, the way a remote user would.
|
Command isobox-sshd launches an SSH server inside an isobox sandbox so you can ssh in and explore the confinement interactively, the way a remote user would. |
|
isobox-testkit-client
command
|
|
|
isobox-testkit-host
command
|
|
|
internal
|
|
|
reslimit
Package reslimit parses human-friendly CPU and memory limit strings into the numeric values isobox.Spec expects.
|
Package reslimit parses human-friendly CPU and memory limit strings into the numeric values isobox.Spec expects. |