mirror of
https://github.com/nextcloud/server.git
synced 2026-02-13 15:54:59 -05:00
fix overwriting original vars when logging
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
6f1b612770
commit
bf5487482d
2 changed files with 6 additions and 3 deletions
|
|
@ -208,14 +208,16 @@ class ExceptionSerializer {
|
|||
}
|
||||
|
||||
private function removeValuesFromArgs($args, $values) {
|
||||
foreach ($args as &$arg) {
|
||||
$workArgs = [];
|
||||
foreach ($args as $arg) {
|
||||
if (in_array($arg, $values, true)) {
|
||||
$arg = '*** sensitive parameter replaced ***';
|
||||
} elseif (is_array($arg)) {
|
||||
$arg = $this->removeValuesFromArgs($arg, $values);
|
||||
}
|
||||
$workArgs[] = $arg;
|
||||
}
|
||||
return $args;
|
||||
return $workArgs;
|
||||
}
|
||||
|
||||
private function encodeTrace($trace) {
|
||||
|
|
|
|||
|
|
@ -60,8 +60,9 @@ class ExceptionSerializerTest extends TestCase {
|
|||
$secret = ['Secret'];
|
||||
$this->emit([&$secret]);
|
||||
} catch (\Exception $e) {
|
||||
$this->serializer->serializeException($e);
|
||||
$serializedData = $this->serializer->serializeException($e);
|
||||
$this->assertSame(['Secret'], $secret);
|
||||
$this->assertSame('*** sensitive parameters replaced ***', $serializedData['Trace'][0]['args'][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue