class TwigSandboxPolicy

Default sandbox policy for Twig templates.

Twig's sandbox extension is usually used to evaluate untrusted code by limiting access to potentially unsafe properties or methods. Since we do not use ViewModels when passing objects to Twig templates, we limit what those objects can do by whitelisting certain classes, method names, and method names with an allowed prefix. All object properties may be accessed.

Hierarchy

File

core/lib/Drupal/Core/Template/TwigSandboxPolicy.php, line 16

Namespace

Drupal\Core\Template

Members

Name Modifiers Type Description
TwigSandboxPolicy::$whitelisted_classes protected property An array of class names for which any method calls are allowed.
TwigSandboxPolicy::$whitelisted_methods protected property An array of whitelisted methods in the form of methodName => TRUE.
TwigSandboxPolicy::$whitelisted_prefixes protected property An array of whitelisted method prefixes -- any method starting with one of these prefixes will be allowed.
TwigSandboxPolicy::checkMethodAllowed public function Overrides Twig_Sandbox_SecurityPolicyInterface::checkMethodAllowed
TwigSandboxPolicy::checkPropertyAllowed public function Overrides Twig_Sandbox_SecurityPolicyInterface::checkPropertyAllowed
TwigSandboxPolicy::checkSecurity public function Overrides Twig_Sandbox_SecurityPolicyInterface::checkSecurity
TwigSandboxPolicy::__construct public function Constructs a new TwigSandboxPolicy object.

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Template!TwigSandboxPolicy.php/class/TwigSandboxPolicy/8.1.x