{ "info": { "author": "Alex Gajewski", "author_email": "agajews@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# hlbox\n\nA Python library to run untrusted code in secure, isolated [Docker](https://www.docker.com/)\nbased sandboxes.\n\n> It allows to spawn a process inside one-time Docker container, send data\n> to stdin, and obtain its exit code and stdout/stderr output. It's very similar\n> to what the [`subprocess`](https://docs.python.org/3/library/subprocess.html#module-subprocess)\n> module does but additionally you can specify a custom environment for the process\n> (a Docker [image](https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/))\n> and limit the CPU, memory, disk, and network usage for the running process.\n\n> ## Usage\n> Run a simple Python script in a one-time Docker container using the\n> [`python:3.6.5-alpine`](https://hub.docker.com/_/python/) image:\n> ```python\n> import epicbox\n\n> epicbox.configure(\n> profiles=[\n> epicbox.Profile('python', 'python:3.6.5-alpine')\n> ]\n> )\n> files = [{'name': 'main.py', 'content': b'print(42)'}]\n> limits = {'cputime': 1, 'memory': 64}\n> result = epicbox.run('python', 'python3 main.py', files=files, limits=limits)\n\n> ```\n> The `result` value is:\n> ```python\n> {'exit_code': 0,\n> 'stdout': b'42\\n',\n> 'stderr': b'',\n> 'duration': 0.143358,\n> 'timeout': False,\n> 'oom_killed': False}\n> ```\n\n> ### Advanced usage\n> A more advanced usage example of `epicbox` is to compile a C++ program and then\n> run it multiple times on different input data. In this example `epicbox` will\n> run containers on a dedicated [Docker Swarm](https://docs.docker.com/swarm/overview/)\n> cluster instead of locally installed Docker engine:\n> ```python\n> import epicbox\n\n> PROFILES = {\n> 'gcc_compile': {\n> 'docker_image': 'stepik/epicbox-gcc:6.3.0',\n> 'user': 'root',\n> },\n> 'gcc_run': {\n> 'docker_image': 'stepik/epicbox-gcc:6.3.0',\n> # It's safer to run untrusted code as a non-root user (even in a container)\n> 'user': 'sandbox',\n> 'read_only': True,\n> 'network_disabled': False,\n> },\n> }\n> epicbox.configure(profiles=PROFILES, docker_url='tcp://1.2.3.4:2375')\n\n> untrusted_code = b\"\"\"\n> // C++ program\n> #include \n\n> int main() {\n> int a, b;\n> std::cin >> a >> b;\n> std::cout << a + b << std::endl;\n> }\n> \"\"\"\n> # A working directory allows to preserve files created in a one-time container\n> # and access them from another one. Internally it is a temporary Docker volume.\n> with epicbox.working_directory() as workdir:\n> epicbox.run('gcc_compile', 'g++ -pipe -O2 -static -o main main.cpp',\n> files=[{'name': 'main.cpp', 'content': untrusted_code}],\n> workdir=workdir)\n> epicbox.run('gcc_run', './main', stdin='2 2',\n> limits={'cputime': 1, 'memory': 64},\n> workdir=workdir)\n> # {'exit_code': 0, 'stdout': b'4\\n', 'stderr': b'', 'duration': 0.095318, 'timeout': False, 'oom_killed': False}\n> epicbox.run('gcc_run', './main', stdin='14 5',\n> limits={'cputime': 1, 'memory': 64},\n> workdir=workdir)\n> # {'exit_code': 0, 'stdout': b'19\\n', 'stderr': b'', 'duration': 0.10285, 'timeout': False, 'oom_killed': False}\n> ```\n\n> ## Installation\n> `epicbox` can be installed by running `pip install epicbox`. It's tested on Python 3.4+ and\n> Docker 1.12+.\n\n> You can also check the [epicbox-images](https://github.com/StepicOrg/epicbox-images)\n> repository that contains Docker images used to automatically grade programming\n> assignments on [Stepik.org](https://stepik.org/).\n\n> ## Contributing\n> Contributions are welcome, and they are greatly appreciated!\n> More details can be found in [CONTRIBUTING](CONTRIBUTING.rst).\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "hlbox", "package_url": "https://pypi.org/project/hlbox/", "platform": "", "project_url": "https://pypi.org/project/hlbox/", "project_urls": null, "release_url": "https://pypi.org/project/hlbox/1.0.3/", "requires_dist": [ "docker (>=2)", "python-dateutil (~=2.4)", "requests (~=2.14)", "structlog (>=15.3)" ], "requires_python": "", "summary": "HLBox runs untrusted code in secure Docker based sandboxes (forked from [EpicBox](https://github.com/StepicOrg/epicbox))", "version": "1.0.3" }, "last_serial": 4683966, "releases": { "1.0.1.dev4": [ { "comment_text": "", "digests": { "md5": "7fd9bc2b2616bf3968851be9220a9d72", "sha256": "4f25a377e6b5b962877681147c01166e3543645a3d968be0b9cac8bffc439ff4" }, "downloads": -1, "filename": "hlbox-1.0.1.dev4-py3-none-any.whl", "has_sig": false, "md5_digest": "7fd9bc2b2616bf3968851be9220a9d72", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14554, "upload_time": "2019-01-10T06:01:30", "url": "https://files.pythonhosted.org/packages/87/cb/a6c3547a63f9986c7988616c2b7b606a3e7de3c7a00b1ba2994f403cd5f7/hlbox-1.0.1.dev4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0be85160f922c8dce0bdf6d35e381e1b", "sha256": "5767c866377f358b23b87d540cff6cc77a6d4c079016b8bf4ff337aea9db9138" }, "downloads": -1, "filename": "hlbox-1.0.1.dev4.tar.gz", "has_sig": false, "md5_digest": "0be85160f922c8dce0bdf6d35e381e1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23698, "upload_time": "2019-01-10T06:01:33", "url": "https://files.pythonhosted.org/packages/ea/b0/cff7fec17eb23fb0e1d76bc8d6f836c32bd079d3ac906b97913a0bccb9d4/hlbox-1.0.1.dev4.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "6b994576c6d08ecb94449646141527e7", "sha256": "e0135582f61b405b6bdca8826b6a8e2b85fb6950ceb344e28fe1b0eb8c2af7ee" }, "downloads": -1, "filename": "hlbox-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6b994576c6d08ecb94449646141527e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14851, "upload_time": "2019-01-11T06:01:39", "url": "https://files.pythonhosted.org/packages/a2/1d/8a93d038e595c8bdc5e0ee69762d5692205dde99d66078515990b1f95b95/hlbox-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "72303eae1f6e5dec0803bac4f8dcdf39", "sha256": "73b996c7eadf25e12c14463babd8400c35c9b5d07c2b15272ebcdd04995f7d79" }, "downloads": -1, "filename": "hlbox-1.0.2.tar.gz", "has_sig": false, "md5_digest": "72303eae1f6e5dec0803bac4f8dcdf39", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24652, "upload_time": "2019-01-11T06:01:41", "url": "https://files.pythonhosted.org/packages/6a/9a/744d114f4219d75927ac1b9d6038d20e2eec2e83000e2c3bd149b2ac94a6/hlbox-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "d29a4b80ddeae0f5be7fff96ebedca13", "sha256": "ca5d6ac8ded641a6eb9c4d500f5638f5e36a7751987ad30e4a1d76ba92c4ff8c" }, "downloads": -1, "filename": "hlbox-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d29a4b80ddeae0f5be7fff96ebedca13", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14853, "upload_time": "2019-01-11T06:08:54", "url": "https://files.pythonhosted.org/packages/35/b5/ca3b82b88a3dc3017094f42b1527d04c6be31dff092a87715af2deba556a/hlbox-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "27293669c7f5a7bcb2ad6f945d065913", "sha256": "9a9b3b3326c88116c9acd1d52a0c1155caf88f4463c837ba584e2dd7611359a8" }, "downloads": -1, "filename": "hlbox-1.0.3.tar.gz", "has_sig": false, "md5_digest": "27293669c7f5a7bcb2ad6f945d065913", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24670, "upload_time": "2019-01-11T06:08:57", "url": "https://files.pythonhosted.org/packages/29/04/7bd13afb6812375ee2bebe0f9f2ec4ee0588f24c3e4aa1d7ebc33d0db22d/hlbox-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d29a4b80ddeae0f5be7fff96ebedca13", "sha256": "ca5d6ac8ded641a6eb9c4d500f5638f5e36a7751987ad30e4a1d76ba92c4ff8c" }, "downloads": -1, "filename": "hlbox-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d29a4b80ddeae0f5be7fff96ebedca13", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14853, "upload_time": "2019-01-11T06:08:54", "url": "https://files.pythonhosted.org/packages/35/b5/ca3b82b88a3dc3017094f42b1527d04c6be31dff092a87715af2deba556a/hlbox-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "27293669c7f5a7bcb2ad6f945d065913", "sha256": "9a9b3b3326c88116c9acd1d52a0c1155caf88f4463c837ba584e2dd7611359a8" }, "downloads": -1, "filename": "hlbox-1.0.3.tar.gz", "has_sig": false, "md5_digest": "27293669c7f5a7bcb2ad6f945d065913", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24670, "upload_time": "2019-01-11T06:08:57", "url": "https://files.pythonhosted.org/packages/29/04/7bd13afb6812375ee2bebe0f9f2ec4ee0588f24c3e4aa1d7ebc33d0db22d/hlbox-1.0.3.tar.gz" } ] }