diff --git a/frappe/utils/safe_exec.py b/frappe/utils/safe_exec.py index 4a6ac7b551..9a61e2a78e 100644 --- a/frappe/utils/safe_exec.py +++ b/frappe/utils/safe_exec.py @@ -13,6 +13,7 @@ from typing import TYPE_CHECKING, Any import orjson import RestrictedPython.Guards +from AccessControl.ZopeGuards import protected_inplacevar from RestrictedPython import PrintCollector, compile_restricted, safe_globals from RestrictedPython.transformer import RestrictingNodeTransformer @@ -313,6 +314,7 @@ def get_safe_globals(): # allow iterators and list comprehension out._getiter_ = iter out._iter_unpack_sequence_ = RestrictedPython.Guards.guarded_iter_unpack_sequence + out._inplacevar_ = protected_inplacevar # add common python builtins out.update(get_python_builtins()) @@ -729,6 +731,7 @@ WHITELISTED_SAFE_EVAL_GLOBALS = { "_getitem_": _getitem, "_getiter_": iter, "_iter_unpack_sequence_": RestrictedPython.Guards.guarded_iter_unpack_sequence, + "_inplacevar_": protected_inplacevar, } SAFE_ORJSON = NamespaceDict(loads=orjson.loads, dumps=orjson.dumps) diff --git a/pyproject.toml b/pyproject.toml index 548f69b237..fdd990e616 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,6 +26,7 @@ dependencies = [ "PyQRCode~=1.2.1", "PyYAML~=6.0.2", "RestrictedPython~=8.0", + "AccessControl~=7.2", "WeasyPrint==59.0", "pydyf==0.11.0", "Werkzeug==3.1.3",