nono_py module provides functions for applying sandboxes, starting the network proxy, and checking platform support.
It also provides policy-loading helpers for filesystem and network policy resolution.
apply
RuntimeError- Platform not supported or sandbox initialization failed
Example
Error Handling
is_supported
True if sandboxing is available.
Example
Platform Requirements
support_info
SupportInfo object with platform details.
Example
Detailed Platform Check
sandboxed_exec
caps.
Maximum runtime in seconds. On timeout,
sandboxed_exec() kills the
sandboxed command’s process group and returns exit code 124.Explicit child environment variables. The parent environment is not inherited
unless
inherit_env=True.If true, inherit the parent environment and apply
env as overrides.
Dynamic-loader environment variables such as LD_* and DYLD_* are rejected.Optional
RLIMIT_NPROC value for the child. This is a per-real-UID kernel
limit, not a per-sandbox process-tree limit.Linux rollout mode. For this compatibility release,
"auto" retains the
Landlock-first behavior. "seccomp" layers a static network baseline under
Landlock, denying UDP, raw/non-IP sockets, and io_uring_setup() for
restricted policies. "landlock" explicitly selects Landlock only.ExecResult with stdout, stderr, and exit_code.
Raises:
RuntimeError- Fork failed, sandbox setup failed, or command could not be executedValueError- Command is empty, timeout is negative, ormax_processesis zero
Example
Optional Process Limit
max_processes sets RLIMIT_NPROC before exec. Use it only when sandboxed
executions run under a dedicated Unix UID. The kernel counts every process
already owned by that UID, so on a normal shared user account a small value can
make the sandboxed program’s first fork() fail with EAGAIN instead of
providing a per-sandbox process budget.
pids.max, containers, or microVMs for reliable per-execution fork
limits.
Linux Static Seccomp Baseline
During this compatibility release, opt into the stronger network baseline withenforcement_mode="seccomp". Plain block_network() then denies non-Unix
sockets on every supported Linux kernel. Policies with TCP port exceptions use
Landlock V4+ for the port allowlist while seccomp denies UDP and other socket
families. The baseline also denies io_uring_setup(), including for workloads
that use io_uring only for file I/O. A future release will make this the
"auto" behavior.
start_proxy
Proxy configuration including allowed hosts, credential routes, and bind settings.
ProxyHandle with env_vars(), credential_env_vars(), drain_audit_events(), and shutdown().
Raises:
RuntimeError- Proxy failed to start (port in use, etc.)
Example
embedded_policy_json
Example
load_policy
Policy object.
Returns: Policy with group inspection and resolution helpers.
Raises:
ValueError- Invalid policy JSON, including unknown policy fields
Example
Policy.resolve_proxy_config() follows the same network field naming used by
the main nono profile format:
- Canonical key:
network.allow_domain - Accepted aliases:
network.allow_proxy,network.proxy_allow
upstream_proxy / external_proxy
values, resolution fails with ValueError instead of silently overwriting the
earlier proxy.
Policy JSON is parsed strictly. Unknown fields are rejected instead of being
ignored.
When resolving groups with proxy-filtered network policy, resolve_groups()
fails closed by blocking direct network access. After starting the proxy, call
caps.proxy_only(proxy) and pass proxy.sandbox_env() to sandboxed_exec().
load_embedded_policy
Policy.
Example
Import
All functions are available from the top-level module:Related
- CapabilitySet - Build capabilities to pass to
apply() - ProxyConfig - Configure the network proxy
- SnapshotManager - Filesystem snapshots and rollback
- SupportInfo - Returned by
support_info() - QueryContext - Check permissions without applying