From 6399b545a7c5f4485548b8b809aa4e606bc05a03 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 26 Oct 2026 16:39:31 +0100 Subject: [PATCH] fix(debugging): Redact chat-relay comments in debug log Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Joas Schilling --- lib/Signaling/BackendNotifier.php | 5 ++ tests/php/Signaling/BackendNotifierTest.php | 77 +++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 tests/php/Signaling/BackendNotifierTest.php diff --git a/lib/Signaling/BackendNotifier.php b/lib/Signaling/BackendNotifier.php index 80fa28e6293..a5ed9fc2b2b 100644 --- a/lib/Signaling/BackendNotifier.php +++ b/lib/Signaling/BackendNotifier.php @@ -610,6 +610,11 @@ public function sendRoomMessage(Room $room, array $message): void { ], ]); $duration = microtime(true) - $start; + + // Don't log chat messages to not leak the content + if (isset($message['chat']['comment'])) { + $message['chat']['comment'] = '[redacted #' . ($message['chat']['comment']['id'] ?? 'null') . ']'; + } $this->logger->debug('Send room message: {token} {message} ({duration})', [ 'token' => $room->getToken(), 'message' => $message, diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php new file mode 100644 index 00000000000..1eaf0a061ef --- /dev/null +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -0,0 +1,77 @@ +logger = $this->createMock(LoggerInterface::class); + $this->backendNotifier = new BackendNotifier( + $this->createMock(Config::class), + $this->createMock(IAppConfig::class), + $this->logger, + $this->createMock(IClientService::class), + $this->createMock(ISecureRandom::class), + $this->createMock(Manager::class), + $this->createMock(ParticipantService::class), + $this->createMock(IURLGenerator::class), + $this->createMock(RoomPropertiesHelper::class), + ); + } + + public static function dataSendRoomMessageLog(): array { + return [ + 'chat message' => [ + ['type' => 'chat', 'chat' => ['refresh' => true, 'comment' => ['id' => 42, 'actorDisplayName' => 'Alice', 'message' => 'Secret', 'parent' => ['message' => 'Secret parent']]]], + ['type' => 'chat', 'chat' => ['refresh' => true, 'comment' => '[redacted #42]']], + ], + 'chat refresh' => [ + ['type' => 'chat', 'chat' => ['refresh' => true]], + ['type' => 'chat', 'chat' => ['refresh' => true]], + ], + 'recording' => [ + ['type' => 'recording', 'recording' => ['status' => 1]], + ['type' => 'recording', 'recording' => ['status' => 1]], + ], + ]; + } + + #[DataProvider('dataSendRoomMessageLog')] + public function testSendRoomMessageLog(array $message, array $expected): void { + $room = $this->createMock(Room::class); + $room->method('getToken')->willReturn('token'); + + $this->logger->expects($this->once()) + ->method('debug') + ->with('Send room message: {token} {message} ({duration})', $this->callback(function (array $context) use ($expected): bool { + $this->assertSame($expected, $context['message']); + return true; + })); + + $this->backendNotifier->sendRoomMessage($room, $message); + } +}