Skip to main content

A Python module for sandboxing code with restricted imports and timeout enforcement (Linux/macOS only)

Project description

PySandboxing

PySandboxing is a Python module for sandboxing code with restricted imports and timeout enforcement. It prevents the execution of dangerous built-in functions and restricts the import of certain modules to enhance security. Sort of...

Installation

From PyPI

pip install pysandboxing

From Source

To install PySandboxing, clone the repository and run the setup script:

git clone https://github.com/libardoram/pysandboxing.git
cd pysandboxing
python setup.py install

Example Usage

To use pysandboxing in your Python code, simply import the module at the beginning of your script:

import pysandboxing.sandbox  

while True:
 print("This will be stopped after the timeout!")
import pysandboxing.sandbox as sandbox

import subprocess

subprocess.run(["ls", "-l"])

Features

  1. Disables dangerous built-in functions (exec, eval, open).
  2. Restricts the import of certain modules to prevent security risks.
  3. Enforces a timeout to stop possible infinite loops.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Libardo Ramirez Tirado - libar@libardoramirez.com

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

pysandboxing-0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

pysandboxing-0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file pysandboxing-0.1.tar.gz.

File metadata

  • Download URL: pysandboxing-0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for pysandboxing-0.1.tar.gz
Algorithm Hash digest
SHA256 0dcb3a22a2581432c1d0e466e98d4e8ead2d6c17f5eef3542772089c1c9f899c
MD5 966aa0c822cc57160e63bc89bdc7ed3d
BLAKE2b-256 29df226bdadb3d2f48f8c5e0f37759ffcda7c813d8db985d43354c898236f0c9

See more details on using hashes here.

File details

Details for the file pysandboxing-0.1-py3-none-any.whl.

File metadata

  • Download URL: pysandboxing-0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for pysandboxing-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f05a136d1d00522d26fd5f1c5a05f6d59ab27d499b21ceeee2daeea1f5ef39e
MD5 75e5bb1f799ce3045ae9a73b6365c72f
BLAKE2b-256 1ffbb6c33bde6a791f52ba2946e9d0e17422fd08e1634d13f8a29c24256b2a22

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