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, args=func_args, kwargs=func_kwargs)
The Jail class constructor has the optional parameters path=os.path.join(os.getcwd(), "jail"), clear_before_create=False and clear_after_destroy=True. The path parameter specifies the directory where the jail will be created. The clear_before_create parameter specifies whether the jail directory should be cleared before creation (if it already exists) and the clear_after_destroy parameter specifies whether the jail directory should be cleared after destruction.
The execute method takes the optional parameters args (positional arguments) and kwargs (keyword arguments) to pass arguments to the function untrusted_func. The execute method also takes an optional timeout parameter to specify the maximum time in seconds that the function is allowed to run. A TimeoutError will be raised if the function takes longer than the specified time to execute. Otherwise, the return value of the function is returned (and exceptions are raised if the function raises an exception).
[!NOTE] You must run your python script as root to create a jail.
[!NOTE] PyJail is currently only supported on Linux.
Metadata
Release files for PyJail 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| PyJail-0.1.4.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyJail-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / PyJail-0.1.4.tar.gz
| Download URL | PyJail-0.1.4.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec250405e0591593256dabd9e35b91bf137ac18d09ca7d963c45a0eb0cb9a198
|
|
BLAKE2b-256 checksum How to use checksums |
899981ac7b41abc2079d535ce09f082b6ca043f24f6e6d159d9f77128c4f4e52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Release files / PyJail-0.1.4-py3-none-any.whl
| Download URL | PyJail-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d642a383428ad0fbf9711d1039ec6ab7d434d4c3ee579c8c14f798e18bf7fb4
|
|
BLAKE2b-256 checksum How to use checksums |
63d5a33b7bdb0d44cd6a52c697420749f81929cc943bc9bbbb42294ce03f447f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|