38 $this->allowedTags =
$tags;
43 $this->allowedFilters = $filters;
48 $this->allowedMethods = array();
49 foreach ($methods as $class =>
$m) {
50 $this->allowedMethods[$class] = array_map(
'strtolower', is_array(
$m) ?
$m : array(
$m));
56 $this->allowedProperties = $properties;
61 $this->allowedFunctions = $functions;
67 if (!in_array(
$tag, $this->allowedTags)) {
72 foreach ($filters as $filter) {
73 if (!in_array($filter, $this->allowedFilters)) {
79 if (!in_array(
$function, $this->allowedFunctions)) {
92 $method = strtolower($method);
93 foreach ($this->allowedMethods as $class => $methods) {
94 if ($obj instanceof $class) {
95 $allowed = in_array($method, $methods);
102 $class = get_class($obj);
110 foreach ($this->allowedProperties as $class => $properties) {
111 if ($obj instanceof $class) {
112 $allowed = in_array($property, is_array($properties) ? $properties : array($properties));
119 $class = get_class($obj);
125class_alias(
'Twig_Sandbox_SecurityPolicy',
'Twig\Sandbox\SecurityPolicy',
false);
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Exception thrown when a not allowed filter is used in a template.
Exception thrown when a not allowed function is used in a template.
Exception thrown when a not allowed class method is used in a template.
Exception thrown when a not allowed class property is used in a template.
Exception thrown when a not allowed tag is used in a template.
Represents a security policy which need to be enforced when sandbox mode is enabled.
checkSecurity($tags, $filters, $functions)
setAllowedFilters(array $filters)
setAllowedProperties(array $properties)
setAllowedFunctions(array $functions)
setAllowedMethods(array $methods)
__construct(array $allowedTags=array(), array $allowedFilters=array(), array $allowedMethods=array(), array $allowedProperties=array(), array $allowedFunctions=array())
setAllowedTags(array $tags)
checkPropertyAllowed($obj, $property)
checkMethodAllowed($obj, $method)
Interfaces that all security policy classes must implements.
Interface implemented by all compiled templates.
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag