{"id":18176647,"url":"https://github.com/zopefoundation/restrictedpython","last_synced_at":"2025-05-13T19:13:11.227Z","repository":{"id":7178722,"uuid":"8480726","full_name":"zopefoundation/RestrictedPython","owner":"zopefoundation","description":"A restricted execution environment for Python to run untrusted code.","archived":false,"fork":false,"pushed_at":"2025-03-20T07:40:06.000Z","size":1770,"stargazers_count":548,"open_issues_count":22,"forks_count":39,"subscribers_count":73,"default_branch":"master","last_synced_at":"2025-04-26T00:14:30.007Z","etag":null,"topics":["code","hacktoberfest","plone","python","restrictions","untrusted","zope"],"latest_commit_sha":null,"homepage":"http://restrictedpython.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zopefoundation.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"docs/roadmap/index.rst","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-28T14:29:45.000Z","updated_at":"2025-04-24T16:46:49.000Z","dependencies_parsed_at":"2023-11-06T08:29:15.874Z","dependency_job_id":"e622b7b7-4bbf-4033-ba48-a2e348bd57c2","html_url":"https://github.com/zopefoundation/RestrictedPython","commit_stats":{"total_commits":664,"total_committers":54,"mean_commits":"12.296296296296296","dds":0.6837349397590362,"last_synced_commit":"642202897b419a74b1cb1756315936b45fb75e78"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2FRestrictedPython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2FRestrictedPython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2FRestrictedPython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zopefoundation%2FRestrictedPython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zopefoundation","download_url":"https://codeload.github.com/zopefoundation/RestrictedPython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912730,"owners_count":21506871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code","hacktoberfest","plone","python","restrictions","untrusted","zope"],"created_at":"2024-11-02T17:09:51.381Z","updated_at":"2025-04-26T00:14:34.937Z","avatar_url":"https://github.com/zopefoundation.png","language":"Python","readme":".. image:: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml\n\n.. image:: https://coveralls.io/repos/github/zopefoundation/RestrictedPython/badge.svg?branch=master\n    :target: https://coveralls.io/github/zopefoundation/RestrictedPython?branch=master\n\n.. image:: https://readthedocs.org/projects/restrictedpython/badge/\n    :target: https://restrictedpython.readthedocs.org/\n    :alt: Documentation Status\n\n.. image:: https://img.shields.io/pypi/v/RestrictedPython.svg\n    :target: https://pypi.org/project/RestrictedPython/\n    :alt: Current version on PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/RestrictedPython.svg\n    :target: https://pypi.org/project/RestrictedPython/\n    :alt: Supported Python versions\n\n.. image:: https://github.com/zopefoundation/RestrictedPython/raw/master/docs/logo.jpg\n\n================\nRestrictedPython\n================\n\nRestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment.\nRestrictedPython is not a sandbox system or a secured environment, but it helps to define a trusted environment and execute untrusted code inside of it.\n\n.. warning::\n\n   RestrictedPython only supports CPython. It does _not_ support PyPy and other Python implementations as it cannot provide its restrictions there.\n\nFor full documentation please see http://restrictedpython.readthedocs.io/.\n\nExample\n=======\n\nTo give a basic understanding what RestrictedPython does here two examples:\n\nAn unproblematic code example\n-----------------------------\n\nPython allows you to execute a large set of commands.\nThis would not harm any system.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e from RestrictedPython import compile_restricted\n    \u003e\u003e\u003e from RestrictedPython import safe_globals\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e source_code = \"\"\"\n    ... def example():\n    ...     return 'Hello World!'\n    ... \"\"\"\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e loc = {}\n    \u003e\u003e\u003e byte_code = compile_restricted(source_code, '\u003cinline\u003e', 'exec')\n    \u003e\u003e\u003e exec(byte_code, safe_globals, loc)\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e loc['example']()\n    'Hello World!'\n\nProblematic code example\n------------------------\n\nThis example directly executed in Python could harm your system.\n\n.. code-block:: pycon\n\n    \u003e\u003e\u003e from RestrictedPython import compile_restricted\n    \u003e\u003e\u003e from RestrictedPython import safe_globals\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e source_code = \"\"\"\n    ... import os\n    ...\n    ... os.listdir('/')\n    ... \"\"\"\n    \u003e\u003e\u003e byte_code = compile_restricted(source_code, '\u003cinline\u003e', 'exec')\n    \u003e\u003e\u003e exec(byte_code, safe_globals, {})\n    Traceback (most recent call last):\n    ImportError: __import__ not found\n\nContributing to RestrictedPython\n--------------------------------\n\nIf you want to help maintain RestrictedPython and contribute, please refer to\nthe documentation `Contributing page\n\u003chttps://restrictedpython.readthedocs.io/en/latest/contributing/index.html\u003e`_.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzopefoundation%2Frestrictedpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzopefoundation%2Frestrictedpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzopefoundation%2Frestrictedpython/lists"}