RestrictedPython 7.2a1.dev0__tar.gz → 7.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. restrictedpython-7.4/.pre-commit-config.yaml +28 -0
  2. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/CHANGES.rst +32 -4
  3. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/MANIFEST.in +1 -0
  4. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/PKG-INFO +37 -9
  5. restrictedpython-7.4/docs/_build/doctest/output.txt +35 -0
  6. restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from312to313.rst.txt +5 -0
  7. restrictedpython-7.4/docs/_build/html/_sources/contributing/index.rst.txt +308 -0
  8. restrictedpython-7.4/docs/_build/html/_sources/index.rst.txt +42 -0
  9. restrictedpython-7.4/docs/_build/html/_sources/usage/basic_usage.rst.txt +175 -0
  10. restrictedpython-7.4/docs/_build/html/_static/scripts/furo.js.LICENSE.txt +7 -0
  11. restrictedpython-7.4/docs/changes.rst +1 -0
  12. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/conf.py +16 -8
  13. restrictedpython-7.4/docs/contributing/ast/python3_13.ast +194 -0
  14. restrictedpython-7.4/docs/contributing/changes_from310to311.rst +5 -0
  15. restrictedpython-7.4/docs/contributing/changes_from311to312.rst +5 -0
  16. restrictedpython-7.4/docs/contributing/changes_from312to313.rst +5 -0
  17. restrictedpython-7.4/docs/contributing/changes_from37to38.rst +5 -0
  18. restrictedpython-7.4/docs/contributing/changes_from38to39.rst +5 -0
  19. restrictedpython-7.4/docs/contributing/changes_from39to310.rst +5 -0
  20. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/index.rst +1 -2
  21. restrictedpython-7.4/docs/idea.rst +85 -0
  22. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/index.rst +0 -2
  23. restrictedpython-7.4/docs/install/index.rst +10 -0
  24. restrictedpython-7.4/docs/logo.jpg +0 -0
  25. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/requirements.txt +1 -0
  26. restrictedpython-7.4/docs/roadmap/index.rst +33 -0
  27. restrictedpython-7.4/docs/usage/api.rst +139 -0
  28. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/usage/basic_usage.rst +56 -0
  29. restrictedpython-7.4/docs/usage/framework_usage.rst +86 -0
  30. restrictedpython-7.4/docs/usage/index.rst +9 -0
  31. restrictedpython-7.4/docs/usage/policy.rst +237 -0
  32. restrictedpython-7.4/pyproject.toml +21 -0
  33. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/setup.cfg +1 -3
  34. restrictedpython-7.4/setup.py +69 -0
  35. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/Guards.py +17 -1
  36. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/Utilities.py +5 -1
  37. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/_compat.py +0 -1
  38. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/transformer.py +30 -80
  39. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/PKG-INFO +37 -9
  40. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/SOURCES.txt +24 -3
  41. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/requires.txt +1 -1
  42. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/builtins/test_utilities.py +10 -2
  43. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_Guards.py +82 -0
  44. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_NamedExpr.py +0 -3
  45. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_compile.py +18 -10
  46. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_compile_restricted_function.py +1 -6
  47. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_dict_comprehension.py +6 -16
  48. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_fstring.py +0 -7
  49. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tox.ini +24 -45
  50. RestrictedPython-7.2a1.dev0/docs/contributing/ast/python3_6.ast +0 -175
  51. RestrictedPython-7.2a1.dev0/docs/contributing/changes_from36to37.rst +0 -5
  52. RestrictedPython-7.2a1.dev0/docs/upgrade_dependencies/index.rst +0 -30
  53. RestrictedPython-7.2a1.dev0/setup.py +0 -79
  54. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/.readthedocs.yaml +0 -0
  55. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/CONTRIBUTING.md +0 -0
  56. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/COPYRIGHT.txt +0 -0
  57. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/LICENSE.txt +0 -0
  58. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/README.rst +0 -0
  59. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/buildout.cfg +0 -0
  60. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/constraints.txt +0 -0
  61. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/Makefile +0 -0
  62. {RestrictedPython-7.2a1.dev0/docs → restrictedpython-7.4/docs/_build/html/_images}/logo.jpg +0 -0
  63. /RestrictedPython-7.2a1.dev0/docs/changes.rst → /restrictedpython-7.4/docs/_build/html/_sources/changes.rst.txt +0 -0
  64. /RestrictedPython-7.2a1.dev0/docs/contributing/changes_from310to311.rst → /restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from310to311.rst.txt +0 -0
  65. /RestrictedPython-7.2a1.dev0/docs/contributing/changes_from311to312.rst → /restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from311to312.rst.txt +0 -0
  66. /RestrictedPython-7.2a1.dev0/docs/contributing/changes_from37to38.rst → /restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from37to38.rst.txt +0 -0
  67. /RestrictedPython-7.2a1.dev0/docs/contributing/changes_from38to39.rst → /restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from38to39.rst.txt +0 -0
  68. /RestrictedPython-7.2a1.dev0/docs/contributing/changes_from39to310.rst → /restrictedpython-7.4/docs/_build/html/_sources/contributing/changes_from39to310.rst.txt +0 -0
  69. /RestrictedPython-7.2a1.dev0/docs/idea.rst → /restrictedpython-7.4/docs/_build/html/_sources/idea.rst.txt +0 -0
  70. /RestrictedPython-7.2a1.dev0/docs/install/index.rst → /restrictedpython-7.4/docs/_build/html/_sources/install/index.rst.txt +0 -0
  71. /RestrictedPython-7.2a1.dev0/docs/roadmap/index.rst → /restrictedpython-7.4/docs/_build/html/_sources/roadmap/index.rst.txt +0 -0
  72. /RestrictedPython-7.2a1.dev0/docs/usage/api.rst → /restrictedpython-7.4/docs/_build/html/_sources/usage/api.rst.txt +0 -0
  73. /RestrictedPython-7.2a1.dev0/docs/usage/framework_usage.rst → /restrictedpython-7.4/docs/_build/html/_sources/usage/framework_usage.rst.txt +0 -0
  74. /RestrictedPython-7.2a1.dev0/docs/usage/index.rst → /restrictedpython-7.4/docs/_build/html/_sources/usage/index.rst.txt +0 -0
  75. /RestrictedPython-7.2a1.dev0/docs/usage/policy.rst → /restrictedpython-7.4/docs/_build/html/_sources/usage/policy.rst.txt +0 -0
  76. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_10.ast +0 -0
  77. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_11.ast +0 -0
  78. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_12.ast +0 -0
  79. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_7.ast +0 -0
  80. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_8.ast +0 -0
  81. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/contributing/ast/python3_9.ast +0 -0
  82. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/docs/make.bat +0 -0
  83. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/Eval.py +0 -0
  84. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/Limits.py +0 -0
  85. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/PrintCollector.py +0 -0
  86. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/__init__.py +0 -0
  87. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython/compile.py +0 -0
  88. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/dependency_links.txt +0 -0
  89. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/not-zip-safe +0 -0
  90. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/src/RestrictedPython.egg-info/top_level.txt +0 -0
  91. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/__init__.py +0 -0
  92. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/builtins/test_limits.py +0 -0
  93. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/helper.py +0 -0
  94. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_Utilities.py +0 -0
  95. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_eval.py +0 -0
  96. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_imports.py +0 -0
  97. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_iterating_over_dict_items.py +0 -0
  98. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/test_print_function.py +0 -0
  99. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_arithmetic_operators.py +0 -0
  100. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_bit_wise_operators.py +0 -0
  101. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_bool_operators.py +0 -0
  102. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_comparison_operators.py +0 -0
  103. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_identity_operators.py +0 -0
  104. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_logical_operators.py +0 -0
  105. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/operators/test_unary_operators.py +0 -0
  106. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_assert.py +0 -0
  107. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_assign.py +0 -0
  108. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_async.py +0 -0
  109. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_attribute.py +0 -0
  110. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_augassign.py +0 -0
  111. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_base_types.py +0 -0
  112. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_breakpoint.py +0 -0
  113. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_call.py +0 -0
  114. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_classdef.py +0 -0
  115. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_comparators.py +0 -0
  116. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_conditional.py +0 -0
  117. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_eval_exec.py +0 -0
  118. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_functiondef.py +0 -0
  119. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_generic.py +0 -0
  120. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_global_local.py +0 -0
  121. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_import.py +0 -0
  122. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_inspect.py +0 -0
  123. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_iterator.py +0 -0
  124. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_lambda.py +0 -0
  125. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_loop.py +0 -0
  126. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_name.py +0 -0
  127. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_slice.py +0 -0
  128. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_subscript.py +0 -0
  129. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_try.py +0 -0
  130. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_with_stmt.py +0 -0
  131. {RestrictedPython-7.2a1.dev0 → restrictedpython-7.4}/tests/transformer/test_yield.py +0 -0
