bwrap

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package bwrap provides a sandbox runtime implementation using bubblewrap (bwrap). On Linux, it uses bwrap for actual process isolation. On other systems (macOS, Windows), it falls back to a local process executor for development/testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBwrapAvailable

func IsBwrapAvailable() bool

IsBwrapAvailable checks if bwrap is available on the system.

Types

type BwrapRuntime

type BwrapRuntime struct {
	// contains filtered or unexported fields
}

BwrapRuntime implements runtime.RuntimeWithExecutor using bubblewrap.

func New

func New(config *Config) *BwrapRuntime

New creates a new BwrapRuntime with the given configuration.

func (*BwrapRuntime) Create

func (r *BwrapRuntime) Create(ctx context.Context, config *rt.SandboxConfig) (*types.Sandbox, error)

Create creates a new sandbox but does not start it.

func (*BwrapRuntime) CreateSession

func (r *BwrapRuntime) CreateSession(ctx context.Context, sandboxID string, config *types.SessionConfig) (*types.Session, error)

CreateSession creates a new shell session within a sandbox.

func (*BwrapRuntime) Destroy

func (r *BwrapRuntime) Destroy(ctx context.Context, sandboxID string) error

Destroy destroys a sandbox, releasing all resources.

func (*BwrapRuntime) DestroySession

func (r *BwrapRuntime) DestroySession(ctx context.Context, sessionID string) error

DestroySession destroys a session and kills all its child processes.

func (*BwrapRuntime) Exec

func (r *BwrapRuntime) Exec(ctx context.Context, sandboxID string, req *types.ExecRequest) (*types.ExecResult, error)

Exec executes a command in the sandbox and returns the result.

func (*BwrapRuntime) ExecStream

func (r *BwrapRuntime) ExecStream(ctx context.Context, sandboxID string, req *types.ExecRequest, output chan<- []byte) error

ExecStream executes a command and streams output.

func (*BwrapRuntime) Get

func (r *BwrapRuntime) Get(ctx context.Context, sandboxID string) (*types.Sandbox, error)

Get retrieves information about a sandbox.

func (*BwrapRuntime) GetSession

func (r *BwrapRuntime) GetSession(ctx context.Context, sessionID string) (*types.Session, error)

GetSession retrieves information about a session.

func (*BwrapRuntime) List

func (r *BwrapRuntime) List(ctx context.Context) ([]*types.Sandbox, error)

List returns all sandboxes managed by this runtime.

func (*BwrapRuntime) ListSessions

func (r *BwrapRuntime) ListSessions(ctx context.Context, sandboxID string) ([]*types.Session, error)

ListSessions returns all sessions for a sandbox.

func (*BwrapRuntime) Name

func (r *BwrapRuntime) Name() string

Name returns the name of this runtime implementation.

func (*BwrapRuntime) SessionExec

func (r *BwrapRuntime) SessionExec(ctx context.Context, sessionID string, req *types.SessionExecRequest) (*types.ExecResult, error)

SessionExec executes a command within a session, preserving state.

func (*BwrapRuntime) SessionExecStream

func (r *BwrapRuntime) SessionExecStream(ctx context.Context, sessionID string, req *types.SessionExecRequest, output chan<- []byte) error

SessionExecStream executes a command within a session and streams output.

func (*BwrapRuntime) Start

func (r *BwrapRuntime) Start(ctx context.Context, sandboxID string) error

Start starts a previously created sandbox.

func (*BwrapRuntime) Stop

func (r *BwrapRuntime) Stop(ctx context.Context, sandboxID string) error

Stop stops a running sandbox without destroying it.

type Config

type Config struct {
	// BwrapPath is the path to the bwrap binary (default: "bwrap")
	BwrapPath string

	// DefaultTimeout is the default timeout for operations
	DefaultTimeout time.Duration

	// WorkDir is the base directory for sandbox working directories
	WorkDir string

	// FUSEMountBase is the base directory for FUSE mount points
	FUSEMountBase string

	// EnableNetworking allows network access in sandboxes
	EnableNetworking bool
}

Config holds configuration for the BwrapRuntime.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults.

Jump to

Keyboard shortcuts

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