Skip to content

Commit

Permalink
fix overwriting original vars when logging
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 6f23f89 commit 79e899a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/private/Log/ExceptionSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,16 @@ private function filterTrace(array $trace) {
}

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) {
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/Log/ExceptionSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public function testSerializer() {
$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]);
}
}
}

0 comments on commit 79e899a

Please sign in to comment.