Skip to content
Myr

extra security

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 76c280b · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:jinja2/sandbox.py+9 added-2 removed
10 unmodified lines
1112 :copyright: Copyright 2008 by Armin Ronacher.13 :license: BSD.14"""15from types import FunctionType, MethodType15from types import FunctionType, MethodType, TracebackType, CodeType, \16 FrameType, GeneratorType17from jinja2.runtime import Undefined18from jinja2.environment import Environment1920
45 unmodified lines
66 return attr not in UNSAFE_FUNCTION_ATTRIBUTES67 if isinstance(obj, MethodType):68 return attr not in UNSAFE_FUNCTION_ATTRIBUTES and \69 attr not in UNSAFE_METHOD_ATTRIBUTES70 if isinstance(obj, type):71 return attr != 'mro'72 if isinstance(obj, (CodeType, TracebackType, FrameType)):73 return False74 if isinstance(obj, GeneratorType):75 return attr != 'gi_frame'76 return True7778 def is_safe_callable(self, obj):79 """Check if an object is safely callable. Per default a function is
22 unmodified lines
102 return self.undefined('access to attribute %r of %r object is'103 ' unsafe.' % (104 argument,105 obj.__class__.__name__99 ))106 ), name=argument)107 return self.undefined(obj=obj, name=argument)108109 def call(__self, __obj, *args, **kwargs):110 """Call an object from sandboxed code."""
5 unmodified lines