8000 [AMQP] [Messenger] Do not leak any credentials when connection fails · symfony/symfony@5812a49 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5812a49

Browse files
ruudkfabpot
authored andcommitted
[AMQP] [Messenger] Do not leak any credentials when connection fails
I noticed that when the connection to AMQP fails for whatever reason all the DSK credentials are leaked. Yes, the password is masked. But it still leaks the server, port and username. I think these things should be private and not be logged to a logger server or error capture service.
1 parent 8a33e05 commit 5812a49

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/Symfony/Component/Messenger/Bridge/Amqp/Tests/Transport/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,10 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
559559
$connection->publish('{}', [], 120000);
560560
}
561561

562-
public function testObfuscatePasswordInDsn()
562+
public function testNoCredentialLeakageWhenConnectionFails()
563563
{
564564
$this->expectException(\AMQPException::class);
565-
$this->expectExceptionMessage('Could not connect to the AMQP server. Please verify the provided DSN. ({"host":"localhost","port":5672,"vhost":"/","login":"user","password":"********"})');
565+
$this->expectExceptionMessage('Could not connect to the AMQP server. Please verify the provided DSN.');
566566
$factory = new TestAmqpFactory(
567567
$amqpConnection = $this->createMock(\AMQPConnection::class),
568568
$amqpChannel = $this->createMock(\AMQPChannel::class),

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,7 @@ public function channel(): \AMQPChannel
495495
try {
496496
$connection->{$connectMethod}();
497497
} catch (\AMQPConnectionException $e) {
498-
$credentials = $this->connectionOptions;
499-
$credentials['password'] = '********';
500-
unset($credentials['delay']);
501-
502-
throw new \AMQPException(sprintf('Could not connect to the AMQP server. Please verify the provided DSN. (%s).', json_encode($credentials, \JSON_UNESCAPED_SLASHES)), 0, $e);
498+
throw new \AMQPException('Could not connect to the AMQP server. Please verify the provided DSN.', 0, $e);
503499
}
504500
$this->amqpChannel = $this->amqpFactory->createChannel($connection);
505501

0 commit comments

Comments
 (0)
0