RestrictedPython 5.3__tar.gz → 5.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.
- {RestrictedPython-5.3 → RestrictedPython-5.4}/CHANGES.rst +14 -1
- {RestrictedPython-5.3 → RestrictedPython-5.4}/PKG-INFO +15 -2
- {RestrictedPython-5.3 → RestrictedPython-5.4}/setup.py +1 -1
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/Guards.py +5 -2
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/Utilities.py +15 -1
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/PKG-INFO +15 -2
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/SOURCES.txt +0 -27
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/builtins/test_utilities.py +4 -1
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_Guards.py +130 -9
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_Utilities.py +13 -0
- RestrictedPython-5.3/docs/_build/doctest/output.txt +0 -34
- RestrictedPython-5.3/docs/_build/html/_sources/changes.rst.txt +0 -1
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from26to27.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from30to31.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from310to311.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from311to312.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from31to32.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from32to33.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from33to34.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from34to35.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from35to36.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from36to37.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from37to38.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from38to39.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/changes_from39to310.rst.txt +0 -5
- RestrictedPython-5.3/docs/_build/html/_sources/contributing/index.rst.txt +0 -350
- RestrictedPython-5.3/docs/_build/html/_sources/idea.rst.txt +0 -85
- RestrictedPython-5.3/docs/_build/html/_sources/index.rst.txt +0 -44
- RestrictedPython-5.3/docs/_build/html/_sources/install/index.rst.txt +0 -10
- RestrictedPython-5.3/docs/_build/html/_sources/roadmap/index.rst.txt +0 -38
- RestrictedPython-5.3/docs/_build/html/_sources/upgrade_dependencies/index.rst.txt +0 -30
- RestrictedPython-5.3/docs/_build/html/_sources/usage/api.rst.txt +0 -139
- RestrictedPython-5.3/docs/_build/html/_sources/usage/basic_usage.rst.txt +0 -119
- RestrictedPython-5.3/docs/_build/html/_sources/usage/framework_usage.rst.txt +0 -86
- RestrictedPython-5.3/docs/_build/html/_sources/usage/index.rst.txt +0 -9
- RestrictedPython-5.3/docs/_build/html/_sources/usage/policy.rst.txt +0 -237
- RestrictedPython-5.3/docs/logo.jpg +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/COPYRIGHT.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/LICENSE.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/MANIFEST.in +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/README.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/buildout.cfg +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/constraints.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/Makefile +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/changes.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/conf.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python2_6.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python2_7.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_0.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_1.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_2.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_3.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_4.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_5.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_6.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_7.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_8.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/ast/python3_9.ast +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from26to27.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from30to31.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from31to32.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from32to33.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from33to34.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from34to35.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from35to36.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from36to37.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from37to38.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/changes_from38to39.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/contributing/index.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/idea.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/index.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/install/index.rst +0 -0
- {RestrictedPython-5.3/docs/_build/html/_images → RestrictedPython-5.4/docs}/logo.jpg +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/make.bat +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/roadmap/index.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/upgrade_dependencies/index.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/usage/api.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/usage/basic_usage.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/usage/framework_usage.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/usage/index.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/docs/usage/policy.rst +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/setup.cfg +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/Eval.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/Limits.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/PrintCollector.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/__init__.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/_compat.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/compile.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython/transformer.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/dependency_links.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/not-zip-safe +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/requires.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/src/RestrictedPython.egg-info/top_level.txt +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/__init__.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/builtins/test_limits.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/helper.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_NamedExpr.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_compile.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_compile_restricted_function.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_eval.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_imports.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_iterating_over_dict_items.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_print_function.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/test_print_stmt.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_arithmetic_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_bit_wise_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_bool_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_comparison_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_identity_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_logical_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/operators/test_unary_operators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_assert.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_assign.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_async.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_attribute.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_augassign.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_base_types.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_breakpoint.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_call.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_classdef.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_comparators.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_conditional.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_dict_comprehension.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_eval_exec.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_fstring.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_functiondef.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_generic.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_global_local.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_import.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_inspect.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_iterator.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_lambda.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_loop.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_name.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_slice.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_subscript.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_try.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_with_stmt.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tests/transformer/test_yield.py +0 -0
- {RestrictedPython-5.3 → RestrictedPython-5.4}/tox.ini +0 -0
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
Changes
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
+
5.4 (2023-08-30)
|
|
5
|
+
----------------
|
|
6
|
+
|
|
7
|
+
Fixes
|
|
8
|
+
+++++
|
|
9
|
+
|
|
10
|
+
- Fix information disclosure problems through
|
|
11
|
+
Python's "format" functionality
|
|
12
|
+
(``format`` and ``format_map`` methods on ``str``/``unicode`` and
|
|
13
|
+
their instances,
|
|
14
|
+
``string.Formatter``).
|
|
15
|
+
|
|
16
|
+
|
|
4
17
|
5.3 (2023-07-08)
|
|
5
18
|
----------------
|
|
6
19
|
|
|
7
|
-
-
|
|
20
|
+
- Forbid using some attributes providing access to restricted Python internals.
|
|
8
21
|
|
|
9
22
|
|
|
10
23
|
5.2 (2021-11-19)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: RestrictedPython
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.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
|
|
@@ -115,10 +115,23 @@ This example directly executed in Python could harm your system.
|
|
|
115
115
|
Changes
|
|
116
116
|
=======
|
|
117
117
|
|
|
118
|
+
5.4 (2023-08-30)
|
|
119
|
+
----------------
|
|
120
|
+
|
|
121
|
+
Fixes
|
|
122
|
+
+++++
|
|
123
|
+
|
|
124
|
+
- Fix information disclosure problems through
|
|
125
|
+
Python's "format" functionality
|
|
126
|
+
(``format`` and ``format_map`` methods on ``str``/``unicode`` and
|
|
127
|
+
their instances,
|
|
128
|
+
``string.Formatter``).
|
|
129
|
+
|
|
130
|
+
|
|
118
131
|
5.3 (2023-07-08)
|
|
119
132
|
----------------
|
|
120
133
|
|
|
121
|
-
-
|
|
134
|
+
- Forbid using some attributes providing access to restricted Python internals.
|
|
122
135
|
|
|
123
136
|
|
|
124
137
|
5.2 (2021-11-19)
|
|
@@ -264,9 +264,12 @@ def safer_getattr(object, name, default=None, getattr=getattr):
|
|
|
264
264
|
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
265
265
|
|
|
266
266
|
"""
|
|
267
|
-
if
|
|
267
|
+
if name in ('format', 'format_map') and (
|
|
268
|
+
isinstance(object, _compat.basestring) or (
|
|
269
|
+
isinstance(object, type)
|
|
270
|
+
and issubclass(object, _compat.basestring))):
|
|
268
271
|
raise NotImplementedError(
|
|
269
|
-
'Using
|
|
272
|
+
'Using the string format* methods is not safe')
|
|
270
273
|
if name.startswith('_'):
|
|
271
274
|
raise AttributeError(
|
|
272
275
|
'"{name}" is an invalid attribute name because it '
|
|
@@ -18,7 +18,21 @@ import string
|
|
|
18
18
|
|
|
19
19
|
utility_builtins = {}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
class _AttributeDelegator:
|
|
23
|
+
def __init__(self, mod, *excludes):
|
|
24
|
+
"""delegate attribute lookups outside *excludes* to module *mod*."""
|
|
25
|
+
self.__mod = mod
|
|
26
|
+
self.__excludes = excludes
|
|
27
|
+
|
|
28
|
+
def __getattr__(self, attr):
|
|
29
|
+
if attr in self.__excludes:
|
|
30
|
+
raise NotImplementedError(
|
|
31
|
+
"{}.{} is not safe".format(self.__mod.__name__, attr))
|
|
32
|
+
return getattr(self.__mod, attr)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
utility_builtins['string'] = _AttributeDelegator(string, "Formatter")
|
|
22
36
|
utility_builtins['math'] = math
|
|
23
37
|
utility_builtins['random'] = random
|
|
24
38
|
utility_builtins['whrandom'] = random
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: RestrictedPython
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.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
|
|
@@ -115,10 +115,23 @@ This example directly executed in Python could harm your system.
|
|
|
115
115
|
Changes
|
|
116
116
|
=======
|
|
117
117
|
|
|
118
|
+
5.4 (2023-08-30)
|
|
119
|
+
----------------
|
|
120
|
+
|
|
121
|
+
Fixes
|
|
122
|
+
+++++
|
|
123
|
+
|
|
124
|
+
- Fix information disclosure problems through
|
|
125
|
+
Python's "format" functionality
|
|
126
|
+
(``format`` and ``format_map`` methods on ``str``/``unicode`` and
|
|
127
|
+
their instances,
|
|
128
|
+
``string.Formatter``).
|
|
129
|
+
|
|
130
|
+
|
|
118
131
|
5.3 (2023-07-08)
|
|
119
132
|
----------------
|
|
120
133
|
|
|
121
|
-
-
|
|
134
|
+
- Forbid using some attributes providing access to restricted Python internals.
|
|
122
135
|
|
|
123
136
|
|
|
124
137
|
5.2 (2021-11-19)
|
|
@@ -15,33 +15,6 @@ docs/idea.rst
|
|
|
15
15
|
docs/index.rst
|
|
16
16
|
docs/logo.jpg
|
|
17
17
|
docs/make.bat
|
|
18
|
-
docs/_build/doctest/output.txt
|
|
19
|
-
docs/_build/html/_images/logo.jpg
|
|
20
|
-
docs/_build/html/_sources/changes.rst.txt
|
|
21
|
-
docs/_build/html/_sources/idea.rst.txt
|
|
22
|
-
docs/_build/html/_sources/index.rst.txt
|
|
23
|
-
docs/_build/html/_sources/contributing/changes_from26to27.rst.txt
|
|
24
|
-
docs/_build/html/_sources/contributing/changes_from30to31.rst.txt
|
|
25
|
-
docs/_build/html/_sources/contributing/changes_from310to311.rst.txt
|
|
26
|
-
docs/_build/html/_sources/contributing/changes_from311to312.rst.txt
|
|
27
|
-
docs/_build/html/_sources/contributing/changes_from31to32.rst.txt
|
|
28
|
-
docs/_build/html/_sources/contributing/changes_from32to33.rst.txt
|
|
29
|
-
docs/_build/html/_sources/contributing/changes_from33to34.rst.txt
|
|
30
|
-
docs/_build/html/_sources/contributing/changes_from34to35.rst.txt
|
|
31
|
-
docs/_build/html/_sources/contributing/changes_from35to36.rst.txt
|
|
32
|
-
docs/_build/html/_sources/contributing/changes_from36to37.rst.txt
|
|
33
|
-
docs/_build/html/_sources/contributing/changes_from37to38.rst.txt
|
|
34
|
-
docs/_build/html/_sources/contributing/changes_from38to39.rst.txt
|
|
35
|
-
docs/_build/html/_sources/contributing/changes_from39to310.rst.txt
|
|
36
|
-
docs/_build/html/_sources/contributing/index.rst.txt
|
|
37
|
-
docs/_build/html/_sources/install/index.rst.txt
|
|
38
|
-
docs/_build/html/_sources/roadmap/index.rst.txt
|
|
39
|
-
docs/_build/html/_sources/upgrade_dependencies/index.rst.txt
|
|
40
|
-
docs/_build/html/_sources/usage/api.rst.txt
|
|
41
|
-
docs/_build/html/_sources/usage/basic_usage.rst.txt
|
|
42
|
-
docs/_build/html/_sources/usage/framework_usage.rst.txt
|
|
43
|
-
docs/_build/html/_sources/usage/index.rst.txt
|
|
44
|
-
docs/_build/html/_sources/usage/policy.rst.txt
|
|
45
18
|
docs/contributing/changes_from26to27.rst
|
|
46
19
|
docs/contributing/changes_from30to31.rst
|
|
47
20
|
docs/contributing/changes_from31to32.rst
|
|
@@ -5,7 +5,10 @@ import string
|
|
|
5
5
|
|
|
6
6
|
def test_string_in_utility_builtins():
|
|
7
7
|
from RestrictedPython.Utilities import utility_builtins
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
# we no longer provide access to ``string`` itself, only to
|
|
10
|
+
# a restricted view of it
|
|
11
|
+
assert utility_builtins['string'].__name__ == string.__name__
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
def test_math_in_utility_builtins():
|
|
@@ -162,7 +162,7 @@ b = a.format('world')
|
|
|
162
162
|
"""
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
def
|
|
165
|
+
def test_Guards__safer_getattr__1a():
|
|
166
166
|
"""It prevents using the format method of a string.
|
|
167
167
|
|
|
168
168
|
format() is considered harmful:
|
|
@@ -173,16 +173,120 @@ def test_Guards__safer_getattr__1():
|
|
|
173
173
|
}
|
|
174
174
|
with pytest.raises(NotImplementedError) as err:
|
|
175
175
|
restricted_exec(STRING_DOT_FORMAT_DENIED, glb)
|
|
176
|
-
assert 'Using
|
|
176
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
177
177
|
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
# contributed by Ward Theunisse
|
|
180
|
+
STRING_DOT_FORMAT_MAP_DENIED = """\
|
|
181
|
+
a = 'Hello {foo.__dict__}'
|
|
182
|
+
b = a.format_map({foo:str})
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def test_Guards__safer_getattr__1b():
|
|
187
|
+
"""It prevents using the format method of a string.
|
|
188
|
+
|
|
189
|
+
format() is considered harmful:
|
|
190
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
191
|
+
"""
|
|
192
|
+
glb = {
|
|
193
|
+
'__builtins__': safe_builtins,
|
|
194
|
+
}
|
|
195
|
+
with pytest.raises(NotImplementedError) as err:
|
|
196
|
+
restricted_exec(STRING_DOT_FORMAT_MAP_DENIED, glb)
|
|
197
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# contributed by Abhishek Govindarasu
|
|
201
|
+
STR_DOT_FORMAT_DENIED = """\
|
|
202
|
+
str.format('{0.__class__.__mro__[1]}', int)
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_Guards__safer_getattr__1c():
|
|
207
|
+
"""It prevents using the format method of a string.
|
|
208
|
+
|
|
209
|
+
format() is considered harmful:
|
|
210
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
211
|
+
"""
|
|
212
|
+
glb = {
|
|
213
|
+
'__builtins__': safe_builtins,
|
|
214
|
+
}
|
|
215
|
+
with pytest.raises(NotImplementedError) as err:
|
|
216
|
+
restricted_exec(STR_DOT_FORMAT_DENIED, glb)
|
|
217
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
STR_DOT_FORMAT_MAP_DENIED = """\
|
|
221
|
+
str.format_map('Hello {foo.__dict__}', {'foo':str})
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def test_Guards__safer_getattr__1d():
|
|
226
|
+
"""It prevents using the format method of a string.
|
|
227
|
+
|
|
228
|
+
format() is considered harmful:
|
|
229
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
230
|
+
"""
|
|
231
|
+
glb = {
|
|
232
|
+
'__builtins__': safe_builtins,
|
|
233
|
+
}
|
|
234
|
+
with pytest.raises(NotImplementedError) as err:
|
|
235
|
+
restricted_exec(STR_DOT_FORMAT_MAP_DENIED, glb)
|
|
236
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
USTRING_DOT_FORMAT_DENIED = """\
|
|
180
240
|
a = u'Hello {}'
|
|
181
|
-
b = a.format(
|
|
241
|
+
b = a.format('world')
|
|
182
242
|
"""
|
|
183
243
|
|
|
184
244
|
|
|
185
|
-
|
|
245
|
+
@pytest.mark.skipif(IS_PY3, reason="Python 3 lacks unicode")
|
|
246
|
+
def test_Guards__safer_getattr__2a():
|
|
247
|
+
"""It prevents using the format method of a unicode.
|
|
248
|
+
|
|
249
|
+
format() is considered harmful:
|
|
250
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
251
|
+
"""
|
|
252
|
+
glb = {
|
|
253
|
+
'__builtins__': safe_builtins,
|
|
254
|
+
}
|
|
255
|
+
with pytest.raises(NotImplementedError) as err:
|
|
256
|
+
restricted_exec(USTRING_DOT_FORMAT_DENIED, glb)
|
|
257
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
# contributed by Ward Theunisse
|
|
261
|
+
USTRING_DOT_FORMAT_MAP_DENIED = """\
|
|
262
|
+
a = u'Hello {foo.__dict__}'
|
|
263
|
+
b = a.format_map({foo:str})
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@pytest.mark.skipif(IS_PY3, reason="Python 3 lacks unicode")
|
|
268
|
+
def test_Guards__safer_getattr__2b():
|
|
269
|
+
"""It prevents using the format method of a unicode.
|
|
270
|
+
|
|
271
|
+
format() is considered harmful:
|
|
272
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
273
|
+
"""
|
|
274
|
+
glb = {
|
|
275
|
+
'__builtins__': safe_builtins,
|
|
276
|
+
}
|
|
277
|
+
with pytest.raises(NotImplementedError) as err:
|
|
278
|
+
restricted_exec(USTRING_DOT_FORMAT_MAP_DENIED, glb)
|
|
279
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# contributed by Abhishek Govindarasu
|
|
283
|
+
UNICODE_DOT_FORMAT_DENIED = """\
|
|
284
|
+
unicode.format(u'{0.__class__.__mro__[1]}', int)
|
|
285
|
+
"""
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
@pytest.mark.skipif(IS_PY3, reason="Python 3 lacks unicode")
|
|
289
|
+
def test_Guards__safer_getattr__2c():
|
|
186
290
|
"""It prevents using the format method of a unicode.
|
|
187
291
|
|
|
188
292
|
format() is considered harmful:
|
|
@@ -193,10 +297,27 @@ def test_Guards__safer_getattr__2():
|
|
|
193
297
|
}
|
|
194
298
|
with pytest.raises(NotImplementedError) as err:
|
|
195
299
|
restricted_exec(UNICODE_DOT_FORMAT_DENIED, glb)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
300
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
UNICODE_DOT_FORMAT_MAP_DENIED = """\
|
|
304
|
+
unicode.format_map(u'Hello {foo.__dict__}', {'foo':str})
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@pytest.mark.skipif(IS_PY3, reason="Python 3 lacks unicode")
|
|
309
|
+
def test_Guards__safer_getattr__2d():
|
|
310
|
+
"""It prevents using the format method of a unicode.
|
|
311
|
+
|
|
312
|
+
format() is considered harmful:
|
|
313
|
+
http://lucumr.pocoo.org/2016/12/29/careful-with-str-format/
|
|
314
|
+
"""
|
|
315
|
+
glb = {
|
|
316
|
+
'__builtins__': safe_builtins,
|
|
317
|
+
}
|
|
318
|
+
with pytest.raises(NotImplementedError) as err:
|
|
319
|
+
restricted_exec(UNICODE_DOT_FORMAT_MAP_DENIED, glb)
|
|
320
|
+
assert 'Using the string format* methods is not safe' == str(err.value)
|
|
200
321
|
|
|
201
322
|
|
|
202
323
|
SAFER_GETATTR_ALLOWED = """\
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
1
3
|
from RestrictedPython.Utilities import reorder
|
|
2
4
|
from RestrictedPython.Utilities import test
|
|
5
|
+
from RestrictedPython.Utilities import utility_builtins
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
def test_Utilities__test_1():
|
|
@@ -30,3 +33,13 @@ def test_Utilities__reorder_1():
|
|
|
30
33
|
_with = [('k2', 'v2'), ('k3', 'v3')]
|
|
31
34
|
without = [('k2', 'v2'), ('k4', 'v4')]
|
|
32
35
|
assert reorder(s, _with, without) == [('k3', 'v3')]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_Utilities_string_Formatter():
|
|
39
|
+
"""Access to ``string.Formatter`` is denied."""
|
|
40
|
+
string = utility_builtins["string"]
|
|
41
|
+
# access successful in principle
|
|
42
|
+
assert string.ascii_lowercase == 'abcdefghijklmnopqrstuvwxyz'
|
|
43
|
+
with pytest.raises(NotImplementedError) as exc:
|
|
44
|
+
string.Formatter
|
|
45
|
+
assert 'string.Formatter is not safe' == str(exc.value)
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Results of doctest builder run on 2023-07-08 09:01:44
|
|
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/framework_usage
|
|
13
|
-
-------------------------------
|
|
14
|
-
2 items passed all tests:
|
|
15
|
-
1 tests in default
|
|
16
|
-
2 tests in own_policy
|
|
17
|
-
3 tests in 2 items.
|
|
18
|
-
3 passed and 0 failed.
|
|
19
|
-
Test passed.
|
|
20
|
-
|
|
21
|
-
Document: usage/basic_usage
|
|
22
|
-
---------------------------
|
|
23
|
-
1 items passed all tests:
|
|
24
|
-
4 tests in default
|
|
25
|
-
4 tests in 1 items.
|
|
26
|
-
4 passed and 0 failed.
|
|
27
|
-
Test passed.
|
|
28
|
-
|
|
29
|
-
Doctest summary
|
|
30
|
-
===============
|
|
31
|
-
20 tests
|
|
32
|
-
0 failures in tests
|
|
33
|
-
0 failures in setup code
|
|
34
|
-
0 failures in cleanup code
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.. include:: ../CHANGES.rst
|