Skip to main content

A Python module for sandboxing code execution.

Project description

PyJail

PyJail is a Python module designed to provide a secure environment for executing untrusted code. PyJail is available on PyPI.

pip install PyJail

To execute a function without access to your system, call it through PyJail as shown below.

from pyjail import Jail

with Jail() as jail:
    result = jail.execute(untrusted_func, func_args, func_kwargs)

The Jail class constructor has the optional parameters path=os.path.join(os.getcwd(), "jail") and clear_before_create=True. The path parameter specifies the directory where the jail will be created (note that this is a transient directory that will be deleted when the Jail object is destroyed) and the clear_before_create parameter specifies whether the jail directory should be cleared before creation (if it already exists).

The execute method takes an option timeout parameter to specify the maximum time in seconds that the function is allowed to run.

[!NOTE] You must run your python script as root to create a jail.

[!NOTE] PyJail is currently only supported on Linux.

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

PyJail-0.1.3.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

PyJail-0.1.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file PyJail-0.1.3.tar.gz.

File metadata

  • Download URL: PyJail-0.1.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for PyJail-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7f88a8c614c4c4e59587a9c230f778cfed9e99e2ec04b4c9a02e81aeb6eaee31
MD5 ea414e2641282403a05efc8144cd9d0d
BLAKE2b-256 1c645bb752a6d72b603dbad61c76477602845abbd03d4e0c4f52756c86dd1e42

See more details on using hashes here.

File details

Details for the file PyJail-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: PyJail-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for PyJail-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 734047461aaf04d8849e0138f2885b1e1506987e93ceed50385f6c22b944ff81
MD5 b7cfeb0ecf397379c60449d2905f762a
BLAKE2b-256 bb62879099d7ff7f5f81d5c00503664f26e5aea915f9515f3767d2a66dd75510

See more details on using hashes here.

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