diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-06-16 13:50:59 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2022-06-16 18:38:29 +0200 |
commit | 8b2b5946e60cc81515c6e3ac7462148d81d7acbc (patch) | |
tree | 0daeb061c81763164fe1ae6ec7d0a0dcf4e2dd54 | |
parent | 891c10d09da333e6af172bacd0c28540fd7a7032 (diff) | |
download | nextcloud-server-8b2b5946e60cc81515c6e3ac7462148d81d7acbc.tar.gz nextcloud-server-8b2b5946e60cc81515c6e3ac7462148d81d7acbc.zip |
make placeholder a const for reuse
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r-- | lib/private/Log/ExceptionSerializer.php | 6 | ||||
-rw-r--r-- | 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 a792f966eda..3c3ff95f8e1 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -42,6 +42,8 @@ use OCA\Encryption\Session; use OCP\HintException; class ExceptionSerializer { + public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameters replaced ***'; + public const methodsWithSensitiveParameters = [ // Session/User 'completeLogin', @@ -180,7 +182,7 @@ class ExceptionSerializer { 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 @@ class ExceptionSerializer { $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 f8cc6b77ee6..70ac80d13e3 100644 --- a/tests/lib/Log/ExceptionSerializerTest.php +++ b/tests/lib/Log/ExceptionSerializerTest.php @@ -62,7 +62,7 @@ class ExceptionSerializerTest extends TestCase { } 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]); } } } |