File tree Expand file tree Collapse file tree 5 files changed +23
-21
lines changed Expand file tree Collapse file tree 5 files changed +23
-21
lines changed Original file line number Diff line number Diff line change 11Changes
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
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def read(*rnames):
2525
2626
2727setup (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 = (
Original file line number Diff line number Diff line change 1717
1818import builtins
1919
20- from RestrictedPython ._compat import IS_PY311_OR_GREATER
2120from RestrictedPython .transformer import INSPECT_ATTRIBUTES
2221
2322
106105 'ZeroDivisionError' ,
107106]
108107
109- if IS_PY311_OR_GREATER :
110- _safe_exceptions .append ("ExceptionGroup" )
111-
112108for name in _safe_names :
113109 safe_builtins [name ] = getattr (builtins , name )
114110
Original file line number Diff line number Diff 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."""
Original file line number Diff line number Diff 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
8680TRY_FINALLY = """
You can’t perform that action at this time.
0 commit comments