mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
make placeholder a const for reuse
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
ed4fcf2d17
commit
6b8d6de4fc
2 changed files with 5 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue