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
CapabilitySet
required
The capability set defining permitted operations.
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.
CapabilitySet
required
Capability set defining the child’s permitted filesystem and network access.
list[str]
required
Program and arguments to execute, for example
["python", "agent.py"].str | None
Working directory for the child process.
float | None
Maximum runtime in seconds. On timeout,
sandboxed_exec() kills the
sandboxed command’s process group and returns exit code 124.list[tuple[str, str]] | None
Explicit child environment variables. The parent environment is not inherited
unless
inherit_env=True.bool
If true, inherit the parent environment and apply
env as overrides.
Dynamic-loader environment variables such as LD_* and DYLD_* are rejected.int | None
Optional
RLIMIT_NPROC value for the child. This is a per-real-UID kernel
limit, not a per-sandbox process-tree limit.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.
start_proxy
ProxyConfig
required
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