Skip to content

Commit

Permalink
make placeholder a const for reuse
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Jun 16, 2022
1 parent d2143b2 commit 5da846c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/private/Log/ExceptionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
use OCP\HintException;

class ExceptionSerializer {
public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameter replaced ***';

public const methodsWithSensitiveParameters = [
// Session/User
'completeLogin',
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Log/ExceptionSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,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]);
}
}
}

0 comments on commit 5da846c

Please sign in to comment.