Skip to main content

Python bindings for nono capability-based sandboxing

Project description

nono-py

Python bindings for nono, a capability-based sandboxing library.

nono provides OS-enforced sandboxing using Landlock (Linux) and Seatbelt (macOS). Once a sandbox is applied, unauthorized operations are structurally impossible.

Installation

pip install nono-py

From source

Requires Rust toolchain and maturin:

pip install maturin
maturin develop

Usage

from nono_py import CapabilitySet, AccessMode, apply, is_supported

# Check platform support
if not is_supported():
    print("Sandboxing not supported on this platform")
    exit(1)

# Build capability set
caps = CapabilitySet()
caps.allow_path("/tmp", AccessMode.READ_WRITE)
caps.allow_path("/home/user/project", AccessMode.READ)
caps.allow_file("/etc/hosts", AccessMode.READ)
caps.block_network()

# Apply sandbox (irreversible!)
apply(caps)

# Now the process can only access granted paths
# Network access is blocked
# This applies to all child processes too

API Reference

Sandboxing

CapabilitySet + apply()

Sandbox the current process (irreversible):

caps = CapabilitySet()
caps.allow_path("/tmp", AccessMode.READ_WRITE)
caps.block_network()
apply(caps)  # Process is now sandboxed

sandboxed_exec

Run a command in a sandboxed child process. The parent stays unsandboxed and can call this repeatedly with different capabilities:

caps = CapabilitySet()
caps.allow_path("/workspace", AccessMode.READ_WRITE)
caps.block_network()
result = sandboxed_exec(caps, ["python", "agent.py"], cwd="/workspace", timeout_secs=30.0)
print(result.stdout, result.exit_code)

Network Proxy

Domain-filtered network access for sandboxed children. The proxy intercepts outbound HTTP requests and enforces a host allowlist. For API calls, it performs credential injection: the sandboxed process sends a dummy token, and the proxy transparently swaps in the real API key (loaded from the OS keyring) before forwarding upstream. The sandboxed process never sees the real secret.

from nono_py import ProxyConfig, RouteConfig, start_proxy

config = ProxyConfig(
    allowed_hosts=["api.openai.com", "*.anthropic.com"],
    routes=[
        RouteConfig(prefix="/openai", upstream="https://api.openai.com", credential_key="openai-key"),
    ],
)
proxy = start_proxy(config)

# Inject proxy env vars into sandboxed child
env = list(proxy.env_vars().items()) + list(proxy.credential_env_vars().items())
result = sandboxed_exec(caps, ["python", "agent.py"], env=env)

# Audit trail
events = proxy.drain_audit_events()
proxy.shutdown()

Filesystem Snapshots

Content-addressable snapshots with Merkle-committed state and rollback:

from nono_py import SnapshotManager, ExclusionConfig

mgr = SnapshotManager(
    session_dir="~/.nono/rollbacks/session-001",
    tracked_paths=["/workspace"],
    exclusion=ExclusionConfig(exclude_patterns=["node_modules", "__pycache__"]),
)
mgr.create_baseline()

# ... agent runs and modifies files ...

manifest, changes = mgr.create_incremental()
for change in changes:
    print(f"{change.change_type}: {change.path}")

# Roll back
mgr.restore_to(snapshot_number=0)

Other Classes

  • QueryContext - Check permissions without applying the sandbox
  • SandboxState - Serialize/restore capability sets as JSON
  • SupportInfo - Platform support details
  • Policy - Load and resolve policy.json documents
  • SessionMetadata - Session audit trail with Merkle roots and network events

Functions

  • apply(caps) - Apply sandbox (irreversible)
  • sandboxed_exec(caps, command, ...) - Run command in sandboxed child
  • start_proxy(config) - Start network filtering proxy
  • is_supported() / support_info() - Platform support
  • load_policy(json) / load_embedded_policy() - Policy loading

Platform Support

Platform Backend Requirements
Linux Landlock Kernel 5.13+ with Landlock enabled
macOS Seatbelt macOS 10.5+
Windows - Not supported

Development

# Install dev dependencies
pip install maturin pytest mypy

# Build and install for development
make dev

# Run tests
make test

# Run linters
make lint

# Format code
make fmt

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nono_py-0.7.2.tar.gz (141.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nono_py-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

nono_py-0.7.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

nono_py-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

nono_py-0.7.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

nono_py-0.7.2-cp312-cp312-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nono_py-0.7.2-cp312-cp312-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

nono_py-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

nono_py-0.7.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

nono_py-0.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

nono_py-0.7.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

nono_py-0.7.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nono_py-0.7.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

Details for the file nono_py-0.7.2.tar.gz.

File metadata

  • Download URL: nono_py-0.7.2.tar.gz
  • Upload date:
  • Size: 141.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nono_py-0.7.2.tar.gz
Algorithm Hash digest
SHA256 56630b248736e627ecda59502b53abcc1f33d1630bd61923b8a2d2a62fb88500
MD5 d4cbecb18f6d4622617671344d62e92a
BLAKE2b-256 9672cb058917f14968f14c21c2c206a83aab38d9bfc3fefffee7898e6c6b0f5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2.tar.gz:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 50ae7416b491249ede918a1d54c79fcf0d714d4d4811985d6a8966c25249e21d
MD5 0d4a77de82a80ac23b05861b4200158c
BLAKE2b-256 74cb38f41f42fc5324674a9e074ce1599fc03118d83763b1257c2afc56339dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e199f41df5d07b1d1b7165ce20e6ebf71fc5fed6286823ead638cbfff48a13ac
MD5 5f1ef54efb04a5015128d743a24ee5ae
BLAKE2b-256 532d10c13f2ff7ecf2e9338fb8dad7f28f13ed568c02796f226afd9386a1b3a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f93cba0ed16466fff916dacb31c39b700c30585a2b696213be9d2cd1270ef4f
MD5 f0e835dc4543f30bc740c08b89ae27d4
BLAKE2b-256 29e567c98330050f46008c2af314bf16923b35298649e48e2b500faf7d996914

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2b718e966dadf9e872ae535621608b68264bd65d76758b1f79abe1b098c2aa86
MD5 aa92534a892515cc860a845db045309b
BLAKE2b-256 812ff4c76328d83cb95c5becbeb5d73e61e3b5c75e265cf267507b81567ff80c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c20afe9b1566f05a93e8f5b6c252dc4585d76da11cb59b7d6d2bab2f09ff07e
MD5 293fead48b3fc78bdcffe0d9d02e8efd
BLAKE2b-256 4a4701885c1e9383060ea0c2f09445c087d19480a7ddd0dd63e6310ca80c4640

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 80d22398ede933d541c2d57aba8946a8ae50f3fe3e04c7a0e7c59b2671d06a53
MD5 c09b9644b736606fba9fe520cb276887
BLAKE2b-256 163293aad2615115b1c9c6e7c392bcf6cc5e203cca9116c2fc39069b5d031941

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b5cdbcb1fca1608c4d13350c3feeb2f778554d92736f8b4021bcc10f1fa811b
MD5 a2e3fbabf44ab5ba9ffda55532d331e3
BLAKE2b-256 3f6d5c001318c64b471b3a550199608d05eab59e2c23855a8f2911aced55d51e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f67a77bae4522e06acb752631578fff0ac74460c9ffb9573a3c71cc01092cf2c
MD5 c881beba5994a6a0ea7ac80318df0f60
BLAKE2b-256 3a05f8b808586373130b43173f8c0d4586d668144efce431633a046c508026b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 04b6ba110009927f694532045e9df20d5116a9f521616c1d0b52b74e6f848fa1
MD5 b220a79cf5bda85f1bc96922829c5a97
BLAKE2b-256 6b7cacd3cad99764888f5b92f495962f2a26b240792d2122e35a39282f8d905f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 99663e5904f336d73dd8b97ce0c9d1396e8e921fa8502801271a3ca805332990
MD5 d35f95566ed8cc983f2ae66dc395c36c
BLAKE2b-256 f6b7f4c25ca1934ea7050eceda79aff5ee508572d4cafa8435cdd02996ed332a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce18647f2b0bed1e42b3fbcc8401ccec2711b1d221fff2ba88003e7497a10115
MD5 06dde6fcd568c182ac11db7592d8f41d
BLAKE2b-256 2540bd7d91db6c41718ddf6a3fe1e0a2afb2b2af481be6275a5d3841435462a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nono_py-0.7.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.7.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 468f14c7d2da657a49253160426aeb9369db07b8c20a89afed3bc510d30a8a23
MD5 d15ada51aafa0878d86458f9478161af
BLAKE2b-256 6a3d7a04703064ade5868116e7920d517c06105ab2fcac5a8ec595598a043ab3

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.7.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on always-further/nono-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page