Commit 08ce94e3 authored by Evan Simpson's avatar Evan Simpson

Incorporated changes to security machinery for Zope 2.4

parent 82035aa4
...@@ -15,3 +15,4 @@ Page Template changes ...@@ -15,3 +15,4 @@ Page Template changes
Bugs Fixed Bugs Fixed
- The various *Python modules failed to import CompilerError. - The various *Python modules failed to import CompilerError.
- Security machinery changes in Zope 2.4 broke ZRPythonExpr
...@@ -88,10 +88,11 @@ ...@@ -88,10 +88,11 @@
Handler for Python expressions that uses the RestrictedPython package. Handler for Python expressions that uses the RestrictedPython package.
""" """
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from AccessControl import full_read_guard, full_write_guard, \ from AccessControl import full_read_guard, full_write_guard, \
safe_builtins, getSecurityManager safe_builtins, getSecurityManager
from AccessControl.ZopeGuards import guarded_getattr, guarded_getitem
from RestrictedPython import compile_restricted_eval from RestrictedPython import compile_restricted_eval
from TALES import CompilerError from TALES import CompilerError
from string import strip, split, join, replace, lstrip from string import strip, split, join, replace, lstrip
...@@ -101,8 +102,8 @@ from PythonExpr import PythonExpr ...@@ -101,8 +102,8 @@ from PythonExpr import PythonExpr
class PythonExpr(PythonExpr): class PythonExpr(PythonExpr):
_globals = {'__debug__': __debug__, _globals = {'__debug__': __debug__,
'__builtins__': safe_builtins, '__builtins__': safe_builtins,
'_read_': full_read_guard, '_getattr_': guarded_getattr,
'_write_': full_write_guard,} '_getitem_': guarded_getitem,}
def __init__(self, name, expr, engine): def __init__(self, name, expr, engine):
self.expr = expr = replace(strip(expr), '\n', ' ') self.expr = expr = replace(strip(expr), '\n', ' ')
code, err, warn, use = compile_restricted_eval(expr, str(self)) code, err, warn, use = compile_restricted_eval(expr, str(self))
...@@ -133,7 +134,7 @@ def call_with_ns(f, ns, arg=1): ...@@ -133,7 +134,7 @@ def call_with_ns(f, ns, arg=1):
td = TemplateDict() td = TemplateDict()
td.this = None td.this = None
td._push(ns['request']) td._push(ns['request'])
td._push(InstanceDict(ns['here'], td, full_read_guard)) td._push(InstanceDict(ns['here'], td, guarded_getattr))
td._push(ns) td._push(ns)
try: try:
if arg==2: if arg==2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment