class SandboxedEnvironment(Environment):
Known subclasses: jinja2.sandbox.ImmutableSandboxedEnvironment
The sandboxed environment. It works like the regular environment but tells the compiler to generate sandboxed code. Additionally subclasses of this environment may override the methods that tell the runtime what attributes or functions are safe to access.
If the template tries to access insecure code a SecurityError
is
raised. However also other exceptions may occur during the rendering so
the caller has to ensure that all exceptions are caught.
Method | call_binop |
For intercepted binary operator calls (intercepted_binops ) this function is executed instead of the builtin operator. This can be used to fine tune the behavior of certain operators. |
Method | call_unop |
For intercepted unary operator calls (intercepted_unops ) this function is executed instead of the builtin operator. This can be used to fine tune the behavior of certain operators. |
Method | is_safe_attribute |
No summary |
Method | is_safe_callable |
Check if an object is safely callable. By default callables are considered safe unless decorated with unsafe . |
Class Variable | default_binop_table |
Undocumented |
Class Variable | default_unop_table |
Undocumented |
Class Variable | intercepted_binops |
Undocumented |
Class Variable | intercepted_unops |
Undocumented |
Method | __init__ |
Undocumented |
Method | call |
Call an object from sandboxed code. |
Method | format_string |
If a format call is detected, then this is routed through this method so that our safety sandbox can be used for it. |
Method | getattr |
Subscribe an object from sandboxed code and prefer the attribute. The attribute passed must be a bytestring. |
Method | getitem |
Subscribe an object from sandboxed code. |
Method | unsafe_undefined |
Return an undefined object for unsafe attributes. |
Class Variable | sandboxed |
Undocumented |
Instance Variable | binop_table |
Undocumented |
Instance Variable | unop_table |
Undocumented |
For intercepted binary operator calls (intercepted_binops
)
this function is executed instead of the builtin operator. This can
be used to fine tune the behavior of certain operators.
Parameters | |
context:Context | Undocumented |
operator:str | Undocumented |
left:t.Any | Undocumented |
right:t.Any | Undocumented |
Returns | |
t.Any | Undocumented |
For intercepted unary operator calls (intercepted_unops
)
this function is executed instead of the builtin operator. This can
be used to fine tune the behavior of certain operators.
Parameters | |
context:Context | Undocumented |
operator:str | Undocumented |
arg:t.Any | Undocumented |
Returns | |
t.Any | Undocumented |
jinja2.sandbox.ImmutableSandboxedEnvironment
is_internal_attribute
function.Parameters | |
obj:t.Any | Undocumented |
attr:str | Undocumented |
value:t.Any | Undocumented |
Returns | |
bool | Undocumented |
Check if an object is safely callable. By default callables
are considered safe unless decorated with unsafe
.
This also recognizes the Django convention of setting func.alters_data = True.
Parameters | |
obj:t.Any | Undocumented |
Returns | |
bool | Undocumented |
Undocumented
Parameters | |
*args:t.Any | Undocumented |
**kwargs:t.Any | Undocumented |
Parameters | |
__self | Undocumented |
__context:Context | Undocumented |
__obj:t.Any | Undocumented |
*args:t.Any | Undocumented |
**kwargs:t.Any | Undocumented |
Returns | |
t.Any | Undocumented |
Parameters | |
s:str | Undocumented |
args:t.Tuple[ | Undocumented |
kwargs:t.Dict[ | Undocumented |
format_func:t.Optional[ | Undocumented |
Returns | |
str | Undocumented |
Parameters | |
obj:t.Any | Undocumented |
attribute:str | Undocumented |
Returns | |
t.Union[ | Undocumented |
Parameters | |
obj:t.Any | Undocumented |
argument:t.Union[ | Undocumented |
Returns | |
t.Union[ | Undocumented |
Parameters | |
obj:t.Any | Undocumented |
attribute:str | Undocumented |
Returns | |
Undefined | Undocumented |