CapabilitySet is the core class for defining what a sandboxed process can access. It collects filesystem capabilities, network settings, and command filters before applying the sandbox.
Constructor
Methods
allow_path
str
required
Path to the directory. Must exist and be a directory.
AccessMode
required
Access level to grant:
READ, WRITE, or READ_WRITE.FileNotFoundError- Path does not existValueError- Path is not a directory
The path is canonicalized (symlinks resolved) when added. On macOS,
/tmp becomes /private/tmp.allow_file
str
required
Path to the file. Must exist and be a regular file.
AccessMode
required
Access level to grant:
READ, WRITE, or READ_WRITE.FileNotFoundError- Path does not existValueError- Path is not a file
block_network
Network is allowed by default. Call
block_network() to restrict it.proxy_only
start_proxy() to allow filtered network access through the proxy while blocking all direct connections.
ProxyHandle
required
A running proxy handle from
start_proxy().proxy_only() and block_network() are mutually exclusive — calling one overrides the other. Use proxy_only() when you want filtered network access; use block_network() when you want no network at all.platform_rule
str
required
Platform-specific rule string.
ValueError- Rule is malformed or grants dangerous access (e.g., root access)
deduplicate
path_covered
str
required
Path to check.
True if the path would be accessible via an existing capability.
This checks against resolved/canonicalized paths. Use the resolved path from a capability for accurate results.
fs_capabilities
FsCapability objects.
summary
Properties
is_network_blocked
True if network access is blocked.
Related
- AccessMode - Access mode enum
- FsCapability - Filesystem capability details
- apply() - Apply the sandbox