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
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
FileNotFoundError- Path does not existValueError- Path is not a file
block_network
Network is allowed by default. Call
block_network() to restrict it.
On Linux during the compatibility release, use
sandboxed_exec(..., enforcement_mode="seccomp") to add the static filter that
also denies UDP, raw/non-IP sockets, and io_uring_setup(). The default
"auto" mode remains Landlock-first for one release.proxy_only
start_proxy() to allow filtered network access through the proxy while blocking all direct connections.
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
ValueError- Rule is malformed or grants dangerous access (e.g., root access)
deduplicate
path_covered
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