Skip to content

Commit 48a92c5

Browse files
authored
Merge commit from fork
1 parent f4c1c1b commit 48a92c5

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

CHANGES.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
Changes
22
=======
33

4-
7.5 (unreleased)
4+
8.0 (unreleased)
55
----------------
66

7+
Backwards incompatible changes
8+
++++++++++++++++++++++++++++++
9+
10+
- Disallow ``try/except*`` clauses due to a possible sandbox escape and
11+
probable uselessness of this feature in the context of ``RestrictedPython``.
12+
In addition, remove ``ExceptionGroup`` from ``safe_builtins`` (as useful only
13+
with ``try/except*``). - This feature was introduced into
14+
``RestrictedPython`` in version 6.0 for Python 3.11+. (CVE-2025-22153)
15+
716
- Drop support for Python 3.8.
817

18+
Features
19+
++++++++
20+
921
- Update setuptools version pin.
1022
(`#292 <https://github.com/zopefoundation/RestrictedPython/issues/292>`_)
1123

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def read(*rnames):
2525

2626

2727
setup(name='RestrictedPython',
28-
version='7.5.dev0',
28+
version='8.0.dev0',
2929
url='https://github.com/zopefoundation/RestrictedPython',
3030
license='ZPL-2.1',
3131
description=(

src/RestrictedPython/Guards.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import builtins
1919

20-
from RestrictedPython._compat import IS_PY311_OR_GREATER
2120
from RestrictedPython.transformer import INSPECT_ATTRIBUTES
2221

2322

@@ -106,9 +105,6 @@
106105
'ZeroDivisionError',
107106
]
108107

109-
if IS_PY311_OR_GREATER:
110-
_safe_exceptions.append("ExceptionGroup")
111-
112108
for name in _safe_names:
113109
safe_builtins[name] = getattr(builtins, name)
114110

src/RestrictedPython/transformer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,8 +1141,8 @@ def visit_Try(self, node):
11411141
return self.node_contents_visit(node)
11421142

11431143
def visit_TryStar(self, node):
1144-
"""Allow `ExceptionGroup` without restrictions."""
1145-
return self.node_contents_visit(node)
1144+
"""Disallow `ExceptionGroup` due to a potential sandbox escape."""
1145+
self.not_allowed(node)
11461146

11471147
def visit_ExceptHandler(self, node):
11481148
"""Protect exception handlers."""

tests/transformer/test_try.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,13 @@ def try_except_star(m):
6868
not IS_PY311_OR_GREATER,
6969
reason="ExceptionGroup class was added in Python 3.11.",
7070
)
71-
def test_RestrictingNodeTransformer__visit_TryStar__1(mocker):
72-
"""It allows try-except* PEP 654 statements."""
73-
trace = mocker.stub()
74-
restricted_exec(TRY_EXCEPT_STAR)['try_except_star'](trace)
75-
76-
trace.assert_has_calls([
77-
mocker.call('try'),
78-
mocker.call('IndentationError'),
79-
mocker.call('ValueError')
80-
])
81-
82-
with pytest.raises(AssertionError):
83-
trace.assert_has_calls([mocker.call('RuntimeError')])
71+
def test_RestrictingNodeTransformer__visit_TryStar__1():
72+
"""It denies try-except* PEP 654 statements."""
73+
result = compile_restricted_exec(TRY_EXCEPT_STAR)
74+
assert result.errors == (
75+
'Line 3: TryStar statements are not allowed.',
76+
)
77+
assert result.code is None
8478

8579

8680
TRY_FINALLY = """

0 commit comments

Comments
 (0)