fix overwriting original vars when logging

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2022-06-16 13:30:52 +02:00
parent 6f1b612770
commit bf5487482d
No known key found for this signature in database
GPG key ID: 7424F1874854DF23
2 changed files with 6 additions and 3 deletions

View file

@ -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) {

View file

@ -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]);
}
}
}