sandbox

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sandbox provides Landlock LSM filesystem sandboxing for process isolation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAvailable

func IsAvailable() bool

IsAvailable reports whether the kernel supports Landlock.

Types

type Sandbox

type Sandbox struct {
	ReadOnly  types
	ReadWrite types

	// WorkDir is the effective working directory, used in String() for display.
	WorkDir string
	// contains filtered or unexported fields
}

Sandbox defines the set of filesystem paths and their access levels for Landlock enforcement.

func (*Sandbox) AddReadOnly

func (s *Sandbox) AddReadOnly(paths ...string)

AddReadOnly registers paths for read-only access within the sandbox.

func (*Sandbox) AddReadWrite

func (s *Sandbox) AddReadWrite(paths ...string)

AddReadWrite registers paths for read-write access within the sandbox.

func (*Sandbox) Apply

func (s *Sandbox) Apply() error

Apply enforces the sandbox by applying all registered Landlock rules.

func (*Sandbox) CanRead

func (s *Sandbox) CanRead(path string) bool

CanRead reports whether the given path falls within any configured read-only or read-write path. Checks against the full declared intent, including non-existent paths.

func (*Sandbox) CanWrite

func (s *Sandbox) CanWrite(path string) bool

CanWrite reports whether the given path falls within any configured read-write path. Checks against the full declared intent, including non-existent paths.

func (*Sandbox) HasRules

func (s *Sandbox) HasRules() bool

HasRules reports whether any read or write rules have been registered.

func (*Sandbox) NumberOfRules

func (s *Sandbox) NumberOfRules() int

NumberOfRules returns the total number of registered read and write rules.

func (*Sandbox) String

func (s *Sandbox) String(omitReadOnly ...bool) string

String returns a human-readable summary of the sandbox restrictions.

Jump to

Keyboard shortcuts

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