From f9270b21e88456fb58d1568d75fa641ba26a0f92 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 16 Jun 2022 13:50:59 +0200 Subject: [PATCH] make placeholder a const for reuse Signed-off-by: Arthur Schiwon --- lib/private/Log/ExceptionSerializer.php | 6 ++++-- tests/lib/Log/ExceptionSerializerTest.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php index fc9e4cc1bd0ad..1eba042fa15ee 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -42,6 +42,8 @@ use OCA\Encryption\Session; class ExceptionSerializer { + public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameters replaced ***'; + public const methodsWithSensitiveParameters = [ // Session/User 'completeLogin', @@ -180,7 +182,7 @@ private function editTrace(array &$sensitiveValues, array $traceLine): array { if (isset($traceLine['args'])) { $sensitiveValues = array_merge($sensitiveValues, $traceLine['args']); } - $traceLine['args'] = ['*** sensitive parameters replaced ***']; + $traceLine['args'] = [self::SENSITIVE_VALUE_PLACEHOLDER]; return $traceLine; } @@ -211,7 +213,7 @@ private function removeValuesFromArgs($args, $values) { $workArgs = []; foreach ($args as $arg) { if (in_array($arg, $values, true)) { - $arg = '*** sensitive parameter replaced ***'; + $arg = self::SENSITIVE_VALUE_PLACEHOLDER; } elseif (is_array($arg)) { $arg = $this->removeValuesFromArgs($arg, $values); } diff --git a/tests/lib/Log/ExceptionSerializerTest.php b/tests/lib/Log/ExceptionSerializerTest.php index 02d91b726e2e4..ea9a52179f5c9 100644 --- a/tests/lib/Log/ExceptionSerializerTest.php +++ b/tests/lib/Log/ExceptionSerializerTest.php @@ -62,7 +62,7 @@ public function testSerializer() { } catch (\Exception $e) { $serializedData = $this->serializer->serializeException($e); $this->assertSame(['Secret'], $secret); - $this->assertSame('*** sensitive parameters replaced ***', $serializedData['Trace'][0]['args'][0]); + $this->assertSame(ExceptionSerializer::SENSITIVE_VALUE_PLACEHOLDER, $serializedData['Trace'][0]['args'][0]); } } }