allowedTags, true)) { throw new SecurityNotAllowedTagError(\sprintf('Tag "%s" is not allowed.', $tag), $tag); } } foreach ($filters as $filter) { if (!\in_array($filter, $this->allowedFilters, true)) { throw new SecurityNotAllowedFilterError(\sprintf('Filter "%s" is not allowed.', $filter), $filter); } } foreach ($functions as $function) { if (!\in_array($function, $this->allowedFunctions, true)) { throw new SecurityNotAllowedFunctionError(\sprintf('Function "%s" is not allowed.', $function), $function); } } } public function checkMethodAllowed($obj, $method): void { if ($obj instanceof UnicodeString) { return; } if ($obj instanceof ServerBag) { throw new SecurityNotAllowedMethodError('Tried to access server environment', ServerBag::class, $method); } if ($obj instanceof SessionInterface) { throw new SecurityNotAllowedMethodError('Tried to access session', SessionInterface::class, $method); } $lcm = strtolower($method); if ($obj instanceof PdfContext) { if ($lcm !== 'setoption') { throw new SecurityNotAllowedMethodError('Tried to access forbidden method on PdfContext', PdfContext::class, $method); } return; } if ($obj instanceof MetaTableTypeInterface && $lcm === 'merge') { return; } if ($obj instanceof Request) { if (!str_starts_with($lcm, 'get')) { throw new SecurityNotAllowedMethodError('Tried to call setter() of app variable', AppVariable::class, $method); } return; } if ($obj instanceof AppVariable) { if (!\in_array($lcm, ['getrequest', 'getuser', 'getlocale'], true)) { throw new SecurityNotAllowedMethodError('Tried to access forbidden app variable method', User::class, $method); } return; } if (!str_starts_with($lcm, 'get') && !str_starts_with($lcm, 'has') && !str_starts_with($lcm, 'is') && $lcm !== '__tostring') { throw new SecurityNotAllowedMethodError('Tried to access non-read method', $obj::class, $method); } if ($obj instanceof User) { if (str_contains($lcm, 'password') || str_contains($lcm, 'totp') || str_contains($lcm, 'api') || str_contains($lcm, 'secret') || str_contains($lcm, 'token') ) { throw new SecurityNotAllowedMethodError('Tried to access user secrets', User::class, $method); } } } public function checkPropertyAllowed($obj, $property): void { } }