Merge pull request #188 from copenhagentruckwash/propose-fix-for-relay-control-bypass-vulnerability

Fix self-serve relay sync to enforce lane safety guards
This commit is contained in:
Jeppe B
2026-06-01 22:33:11 +02:00
committed by GitHub
2 changed files with 9 additions and 9 deletions
@@ -579,13 +579,13 @@ class departmentsRoute
// Self-serve enabled: keep machine stack off. // Self-serve enabled: keep machine stack off.
$this->setOptionalLaneRelayState($lane, 'relay_machine_program_picker_id', static function () use ($lane): void { $this->setOptionalLaneRelayState($lane, 'relay_machine_program_picker_id', static function () use ($lane): void {
$lane->setMachineProgramPickerRelayStatusHard(false); $lane->setMachineProgramPickerRelayStatus(false);
}); });
$this->setOptionalLaneRelayState($lane, 'relay_machine_cleaner_id', static function () use ($lane): void { $this->setOptionalLaneRelayState($lane, 'relay_machine_cleaner_id', static function () use ($lane): void {
$lane->setMachineCleanerRelayStatusHard(false); $lane->setMachineCleanerRelayStatus(false);
}); });
try { try {
$lane->setMachineRelayStatusHard(false); $lane->setMachineRelayStatus(false);
} catch (\Throwable) {} } catch (\Throwable) {}
} }
} }
@@ -8,10 +8,10 @@ it('syncs lane relay states when department self-serve enabled flag changes', fu
expect($routeContent)->toContain('$this->syncDepartmentSelfServeRelayStates((int)$department->id, $enabled);'); expect($routeContent)->toContain('$this->syncDepartmentSelfServeRelayStates((int)$department->id, $enabled);');
expect($routeContent)->toContain('if (!$enabled) {'); expect($routeContent)->toContain('if (!$enabled) {');
expect($routeContent)->toContain('// Self-serve disabled: do not mutate lane relay states.'); expect($routeContent)->toContain('// Self-serve disabled: do not mutate lane relay states.');
expect($routeContent)->toContain('setMachineProgramPickerRelayStatusHard(false)'); expect($routeContent)->toContain('setMachineProgramPickerRelayStatus(false)');
expect($routeContent)->toContain('setMachineCleanerRelayStatusHard(false)'); expect($routeContent)->toContain('setMachineCleanerRelayStatus(false)');
expect($routeContent)->toContain('setMachineRelayStatusHard(false)'); expect($routeContent)->toContain('setMachineRelayStatus(false)');
expect($routeContent)->not->toContain('setMachineCleanerRelayStatusHard(true)'); expect($routeContent)->not->toContain('setMachineProgramPickerRelayStatusHard(false)');
expect($routeContent)->not->toContain('setMachineRelayStatusHard(true)'); expect($routeContent)->not->toContain('setMachineCleanerRelayStatusHard(false)');
expect($routeContent)->not->toContain('setMachineProgramPickerRelayStatusHard(true)'); expect($routeContent)->not->toContain('setMachineRelayStatusHard(false)');
}); });