Skip to content

Mark passwords and URIs as #[\SensitiveParameter] (PHP 8.2+) #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Commands/AuthenticateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ class AuthenticateCommand extends AbstractCommand
* @param string $charset
* @throws \InvalidArgumentException for invalid/unknown charset name
*/
public function __construct($user, $passwd, $dbname, $charset)
{
public function __construct(
$user,
#[\SensitiveParameter]
$passwd,
$dbname,
$charset
) {
if (!isset(self::$charsetMap[$charset])) {
throw new \InvalidArgumentException('Unsupported charset selected');
}
Expand Down
12 changes: 8 additions & 4 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ public function __construct(LoopInterface $loop = null, ConnectorInterface $conn
* @param string $uri
* @return PromiseInterface Promise<ConnectionInterface, Exception>
*/
public function createConnection($uri)
{
public function createConnection(
#[\SensitiveParameter]
$uri
) {
if (strpos($uri, '://') === false) {
$uri = 'mysql://' . $uri;
}
Expand Down Expand Up @@ -374,8 +376,10 @@ public function createConnection($uri)
* @param string $uri
* @return ConnectionInterface
*/
public function createLazyConnection($uri)
{
public function createLazyConnection(
#[\SensitiveParameter]
$uri
) {
return new LazyConnection($this, $uri, $this->loop);
}
}
8 changes: 6 additions & 2 deletions src/Io/LazyConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ class LazyConnection extends EventEmitter implements ConnectionInterface
private $idleTimer;
private $pending = 0;

public function __construct(Factory $factory, $uri, LoopInterface $loop)
{
public function __construct(
Factory $factory,
#[\SensitiveParameter]
$uri,
LoopInterface $loop
) {
$args = [];
\parse_str((string) \parse_url($uri, \PHP_URL_QUERY), $args);
if (isset($args['idle'])) {
Expand Down