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.3.1.tar.gz (93.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.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (608.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

nono_py-0.3.1-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.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (609.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

nono_py-0.3.1-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.3.1-cp312-cp312-macosx_11_0_arm64.whl (724.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

nono_py-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl (838.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

nono_py-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (607.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

nono_py-0.3.1-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.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (607.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

nono_py-0.3.1-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.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (608.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

nono_py-0.3.1-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.3.1.tar.gz.

File metadata

  • Download URL: nono_py-0.3.1.tar.gz
  • Upload date:
  • Size: 93.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.3.1.tar.gz
Algorithm Hash digest
SHA256 422076e7308c1716b73f452a1adf0653b1dead10a361b55aba9d63fdebce1cce
MD5 69011b6dbaf0dd659f1148329510a9e8
BLAKE2b-256 494d0ec65d5b60aa1f07213b16c3d8e6f90a41d11f8ef28f1864a8308b045ba7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b077c02a81b261d964bd6d4d096363c775e160aabacd0f13127782e2a425e33d
MD5 655af2422cd1c41d6dfb25ebba3681ee
BLAKE2b-256 a204321614e91effc72a0fdf6ae10518d888fede3e000d0f2039e0b94c2c7b93

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 25e36de190c01040ed486254151ccaac923d0351b242f21c5e60839686e989ee
MD5 cb7092aa8bd3362b8c5f90adb2b352da
BLAKE2b-256 16895410200b101335d3692654222a01f0ce3c0bfc501b922e7bd95e0dbf185c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 722a064df9e65d7874753d0e1dad9c189073f587be4e293d35a2308645a61eb5
MD5 96e11b0b29a364c12231ad20421c007d
BLAKE2b-256 45e7eb463bea31f9f1165e4989e42589786925754238c1527d98b49ccec8735a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fc5220e4882216a1787a296ae4e3ea5d6a444668f891615cd9979d6dc460eb27
MD5 da000a118cd179b81cf2b7dc82bfd136
BLAKE2b-256 d61b38c1b17c72742beb22fc85d3f61246400365ec6428eaf272eadfdf1f86c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c50fd64db933bd3d82304ff9c9d8f976401b7f9eac34c78b45b0360b09df6a13
MD5 0ca7a2255312df010e61eda4271630c2
BLAKE2b-256 4c5471fa53a282ea4fdbd2d400f9faf97ebe575eccd33e7ff38d63b5b97d31ee

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4b147a0f529d9f5a0991328ac83290a88fe87ff88c8ad46b53a302a3351df1be
MD5 284efb51bf13b68a6083e274c4f770d3
BLAKE2b-256 5a75d2e805cf7370c81c184f326b2abfa7d139a2c81df612fff0c166bd19823d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ff3afc1bb3315a2471f55034bf8159ad0652aa93d172e3e11e588f0b8787821
MD5 cf6985ec26b38ddf24f0afa38934f054
BLAKE2b-256 6d149303eda3e73a1e50a8d83b7642a0b21e845f4d43a6e29a1c672a0602b91c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 024e70e85373d76a1377af758676432785749dbc1306d1abb5581195b62a82ed
MD5 d50ad7bb99289a9596231cd16aaa0a4a
BLAKE2b-256 ec57506f3e8bb505617d9e83833dfb1df7ac1842f0099b4e561f0e1ed0ca7e98

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 577174079c84ca3816bd4258fb52c2bf015e02c33b2ff589fe24dac50a323376
MD5 af17052cc8d708e356e6795b9a52a868
BLAKE2b-256 9d7622288e9e0353cd5b09084c97e5c379f7bbe1aa7e4db4b598168a6c6cc3a3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9655f0538ba8215601d7efe0d5845ea058b9ee99f48ad85a55b8d8c9eb11aeb0
MD5 935dab04b6d5927db5231b1bc9a7890e
BLAKE2b-256 04ca1c9a32277ccbf4b54bbf168849f2b36f70950855fcdfce2e3f8581ff3cd9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 717551fdc1083e8d7888a10f73480e2f5e412322550c9bce43834bc51a7b182c
MD5 bfc7c4e532baf7bf3e0aa6546dd8662f
BLAKE2b-256 73459fc5b8c73a0ddd07863974040784d93ed08f127782bf495e54e88c08b25f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for nono_py-0.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1d414c70e293044ea2efed6162f06a69f751429584d6d295ebe69601fce5f36a
MD5 c72f9072933e60362a1e9b4f60361bc0
BLAKE2b-256 6fd33569d533df72688f50e3a5385e48f16db175eaafc9a4bcf971a9f67348a1

See more details on using hashes here.

Provenance

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