diff --git a/CHANGELOG.md b/CHANGELOG.md index a3ff56e3..05c0faf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fix infinite loop / Gateway Timeout when a ticket's assigned technician and assigned group are changed simultaneously, caused by a synchronous actor removal during `pre_item_update()` - Fixed group reassignment to remove previously assigned groups only when using the Escalade reassignment action +- Use item-scoped access check on escalation routes ## [2.10.6] - 2026-07-31 diff --git a/front/climb_group.php b/front/climb_group.php index 7cac026f..5d1cf00e 100644 --- a/front/climb_group.php +++ b/front/climb_group.php @@ -48,7 +48,8 @@ $tickets_id = (int) $_REQUEST['tickets_id']; $ticket = new Ticket(); -if (!$ticket->getFromDB($tickets_id) || !$ticket->canAssign()) { + +if (!$ticket->getFromDB($tickets_id) || !$ticket->canAssign() || !$ticket->checkEntity(true)) { throw new AccessDeniedHttpException(); } diff --git a/front/ticket.form.php b/front/ticket.form.php index 43826575..b4d53dda 100644 --- a/front/ticket.form.php +++ b/front/ticket.form.php @@ -40,7 +40,8 @@ $tickets_id = (int) $_POST['tickets_id']; $ticket = new Ticket(); - if (!$ticket->getFromDB($tickets_id) || !$ticket->canAssign()) { + + if (!$ticket->getFromDB($tickets_id) || !$ticket->canAssign() || !$ticket->checkEntity(true)) { throw new AccessDeniedHttpException(); } diff --git a/tests/Units/EscalationAccessTest.php b/tests/Units/EscalationAccessTest.php new file mode 100644 index 00000000..d01b907e --- /dev/null +++ b/tests/Units/EscalationAccessTest.php @@ -0,0 +1,83 @@ +. + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/escalade + * ------------------------------------------------------------------------- + */ + +namespace GlpiPlugin\Escalade\Tests\Units; + +use GlpiPlugin\Escalade\Tests\EscaladeTestCase; +use ProfileRight; +use Ticket; + +final class EscalationAccessTest extends EscaladeTestCase +{ + private function setTechnicianTicketRight(int $right): void + { + ProfileRight::updateProfileRights( + getItemByTypeName('Profile', 'Technician', true), + ['ticket' => $right], + ); + } + + private function loadTicket(int $tickets_id): Ticket + { + $ticket = new Ticket(); + $ticket->getFromDB($tickets_id); + return $ticket; + } + + public function testAssignOnlyUserCanReachEscalationRoutes(): void + { + $this->initConfig(); + $tickets_id = $this->createItem(Ticket::class, ['name' => 'Escalation access test', 'content' => ''])->getID(); + + $this->setTechnicianTicketRight(Ticket::ASSIGN); + $this->login('tech', 'tech'); + + $ticket = $this->loadTicket($tickets_id); + $this->assertTrue( + $ticket->canAssign() && $ticket->checkEntity(), + 'A user with only the ASSIGN right must be allowed to reach escalation routes', + ); + } + + public function testUpdateOnlyUserCannotReachEscalationRoutes(): void + { + $this->initConfig(); + $tickets_id = $this->createItem(Ticket::class, ['name' => 'Escalation access test', 'content' => ''])->getID(); + + $this->setTechnicianTicketRight(UPDATE); + $this->login('tech', 'tech'); + + $ticket = $this->loadTicket($tickets_id); + $this->assertFalse( + (bool) $ticket->canAssign(), + 'A user with only the UPDATE right must not be allowed to reach escalation routes', + ); + } +}