Skip to content

Commit

Permalink
Merge pull request #5345 from andrew-demb/avoid-log-connection-url
Browse files Browse the repository at this point in the history
Redact connection URL from logs as it may contain sensitive data
  • Loading branch information
malarzm committed Apr 5, 2022
2 parents 1062be9 + 07496af commit 719663b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Logging/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ private function maskPassword(array $params): array
$params['password'] = '<redacted>';
}

if (isset($params['url'])) {
$params['url'] = '<redacted>';
}

return $params;
}
}
2 changes: 2 additions & 0 deletions tests/Logging/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testConnectAndDisconnect(): void
'params' => [
'username' => 'admin',
'password' => '<redacted>',
'url' => '<redacted>',
],
],
],
Expand All @@ -54,6 +55,7 @@ public function testConnectAndDisconnect(): void
$this->driver->connect([
'username' => 'admin',
'password' => 'Passw0rd!',
'url' => 'mysql://user:secret@localhost/mydb',
]);
}

Expand Down

0 comments on commit 719663b

Please sign in to comment.