function SecurityPolicy::checkSecurity
Overrides SecurityPolicyInterface::checkSecurity
File
-
vendor/
twig/ twig/ src/ Sandbox/ SecurityPolicy.php, line 67
Class
- SecurityPolicy
- Represents a security policy which need to be enforced when sandbox mode is enabled.
Namespace
Twig\SandboxCode
public function checkSecurity($tags, $filters, $functions) : void {
foreach ($tags as $tag) {
if (!\in_array($tag, $this->allowedTags)) {
if ('extends' === $tag) {
trigger_deprecation('twig/twig', '3.12', 'The "extends" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitly in your sandbox policy if needed.');
}
elseif ('use' === $tag) {
trigger_deprecation('twig/twig', '3.12', 'The "use" tag is always allowed in sandboxes, but won\'t be in 4.0, please enable it explicitly in your sandbox policy if needed.');
}
else {
throw new SecurityNotAllowedTagError(\sprintf('Tag "%s" is not allowed.', $tag), $tag);
}
}
}
foreach ($filters as $filter) {
if (!\in_array($filter, $this->allowedFilters)) {
throw new SecurityNotAllowedFilterError(\sprintf('Filter "%s" is not allowed.', $filter), $filter);
}
}
foreach ($functions as $function) {
if (!\in_array($function, $this->allowedFunctions)) {
throw new SecurityNotAllowedFunctionError(\sprintf('Function "%s" is not allowed.', $function), $function);
}
}
}