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

Enums

AccessMode

File system access mode:

  • AccessMode.READ - Read-only access
  • AccessMode.WRITE - Write-only access
  • AccessMode.READ_WRITE - Both read and write access

Classes

CapabilitySet

A collection of capabilities that define sandbox permissions.

caps = CapabilitySet()

# Add directory access (recursive)
caps.allow_path("/tmp", AccessMode.READ_WRITE)

# Add single file access
caps.allow_file("/etc/hosts", AccessMode.READ)

# Block network
caps.block_network()

# Add command to allow/block lists
caps.allow_command("git")
caps.block_command("rm")

# Add platform-specific rule (macOS Seatbelt)
caps.platform_rule("(allow mach-lookup (global-name \"com.apple.system.logger\"))")

# Utility methods
caps.deduplicate()  # Remove duplicates
caps.path_covered("/tmp/foo")  # Check if path is covered
caps.fs_capabilities()  # List all fs capabilities
caps.summary()  # Human-readable summary

QueryContext

Query permissions without applying the sandbox:

caps = CapabilitySet()
caps.allow_path("/tmp", AccessMode.READ)

ctx = QueryContext(caps)

result = ctx.query_path("/tmp/file.txt", AccessMode.READ)
# {'status': 'allowed', 'reason': 'granted_path', 'granted_path': '/tmp', 'access': 'read'}

result = ctx.query_path("/var/log/test", AccessMode.READ)
# {'status': 'denied', 'reason': 'path_not_granted'}

result = ctx.query_network()
# {'status': 'allowed', 'reason': 'network_allowed'}

SandboxState

Serialize and restore capability sets:

caps = CapabilitySet()
caps.allow_path("/tmp", AccessMode.READ)

# Serialize to JSON
state = SandboxState.from_caps(caps)
json_str = state.to_json()

# Restore from JSON
restored_state = SandboxState.from_json(json_str)
restored_caps = restored_state.to_caps()

SupportInfo

Platform support information:

info = support_info()
print(info.is_supported)  # True/False
print(info.platform)      # "linux" or "macos"
print(info.details)       # Human-readable details

Functions

apply(caps: CapabilitySet) -> None

Apply the sandbox. This is irreversible. Once applied, the current process and all children can only access resources granted by the capabilities.

is_supported() -> bool

Check if sandboxing is supported on this platform.

support_info() -> SupportInfo

Get detailed platform support information.

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.4.2.tar.gz (101.3 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.4.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (660.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

nono_py-0.4.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

nono_py-0.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

nono_py-0.4.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

nono_py-0.4.2-cp312-cp312-macosx_11_0_arm64.whl (765.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nono_py-0.4.2-cp312-cp312-macosx_10_12_x86_64.whl (882.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

nono_py-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

nono_py-0.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

nono_py-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

nono_py-0.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

nono_py-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (660.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nono_py-0.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: nono_py-0.4.2.tar.gz
  • Upload date:
  • Size: 101.3 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.4.2.tar.gz
Algorithm Hash digest
SHA256 b8f417bfa89b598c87126987f1388375fe8100119531bc81ada9a713881e1a95
MD5 a3e8d6c0040a2199fe34946c71982f17
BLAKE2b-256 f5e67107ea7099098fbe8643184260c2605791bd7f45df2e7985751c5e8465a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03223ac5eb487abd6c437fca24178a960377101bfdfec4aa3ce78180c1290295
MD5 656def17e8f0a0f89b89e1d4ec398bb3
BLAKE2b-256 efc779b840a163347a348992f874769d92d0363e63dd8559d25e7b6289f50ebe

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 161361b8c6748aff4f15d929b2f1ae432de7d884652aba722ce3597310f9a9a5
MD5 023c39af0f4a6a53138db18b42dc8497
BLAKE2b-256 8571b5cfb1f51892521419da4fa726ab6c010ce8b4e925cbd6cc3e25660815a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 88e08112d879b0768750415a63c31684d2f2afbe6f452b295f8c7884c458821b
MD5 a444cbb293e7296dd5f0710e9b5b2e99
BLAKE2b-256 5a79385897444d21b1de7f720b72da6561e81e75b839193a35fddae47b2111e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 60b08a3a981c47a1848a40387f0371cdc3201c553ad8be81680d3264447d9b33
MD5 88d2f9467ec287e7e7a106b1834b61da
BLAKE2b-256 ad19dea592b5406093d93afe5d5234d5f506f81fa050d21939fc1b97dea0de06

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6eda78100212dc0e2f1cded6da86bbea3667c1f8f6a5951cacf4ca1ddbdfddd6
MD5 dc8e203220beeec6f98660d758f84f89
BLAKE2b-256 5c1b9fee48fe3e01a5261b664ee71d32b22ab9f219904091b0124b5a97c97260

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e02d0c6ffe234f45cdf41105af4eec46f80e6ef638225fdf86d66dc9dece1416
MD5 3f47938da906ef612bf8fc3492d7b376
BLAKE2b-256 74a477cb1d77dc18b2eb89248f450fcd21080926fceab81f08877619ca0ea075

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d5337dfcaede7518fc009d1a25e6c2fd6e46bfa56d63e35a2d1e5bbb40d49f66
MD5 ee522b83ea86fc65b7908871217d3cbf
BLAKE2b-256 abef528d0de794a98b49f333c84fb7fed2c1bc63e2dc80fb6c6f3287e45f6066

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f76520adec4bb31384d7b4d4f8ea70a1c1d36bbeb2d78991f7af4f275393b2db
MD5 161c3f3f6858ce7e4a90b4ca2e08fa8d
BLAKE2b-256 356676a232887f3c8831ffe799e4432d959bf4ffc997d836113ea57bfc7ad0f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 978198d16d13eed1bb8d76a427fb7621c4fbc67027adae89a5c9fed7ca3eae02
MD5 88a8d5d5c3407522ae4647f447a8e264
BLAKE2b-256 b3075a9f28e73a3b1016cab46f25d77c6a5a790d7213c0c5d9fcffc214e1902b

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b8a930b16020b676536721ef0c44f4978165c58a639502e812654657539d68e5
MD5 5d5132c59d46dbbfcae8402879a51280
BLAKE2b-256 282df7e2fc2a2e8d7ce6e75199a753813aad5b6313fbdbdd0885236bc9d78a0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf4caabdc09bec7c6c0c0bb98cc34f84cb8187ac38fa09271cbd01c244c1b4d6
MD5 b6ea294ead91fec4a147ccc4b09a3ea6
BLAKE2b-256 29b0682f02dd46930d28e6c74f58490d5a6abed61e34ea37e3d3ebd558034dda

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for nono_py-0.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 674a7726b40aee328bdd52347d609aa6e335adbd26fac28b25db93fbe59a7f26
MD5 4af4d93c747717fdcdb59d0c8df1ed3a
BLAKE2b-256 dcd96df63ac2aecdcb4fd9a540789037b10aec37332f8a2068abd8cae1af61da

See more details on using hashes here.

Provenance

The following attestation bundles were made for nono_py-0.4.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