@@ -0,0 +1,28 @@
1
+ # Generated from:
2
+ # https://github.com/zopefoundation/meta/tree/master/config/pure-python
3
+ minimum_pre_commit_version: '3.6'
4
+ repos:
5
+ - repo: https://github.com/pycqa/isort
6
+ rev: "5.13.2"
7
+ hooks:
8
+ - id: isort
9
+ - repo: https://github.com/hhatto/autopep8
10
+ rev: "v2.3.1"
11
+ hooks:
12
+ - id: autopep8
13
+ args: [--in-place, --aggressive, --aggressive]
14
+ - repo: https://github.com/asottile/pyupgrade
15
+ rev: v3.17.0
16
+ hooks:
17
+ - id: pyupgrade
18
+ args: [--py38-plus]
19
+ - repo: https://github.com/isidentical/teyit
20
+ rev: 0.4.3
21
+ hooks:
22
+ - id: teyit
23
+ - repo: https://github.com/PyCQA/flake8
24
+ rev: "7.1.1"
25
+ hooks:
26
+ - id: flake8
27
+ additional_dependencies:
28
+ - flake8-debugger == 4.1.2
@@ -1,11 +1,39 @@
1
1
  Changes
2
2
  =======
3
3
 
4
- 7.2a1.dev0 (2024-03-14)
5
- -----------------------
4
+ 7.4 (2024-10-09)
5
+ ----------------
6
+
7
+ - Allow to use the package with Python 3.13.
8
+
9
+ - Drop support for Python 3.7.
10
+
11
+ - Provide new function ``RestrictedPython.Guards.safer_getattr_raise``.
12
+ It is similar to ``safer_getattr`` but handles its parameter
13
+ ``default`` like ``getattr``, i.e. it raises ``AttributeError``
14
+ if the attribute lookup fails and this parameter is not provided,
15
+ fixes `#287 <https://github.com/zopefoundation/RestrictedPython/issues/287>`_.
16
+
17
+
18
+ 7.3 (2024-09-30)
19
+ ----------------
20
+
21
+ - Increase the safety level of ``safer_getattr`` allowing applications to use
22
+ it as ``getattr`` implementation. Such use should now follow the same policy
23
+ and give the same level of protection as direct attribute access in an
24
+ environment based on ``RestrictedPython``'s ``safe_builtints``.
25
+ - Prevent information leakage via ``AttributeError.obj``
26
+ and the ``string`` module. (CVE-2024-47532)
27
+
28
+
29
+ 7.2 (2024-08-02)
30
+ ----------------
6
31
 
