Documentation
¶
Index ¶
- func ContextWithGitAccess(ctx context.Context, allowed bool) context.Context
- func FormatSandboxInfo(s Sandbox) string
- func GitAccessFromContext(ctx context.Context) bool
- func GitAccessRequired(command, workDir string) bool
- func IsGitDeniedPath(path string) bool
- type AvailabilityErrorProvider
- type BwrapCapabilities
- type BwrapSandbox
- func (s *BwrapSandbox) AvailabilityError() error
- func (s *BwrapSandbox) IsAvailable() bool
- func (s *BwrapSandbox) Level() Level
- func (s *BwrapSandbox) Name() string
- func (s *BwrapSandbox) WrapCommand(ctx context.Context, shell, cmd string, opts ExecOpts) *exec.Cmd
- func (s *BwrapSandbox) WrapCommandWithGitAccess(ctx context.Context, shell, cmd string, opts ExecOpts) *exec.Cmd
- type CommandCleanupProvider
- type ExecOpts
- type GitAccessSandbox
- type Level
- type Manager
- type NoneSandbox
- type Options
- type Sandbox
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithGitAccess ¶
func FormatSandboxInfo ¶
FormatSandboxInfo returns a human-readable description of the sandbox state.
func GitAccessFromContext ¶
func GitAccessRequired ¶
GitAccessRequired conservatively identifies commands that may access Git metadata. It is only an approval hint; the sandbox deny rule remains the actual enforcement boundary.
func IsGitDeniedPath ¶
Types ¶
type AvailabilityErrorProvider ¶
type AvailabilityErrorProvider interface {
AvailabilityError() error
}
type BwrapCapabilities ¶
type BwrapCapabilities struct {
NewSession bool
DieWithParent bool
MountProc bool
MountDev bool
MountTmpfs bool
TmpfsSize bool
MountBind bool
ChangeDir bool
Hostname bool
}
BwrapCapabilities describes the flags and runtime features required by MothX.
type BwrapSandbox ¶
type BwrapSandbox struct {
// contains filtered or unexported fields
}
BwrapSandbox implements sandbox using bubblewrap (bwrap).
func NewBwrapSandbox ¶
func NewBwrapSandbox(projectDir string, level Level) *BwrapSandbox
NewBwrapSandbox creates a new bubblewrap sandbox.
func NewBwrapSandboxWithOptions ¶
func NewBwrapSandboxWithOptions(projectDir string, level Level, opts Options) *BwrapSandbox
NewBwrapSandboxWithOptions creates a bubblewrap sandbox with a policy.
func (*BwrapSandbox) AvailabilityError ¶
func (s *BwrapSandbox) AvailabilityError() error
AvailabilityError explains why bwrap could not be used.
func (*BwrapSandbox) IsAvailable ¶
func (s *BwrapSandbox) IsAvailable() bool
IsAvailable checks if bwrap is available on this system.
func (*BwrapSandbox) WrapCommand ¶
WrapCommand wraps a command for execution inside bubblewrap.
func (*BwrapSandbox) WrapCommandWithGitAccess ¶
func (s *BwrapSandbox) WrapCommandWithGitAccess(ctx context.Context, shell, cmd string, opts ExecOpts) *exec.Cmd
WrapCommandWithGitAccess runs one command with the protected .git deny carveout removed. The sandbox instance itself is immutable; only this prepared command receives the temporary transform.
type CommandCleanupProvider ¶
type ExecOpts ¶
type ExecOpts struct {
WritablePaths []string // Additional writable paths
ReadOnlyPaths []string // Additional read-only paths (for standard mode)
NetworkAccess bool // Deprecated: sandbox preserves host network access
EnvVars map[string]string // Additional environment variables
WorkDir string // Working directory
Timeout time.Duration // Command timeout
}
ExecOpts contains options for executing a command in a sandbox.
type GitAccessSandbox ¶
type GitAccessSandbox interface {
WrapCommandWithGitAccess(ctx context.Context, shell, cmd string, opts ExecOpts) *exec.Cmd
}
GitAccessSandbox is implemented by backends that can temporarily remove the protected Git deny rule for exactly one command.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages sandbox selection based on mode and availability.
func NewManager ¶
NewManager creates a manager with the default sandbox policy.
func NewManagerWithOptions ¶
NewManagerWithOptions creates a manager using the supplied sandbox policy.
func (*Manager) FallbackError ¶
FallbackError reports why a best-effort sandbox fell back to direct execution.
func (*Manager) GetForLevel ¶
GetForLevel returns the sandbox for a specific level, checking availability.
type NoneSandbox ¶
type NoneSandbox struct{}
NoneSandbox executes commands without any sandbox restrictions.
func NewNoneSandbox ¶
func NewNoneSandbox() *NoneSandbox
NewNoneSandbox creates a new no-op sandbox.
func (*NoneSandbox) IsAvailable ¶
func (s *NoneSandbox) IsAvailable() bool
IsAvailable always returns true.
func (*NoneSandbox) WrapCommand ¶
WrapCommand returns a plain command without any sandbox restrictions. It inherits the full parent environment and overlays opts.EnvVars on top.
type Options ¶
type Options struct {
BwrapPath string
AllowNetwork bool // Deprecated: sandbox always preserves host network access
AllowedRead []string
AllowedWrite []string
DeniedPaths []string
PassEnv []string
TmpSize string
ProtectGit bool
}
Options controls sandbox backends. It deliberately uses primitive values so callers from every runtime can share the same policy without importing config.
type Sandbox ¶
type Sandbox interface {
// WrapCommand wraps a command for execution inside the sandbox.
WrapCommand(ctx context.Context, shell, cmd string, opts ExecOpts) *exec.Cmd
// IsAvailable checks if the sandbox can be used on this system.
IsAvailable() bool
// Name returns the sandbox implementation name.
Name() string
// Level returns the sandbox level.
Level() Level
}
Sandbox is the interface for sandbox implementations.