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.0.tar.gz (94.0 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.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (615.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

nono_py-0.4.0-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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (615.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

nono_py-0.4.0-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.0-cp312-cp312-macosx_11_0_arm64.whl (725.8 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nono_py-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl (839.0 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

nono_py-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (614.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

nono_py-0.4.0-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.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (614.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

nono_py-0.4.0-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.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (615.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nono_py-0.4.0-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.0.tar.gz.

File metadata

  • Download URL: nono_py-0.4.0.tar.gz
  • Upload date:
  • Size: 94.0 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.0.tar.gz
Algorithm Hash digest
SHA256 671c20211b151a2d2e3df93b389dbdd3635b55158bf4df77ba2926310ec82777
MD5 6d7b5e7de05d68ddb3b278cd9e4e92d6
BLAKE2b-256 5267e4fa5cae2ac0a0f8318d07c170b57b7e7461ae45ba00451cc3ee246e5845

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0f68af0ee0bc79db583a1ed0a7240582ab1fff0b92837b2c2d7cd583ca8b709
MD5 0b9ad52ab9de2872b73ca934e4cb703d
BLAKE2b-256 acb5ff37dd9f8018209f6764115323a5fbd97b5e3240a5f80daf57e07ef7a3d1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a4a9b4cc85cd06cb8454fa512a21ee3eb29bb8d8f9ffa99eaf020d08ef331116
MD5 46a3df68a6d91e6713e664d510fbd107
BLAKE2b-256 99fb59ada2c8887f19b9b144e5a3668a47069f0b68f0e7a48c83ea85d2539e1f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d7f3f5ff1d6851dfa6cddc0f09015da68ff8ca3922fa9efb5c8d8a9821d0d46
MD5 ce68a5ac3263938a91f636a45677633e
BLAKE2b-256 dbafa1318dbb6e0a81424beadb6eb74321ef7d3bc41000971f5cf1deb36651de

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 019dd391e5332afa0f27997026b29ed50f9a3a794afdffbc901d59d549393993
MD5 c1b12a8652e11ea653b0579934ce3f3b
BLAKE2b-256 bbca1c2df354fb5adec6b95786e6dc0352a2a4763087bd6f911ba23ce95e1df4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d8f6043a9df7995ccc46a187d8ac57721802f56e290df7eaf2667a85f8a73013
MD5 88411eae78b650767fe6f057d6bf416d
BLAKE2b-256 d1ffba000c365a19f3c1eef91d4394d663698b55dee2ded73318eb7a17f3552b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 002f04cd43c4a431a0f9f94eae77a8d93a38d6813e4db54eacba60d6bad9d58d
MD5 93ba0ddab8994c1539d29afcf0c92ae7
BLAKE2b-256 eb8b7965947eb36a1942edadbdf7557dd7e51a6f9cef0d4d7f27fd9eb72fe022

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 982169f351d80e48ea599a5cbc571bd766fd9b146a5bc22df64dbc2fd0bc050f
MD5 4ca81bad44c7fe2878676a70592b1cdc
BLAKE2b-256 8eb1508d4d8b8b869a905a79f4428ec72b3558109e3000d0e82cdc8a43b78f87

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8d2251355e433e0cd741c424d6eec832944743440cf56a0b398d61d48b58cacb
MD5 547ab9dd43f90487e6d272e78c3d82a2
BLAKE2b-256 9b441ed620a5f732a0f61d64a4d36ce0dfab76262d6077a042f41b2da3cda90f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe3500a7fd8ab60c68d67dfa7a40d7e206266a0253ccab5bf8ec135f835a32e1
MD5 a8c589dde76658180c5da2ba1fb0383e
BLAKE2b-256 782fe9ffdfabe8825bb7179920e9b21d20329a2e702e8b186c3e88d2ae191528

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8b8462c96ae4bbff644b520d60e9cc16f007d289c07049374365a57b4358cd38
MD5 1354ba3a7fb104716864aa838680fa50
BLAKE2b-256 b772952dcdbb58ee63c3d704096359715fa27715650f832cd8ed0164a56ebc59

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 821fa0ae7c7ab6ecfbf1c73531775c1c63f03d9d4076a03a18d9df402c7e1093
MD5 d717157245dde92e907c5835b18303d6
BLAKE2b-256 7703edd861d38b5dc568ae1b0150f8d4d66673a184ac2c28f27d4c293d82bc38

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4e5803ff450ee134b5f1d9b1ea9be5ead9af950c9e0d4e1796c74ccf0ff9264
MD5 d90e2633728a6ba9476cf51ef0564120
BLAKE2b-256 b3301c22f03ba297eebd08a9f251c08b41e3307344267730e6ee02357b9d47f0

See more details on using hashes here.

Provenance

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