7
- - Allow to use the package with Python 3.13 -- Caution: No security
8
- audit has been done so far.
32
+ - Remove unneeded setuptools fossils that may cause installation problems
33
+ with recent setuptools versions.
34
+ - Add support for single mode statements / execution.
35
+ - Fix a potential breakout capability in the provided ``safer_getattr`` method
36
+ that is part of the ``safer_builtins``.
9
37
 
10
38
 
11
39
  7.1 (2024-03-14)
@@ -5,6 +5,7 @@ include *.rst
5
5
  include *.txt
6
6
  include buildout.cfg
7
7
  include tox.ini
8
+ include .pre-commit-config.yaml
8
9
 
9
10
  recursive-include docs *.py
10
11
  recursive-include docs *.rst
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RestrictedPython
3
- Version: 7.2a1.dev0
3
+ Version: 7.4
4
4
  Summary: RestrictedPython is a defined subset of the Python language which allows to provide a program input into a trusted environment.
5
5
  Home-page: https://github.com/zopefoundation/RestrictedPython
6
6
  Author: Zope Foundation and Contributors
7
- Author-email: zope-dev@zope.org
7
+ Author-email: zope-dev@zope.dev
8
8
  License: ZPL 2.1
9
9
  Project-URL: Documentation, https://restrictedpython.readthedocs.io/
