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.
39 lines
1.5 KiB
PHP
39 lines
1.5 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$routes = file_get_contents($root . '/config/routes.php');
|
|
$controller = file_get_contents($root . '/app/Controllers/Admin/TicketController.php');
|
|
$readModel = file_get_contents($root . '/app/Services/Ticket/TicketReadModel.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($readModel, 'AdminDataMasker::sensitiveText($title)')
|
|
&& str_contains($controller, "->assign('ticket_display_title', \$thread['title'])"),
|
|
'The administrator ticket title must use a dedicated masked display value.'
|
|
);
|
|
$assert(
|
|
str_contains($controller, 'AdminPermission::isSuperAdmin()')
|
|
&& str_contains($readModel, 'if (!$viewer->isAdmin || $viewer->isSuperAdmin)'),
|
|
'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";
|