You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
PHTML
38 lines
1.4 KiB
PHTML
|
2 weeks ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$routes = file_get_contents($root . '/config/routes.php');
|
||
|
|
$controller = file_get_contents($root . '/app/Controllers/Admin/TicketController.php');
|
||
|
|
$template = file_get_contents($root . '/resources/views/venix/admin/ticket/view.tpl');
|
||
|
|
|
||
|
|
$assert = static function ($condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$assert(
|
||
|
|
preg_match(
|
||
|
|
"#get\('/ticket/\{id\}/attachment/\{attachment_id:\[0-9\]\+\}',\s*'App\\\\Controllers\\\\Admin\\\\TicketController:attachment'\)->add\(new SuperAdmin\(\)\)#",
|
||
|
|
$routes
|
||
|
|
) === 1,
|
||
|
|
'Administrator ticket attachments must require the SuperAdmin middleware.'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
str_contains($controller, 'AdminDataMasker::sensitiveText((string) $ticketMain->title)')
|
||
|
|
&& str_contains($controller, "->assign('ticket_display_title'"),
|
||
|
|
'The administrator ticket title must use a dedicated masked display value.'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
str_contains($controller, 'AdminPermission::isSuperAdmin()')
|
||
|
|
&& str_contains($controller, 'if ($canViewAttachments)'),
|
||
|
|
'Attachment metadata must only be loaded for super administrators.'
|
||
|
|
);
|
||
|
|
$assert(
|
||
|
|
str_contains($template, '{$ticket_display_title')
|
||
|
|
&& !str_contains($template, '$ticket_main->title'),
|
||
|
|
'The administrator template must never fall back to the raw ticket title.'
|
||
|
|
);
|
||
|
|
|
||
|
|
echo "Administrator ticket privacy contract passed.\n";
|