10
10
  Project-URL: Source, https://github.com/zopefoundation/RestrictedPython
@@ -15,15 +15,15 @@ Classifier: License :: OSI Approved :: Zope Public License
15
15
  Classifier: Programming Language :: Python
16
16
  Classifier: Operating System :: OS Independent
17
17
  Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.7
19
18
  Classifier: Programming Language :: Python :: 3.8
20
19
  Classifier: Programming Language :: Python :: 3.9
21
20
  Classifier: Programming Language :: Python :: 3.10
22
21
  Classifier: Programming Language :: Python :: 3.11
23
22
  Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
24
  Classifier: Programming Language :: Python :: Implementation :: CPython
25
25
  Classifier: Topic :: Security
26
- Requires-Python: >=3.7, <3.14
26
+ Requires-Python: >=3.8, <3.14
27
27
  Description-Content-Type: text/x-rst
28
28
  License-File: LICENSE.txt
29
29
  Provides-Extra: test
@@ -31,7 +31,7 @@ Requires-Dist: pytest; extra == "test"
31
31
  Requires-Dist: pytest-mock; extra == "test"
32
32
  Provides-Extra: docs
33
33
  Requires-Dist: Sphinx; extra == "docs"
34
- Requires-Dist: sphinx_rtd_theme; extra == "docs"
34
+ Requires-Dist: furo; extra == "docs"
35
35
 
36
36
  .. image:: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml/badge.svg
37
37
  :target: https://github.com/zopefoundation/RestrictedPython/actions/workflows/tests.yml
@@ -124,11 +124,39 @@ the documentation `Contributing page
124
124
  Changes
125
125
  =======
126
126
 
127
- 7.2a1.dev0 (2024-03-14)
128
- -----------------------
127
+ 7.4 (2024-10-09)
128
+ ----------------
129
+
130
+ - Allow to use the package with Python 3.13.
131
+
132
+ - Drop support for Python 3.7.
133
+
134
+ - Provide new function ``RestrictedPython.Guards.safer_getattr_raise``.
135
+ It is similar to ``safer_getattr`` but handles its parameter
136
+ ``default`` like ``getattr``, i.e. it raises ``AttributeError``
137
+ if the attribute lookup fails and this parameter is not provided,
138
+ fixes `#287 <https://github.com/zopefoundation/RestrictedPython/issues/287>`_.
139
+
140
+
141
+ 7.3 (2024-09-30)
142
+ ----------------
143
+
144
+ - Increase the safety level of ``safer_getattr`` allowing applications to use
145
+ it as ``getattr`` implementation. Such use should now follow the same policy
146
+ and give the same level of protection as direct attribute access in an
147
+ environment based on ``RestrictedPython``'s ``safe_builtints``.
148
+ - Prevent information leakage via ``AttributeError.obj``
149
+ and the ``string`` module. (CVE-2024-47532)
150
+
151
+
152
+ 7.2 (2024-08-02)
153
+ ----------------
129
154
 
130
- - Allow to use the package with Python 3.13 -- Caution: No security
131
- audit has been done so far.
155
+ - Remove unneeded setuptools fossils that may cause installation problems
156
+ with recent setuptools versions.
157
+ - Add support for single mode statements / execution.
158
+ - Fix a potential breakout capability in the provided ``safer_getattr`` method
159
+ that is part of the ``safer_builtins``.
132
160
 
133
161
 
134
162
  7.1 (2024-03-14)
@@ -0,0 +1,35 @@
1
+ Results of doctest builder run on 2024-10-09 09:56:01
2
+ =====================================================
3
+
4
+ Document: usage/api
5
+ -------------------
6
+ 1 items passed all tests:
7
+ 13 tests in default
8
+ 13 tests in 1 items.
9
+ 13 passed and 0 failed.
10
+ Test passed.
11
+
12
+ Document: usage/basic_usage
13
+ ---------------------------
14
+ 2 items passed all tests:
15
+ 6 tests in default
16
+ 1 tests in single
17
+ 7 tests in 2 items.
18
+ 7 passed and 0 failed.
19
+ Test passed.
20
+
21
+ Document: usage/framework_usage
22
+ -------------------------------
23
+ 2 items passed all tests:
24
+ 1 tests in default
25
+ 2 tests in own_policy
26
+ 3 tests in 2 items.
27
+ 3 passed and 0 failed.
28
+ Test passed.
29
+
30
+ Doctest summary
31
+ ===============
32
+ 23 tests
33
+ 0 failures in tests
34
+ 0 failures in setup code
35
+ 0 failures in cleanup code
@@ -0,0 +1,5 @@
1
+ Changes from Python 3.12 to Python 3.13
2
+ ---------------------------------------
3
+
4
+ .. literalinclude:: ast/python3_13.ast
5
+ :diff: ast/python3_12.ast
@@ -0,0 +1,308 @@
1
+ Contributing
2
+ ============
3
+
4
+
5
+ Contributing to RestrictedPython
6
+ --------------------------------
7
+
8
+ Legal requirements to contribute to RestrictedPython
9
+ ++++++++++++++++++++++++++++++++++++++++++++++++++++
10
+
11
+ The projects under the zopefoundation GitHub organization are open source, including RestrictedPython.
12
+ We welcome contributions in different forms:
13
+
14
+ * bug reports
15
+ * code improvements and bug fixes
16
+ * documentation improvements
17
+ * pull request reviews
18
+
19
+ For any changes in the repository besides trivial typo fixes, you are required to sign the contributor agreement.
20
+ See https://www.zope.dev/developer/becoming-a-committer.html for details.
21
+
22
+ Please visit our `Developer Guidelines`_ if you'd like to contribute code changes and our `guidelines for reporting bugs`_ if you want to file a bug report.
23
+
24
+
25
+ .. _`Developer Guidelines`: https://www.zope.dev/developer/guidelines.html
26
+ .. _`guidelines for reporting bugs`: https://www.zope.dev/developer/reporting-bugs.html
27
+
28
+ Preperations for Contributing
29
+ +++++++++++++++++++++++++++++
30
+
31
+ If you want to contribute to this package, please prepare a development environment that includes ``git``, ``tox``, and several Python versions available through a Python manager such as ``pyenv``.
32
+ Please read the section :ref:`understand` first.
33
+
34
+ For all commits, use ``tox`` to run tests and lint, and build the docs, before pushing your commit to the remote repository.
35
+
36
+ .. _new_python_version:
37
+
38
+ Preperations for a new Python version
39
+ +++++++++++++++++++++++++++++++++++++
40
+
41
+ RestrictedPython should be updated for each new version of Python.
42
+ To do so:
43
+
44
+ * Read the changelog (`What's new in Python`_).
45
+ * Copy and adjust the new AST Grammar (found under: `Python 3 AST`_) to ``/docs/contributing/ast/python<version>.ast``.
46
+ * Add a new file ``changes_from<old_version>to<new_version>.rst`` in the directory ``/docs/contributing/``.
47
+ If the changes are significant, especially if related to security, then add a description of the changes in that file.
48
+ * Add those files to the ``toctree`` directive in ``index.rst``.
49
+ * For each new **AST Node** or functionality:
50
+
51
+ * Add tests to ``/tests/``.
52
+ * Add a ``visit_<AST Node>`` to ``/src/RestrictedPython/transformer.py``.
53
+
54
+ If the new AST Node should be enabled by default, with or without any modification, please add a ``visit_<AST Node>`` method such as the following:
55
+
56
+ .. code-block:: python
57
+
58
+ def visit_<AST Node>(self, node):
59
+ """Allow `<AST Node>` expressions."""
60
+ ... # modifications
61
+ return self.node_contents_visit(node)
62
+
63
+ All AST Nodes without an explicit ``visit_<AST Node>`` method, are denied by default.
64
+ So the usage of this expression and functionality is not allowed.
65
+
66
+ * Check the documentation for `inspect <https://docs.python.org/3/library/inspect.html>`_ and adjust the ``transformer.py:INSPECT_ATTRIBUTES`` list.
67
+ * Add a corresponding changelog entry.
68
+ * Additionally modify ``.meta.toml`` and run the ``meta/config`` script (for details see: https://github.com/mgedmin/check-python-versions) to update the following files:
69
+
70
+ * ``/setup.py`` - Check that the new Python version classifier has been added ``"Programming Language :: Python :: <version>",``, and that the ``python_requires`` section has been updated correctly.
71
+ * ``/tox.ini`` - Check that a ``testenv`` entry is added to the general ``envlist`` statement.
72
+ * ``/.github/workflows/tests.yml`` - Check that a corresponding Python version entry has been added to the matrix definition.
73
+ * ``/docs/conf.py`` - Add the Python version to the ``intersphinx_mapping`` list.
74
+
75
+ * On your local environment, use ``tox`` to run tests and lint, and build the docs, before pushing your commit to the remote repository.
76
+ * Create a pull request.
77
+
78
+ Enable a Python Feature in RestrictedPython
79
+ +++++++++++++++++++++++++++++++++++++++++++
80
+
81
+ To enable a certain functionality in RestrictedPython, do the following:
82
+
83
+ * `Create a new issue on GitHub <https://github.com/zopefoundation/RestrictedPython/issues/new/choose>`__, requesting the new feature, for discussion.
84
+ * In ``/src/RestrictedPython/transformer.py``, change the corresponding ``visit_<AST Node>`` method.
85
+ * In ``/tests/``, add or change the corresponding tests for this functionality.
86
+ * Add a changelog entry.
87
+ * On your local environment, use ``tox`` to run tests and lint, and build the docs, before pushing your commit to the remote repository.
88
+ * Create a pull request and request a review by a core maintainer, e.g.:
89
+
90
+ * icemac
91
+ * loechel
92
+
93
+ Differences between Python versions
94
+ -----------------------------------
95
+
96
+ A (modified style) Copy of all Abstract Grammar Definitions for the Python versions does live in this Documentation (ast Subfolder) to help finding difference quicker by comparing files.
97
+
98
+ .. toctree::
99
+ :maxdepth: 2
100
+
101
+ changes_from37to38
102
+ changes_from38to39
103
+ changes_from39to310
104
+ changes_from310to311
105
+ changes_from311to312
106
+ changes_from312to313
107
+
108
+ .. _understand:
109
+
110
+ Understanding How RestrictedPython works internally
111
+ ---------------------------------------------------
112
+
113
+ RestrictedPython is a classic approach of compiler construction to create a limited subset of an existing programming language.
114
+
115
+ Defining a programming language requires a regular grammar (`Chomsky 3`_ / `EBNF`_) definition.
116
+ This grammar will be implemented in an abstract syntax tree (AST), which will be passed on to a code generator to produce a machine-readable version.
117
+
118
+ .. _`_sec_code_generation`:
119
+
120
+ Code generation
121
+ +++++++++++++++
122
+
123
+ As Python is a platform independent programming language, this machine readable version is a byte code which will be translated on the fly by an interpreter into machine code.
124
+ This machine code then gets executed on the specific CPU architecture, with the standard operating system restrictions.
125
+
126
+ The byte code produced must be compatible with the execution environment that the Python interpreter is running in, so we do not generate the byte code directly from ``compile_restricted`` and the other ``compile_restricted_*`` methods manually, it may not match what the interpreter expects.
127
+
128
+ Thankfully, the Python ``compile()`` function introduced the capability to compile ``ast.AST`` code into byte code in Python 2.6, so we can return the platform-independent AST and keep byte code generation delegated to the interpreter.
129
+
130
+ ``ast`` module (Abstract Syntax Trees)
131
+ ++++++++++++++++++++++++++++++++++++++
132
+
133
+ The ``ast`` module consists of four areas:
134
+
135
+ * ``AST`` (Basis of all Nodes) + all node class implementations
136
+ * ``NodeVisitor`` and ``NodeTransformer`` (tool to consume and modify the AST)
137
+ * Helper methods
138
+
139
+ * ``parse``
140
+ * ``walk``
141
+ * ``dump``
142
+
143
+ * Constants
144
+
145
+ * ``PyCF_ONLY_AST``
146
+
147
+
148
+ ``NodeVisitor`` & ``NodeTransformer``
149
+ +++++++++++++++++++++++++++++++++++++
150
+
151
+ A ``NodeVisitor`` is a class of a node / AST consumer, it reads the data by stepping through the tree without modifying it.
152
+ In contrast, a ``NodeTransformer`` (which inherits from a ``NodeVisitor``) is allowed to modify the tree and nodes.
153
+
154
+ Technical decisions on how to implement / maintain RestrictedPython (Design, Structure, Tools, ...)
155
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
156
+
157
+ RestrictedPython is a core Package of the Zope & Plone Stack.
158
+ Until Version 3.6 RestrictedPython was Python 2 only, and a critical blocker for Zope & Plone.
159
+ With RestrictedPython 4.0 an API compatible rewrite has happened, which supports modern Python Versions.
160
+
161
+ * Use modern python tool stack for maintenance and tests
162
+
163
+ * tox
164
+ * pytest
165
+ * black
166
+ * linting tools: flake8
167
+
168
+ * Use clear package Structure
169
+
170
+ * ``/src`` - Source Code
171
+ * ``/tests`` - separated tests
172
+ * ``/docs`` - Documentation
173
+
174
+ Tests and documentation are distributed within released packages.
175
+
176
+ .. todo::
177
+
178
+ Resolve discussion about how RestrictedPython should be treat new expressions / ``ast.Nodes``.
179
+ This belongs to :ref:`new_python_version`.
180
+
181
+ **Option 1 - reduce maintenance burden (preferred by icemac)**
182
+
183
+
184
+ All AST Nodes without an explicit ``visit_<AST Node>`` method, are denied by default.
185
+ So the usage of this expression and functionality is not allowed.
186
+
187
+ *This is currently the promoted version.*
188
+
189
+ **Option 2 - be as explicit as possible (preferred by loechel)**
190
+
191
+ If the new AST Node should be disabled by default, add a ``visit_<AST Node>`` method such as the following:
192
+
193
+ .. code-block:: python
194
+
195
+ def visit_<AST Node>(self, node):
196
+ """`<AST Node>` expression currently not allowed."""
197
+ self.not_allowed(node)
198
+
199
+ Please note, that for all AST Nodes without an explicit ``visit_<AST Node>`` method, a default applies which denies the usage of this expression and functionality.
200
+ As we try to be **as explicit as possible**, all language features should have a corresponding ``visit_<AST Node>``.
201
+
202
+ That follows the Zen of Python:
203
+
204
+ .. code-block:: pycon
205
+ :emphasize-lines: 5
206
+
207
+ >>> import this
208
+ The Zen of Python, by Tim Peters
209
+
210
+ Beautiful is better than ugly.
211
+ Explicit is better than implicit.
212
+ Simple is better than complex.
213
+ Complex is better than complicated.
214
+ Flat is better than nested.
215
+ Sparse is better than dense.
216
+ Readability counts.
217
+ Special cases aren't special enough to break the rules.
218
+ Although practicality beats purity.
219
+ Errors should never pass silently.
220
+ Unless explicitly silenced.
221
+ In the face of ambiguity, refuse the temptation to guess.
222
+ There should be one-- and preferably only one --obvious way to do it.
223
+ Although that way may not be obvious at first unless you're Dutch.
224
+ Now is better than never.
225
+ Although never is often better than *right* now.
226
+ If the implementation is hard to explain, it's a bad idea.
227
+ If the implementation is easy to explain, it may be a good idea.
228
+ Namespaces are one honking great idea -- let's do more of those!
229
+
230
+
231
+ Technical Backgrounds - Links to External Documentation
232
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++
233
+
234
+ * `Concept of Immutable Types and Python Example`_
235
+ * `Python 3 Standard Library Documentation on AST module`_
236
+
237
+ * AST Grammar of Python (`Status of Python Versions`_)
238
+
239
+ * `Python 3.12 AST`_ (EOL 2028-10)
240
+ * `Python 3.11 AST`_ (EOL 2027-10)
241
+ * `Python 3.10 AST`_ (EOL 2026-10)
242
+ * `Python 3.9 AST`_ (EOL 2025-10)
243
+ * `Python 3.8 AST`_ (EOL 2024-10)
244
+ * `Python 3.7 AST`_ (EOL 2023-06-27)
245
+
246
+ * `AST NodeVistiors Class`_
247
+ * `AST NodeTransformer Class`_
248
+ * `AST dump method`_
249
+
250
+ * `In detail Documentation on the Python AST module (Green Tree Snakes)`_
251
+ * `Example how to Instrumenting the Python AST`_
252
+
253
+ Todos
254
+ -----
255
+
256
+ .. todolist::
257
+
258
+ .. Links:
259
+
260
+ .. _`What's new in Python`: https://docs.python.org/3/whatsnew/
261
+
262
+ .. _`What's new in Python 3.12`: https://docs.python.org/3.12/whatsnew/3.12.html
263
+
264
+ .. _`What's new in Python 3.11`: https://docs.python.org/3.11/whatsnew/3.11.html
265
+
266
+ .. _`What's new in Python 3.10`: https://docs.python.org/3.10/whatsnew/3.10.html
267
+
268
+ .. _`What's new in Python 3.9`: https://docs.python.org/3.9/whatsnew/3.9.html
269
+
270
+ .. _`What's new in Python 3.8`: https://docs.python.org/3.8/whatsnew/3.8.html
271
+
272
+ .. _`What's new in Python 3.7`: https://docs.python.org/3.7/whatsnew/3.7.html
273
+
274
+ .. _`Status of Python Versions`: https://devguide.python.org/versions/
275
+
276
+ .. _`Concept of Immutable Types and Python Example`: https://en.wikipedia.org/wiki/Immutable_object#Python
277
+
278
+ .. _`Python 3 Standard Library Documentation on AST module`: https://docs.python.org/3/library/ast.html
279
+
280
+ .. _`CamelCase`: https://en.wikipedia.org/wiki/Camel_case
281
+
282
+ .. _`EBNF`: https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form
283
+
284
+ .. _`Chomsky 3`: https://en.wikipedia.org/wiki/Chomsky_hierarchy#Type-3_grammars
285
+
286
+ .. _`Python 3 AST`: https://docs.python.org/3/library/ast.html#abstract-grammar
287
+
288
+ .. _`Python 3.12 AST`: https://docs.python.org/3.12/library/ast.html#abstract-grammar
289
+
290
+ .. _`Python 3.11 AST`: https://docs.python.org/3.11/library/ast.html#abstract-grammar
291
+
292
+ .. _`Python 3.10 AST`: https://docs.python.org/3.10/library/ast.html#abstract-grammar
293
+
294
+ .. _`Python 3.9 AST`: https://docs.python.org/3.9/library/ast.html#abstract-grammar
295
+
296
+ .. _`Python 3.8 AST`: https://docs.python.org/3.8/library/ast.html#abstract-grammar
297
+
298
+ .. _`Python 3.7 AST`: https://docs.python.org/3.7/library/ast.html#abstract-grammar
299
+
300
+ .. _`AST NodeVistiors Class`: https://docs.python.org/3/library/ast.html#ast.NodeVisitor
301
+
302
+ .. _`AST NodeTransformer Class`: https://docs.python.org/3/library/ast.html#ast.NodeTransformer
303
+
304
+ .. _`AST dump method`: https://docs.python.org/3/library/ast.html#ast.dump
305
+
306
+ .. _`In detail Documentation on the Python AST module (Green Tree Snakes)`: https://greentreesnakes.readthedocs.org/en/latest/
307
+
308
+ .. _`Example how to Instrumenting the Python AST`: http://www.dalkescientific.com/writings/diary/archive/2010/02/22/instrumenting_the_ast.html
@@ -0,0 +1,42 @@
1
+ .. RestrictedPython documentation master file, created by
2
+ sphinx-quickstart on Thu May 19 12:43:20 2016.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ .. image:: logo.jpg
7
+
8
+ ============================================
9
+ Welcome to RestrictedPython's documentation!
10
+ ============================================
11
+
12
+ RestrictedPython is a tool that helps to define a subset of the Python language which allows to provide a program input into a trusted environment.
13
+ RestrictedPython is not a sandbox system or a secured environment, but it helps to define a trusted environment and execute untrusted code inside of it.
14
+
15
+ Supported Python versions
16
+ =========================
17
+
18
+ RestrictedPython supports CPython 3.7 up to 3.12.
19
+ It does _not_ support PyPy or other alternative Python implementations.
20
+
21
+ Contents
22
+ ========
23
+
24
+ .. toctree::
25
+ :maxdepth: 2
26
+
27
+ idea
28
+ install/index
29
+ usage/index
30
+ usage/api
31
+
32
+ roadmap/index
33
+ contributing/index
34
+
35
+ changes
36
+
37
+ Indices and tables
38
+ ==================
39
+
40
+ * :ref:`genindex`
41
+ * :ref:`modindex`
42
+ * :ref:`search`