This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new 976e2181c NO-JIRA: avoid logging AMQP credentials in python binding
976e2181c is described below
commit 976e2181c4c1daa6b84fd81465a0ca5cb98b39b8
Author: Kevin SERIN <[email protected]>
AuthorDate: Fri May 22 17:45:13 2026 +0200
NO-JIRA: avoid logging AMQP credentials in python binding
---
python/proton/_url.py | 3 +--
python/tests/proton_tests/url.py | 20 +++++++++-----------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/python/proton/_url.py b/python/proton/_url.py
index 5741afde3..c50e58384 100644
--- a/python/proton/_url.py
+++ b/python/proton/_url.py
@@ -229,8 +229,7 @@ class Url:
if self.username:
userpart += quote(self.username)
if self.password:
- userpart += ':'
- userpart += quote(self.password)
+ userpart += ':***'
if self.username or self.password:
userpart += '@'
return userpart + hostport
diff --git a/python/tests/proton_tests/url.py b/python/tests/proton_tests/url.py
index 9e2fe05c1..09c4970aa 100644
--- a/python/tests/proton_tests/url.py
+++ b/python/tests/proton_tests/url.py
@@ -35,24 +35,22 @@ class UrlTest(common.Test):
def testUrl(self):
url = Url('amqp://me:secret@myhost:1234/foobar')
- self.assertEqual(str(url), "amqp://me:secret@myhost:1234/foobar")
+ self.assertEqual(str(url), "amqp://me:***@myhost:1234/foobar")
self.assertUrl(url, 'amqp', 'me', 'secret', 'myhost', 1234, 'foobar')
- self.assertEqual(str(url), "amqp://me:secret@myhost:1234/foobar")
def testIpV6Url(self):
url = Url('amqp://me:secret@[::1]:1234/foobar')
- self.assertEqual(str(url), "amqp://me:secret@[::1]:1234/foobar")
+ self.assertEqual(str(url), "amqp://me:***@[::1]:1234/foobar")
self.assertUrl(url, 'amqp', 'me', 'secret', '::1', 1234, 'foobar')
- self.assertEqual(str(url), "amqp://me:secret@[::1]:1234/foobar")
def testDefaults(self):
# Check that we allow None for scheme, port
url = Url(username='me', password='secret', host='myhost',
path='foobar', defaults=False)
- self.assertEqual(str(url), "//me:secret@myhost/foobar")
+ self.assertEqual(str(url), "//me:***@myhost/foobar")
self.assertUrl(url, None, 'me', 'secret', 'myhost', None, 'foobar')
self.assertEqual(str(Url("amqp://me:secret@myhost/foobar")),
- "amqp://me:secret@myhost:amqp/foobar")
+ "amqp://me:***@myhost:amqp/foobar")
# Empty string vs. None for path
self.assertEqual(Url("myhost/").path, "")
@@ -66,7 +64,7 @@ class UrlTest(common.Test):
("/path", "amqp://0.0.0.0:amqp/path"),
("user@host/topic://test", "amqp://user@host:amqp/topic://test"),
("user@host:3456", "amqp://user@host:3456"),
- ("user:pass@host/topic://test",
"amqp://user:pass@host:amqp/topic://test")
+ ("user:pass@host/topic://test",
"amqp://user:***@host:amqp/topic://test")
]:
self.assertEqual(str(Url(s)), u)
@@ -118,7 +116,7 @@ class UrlTest(common.Test):
for s, full in [
('amqp://', 'amqp://'),
('username@', '//username@'),
- (':pass@', '//:pass@'),
+ (':pass@', '//:***@'),
(':1234', '//:1234'),
('/path', '/path')
]:
@@ -127,7 +125,7 @@ class UrlTest(common.Test):
for s, full in [
('amqp://', 'amqp://0.0.0.0:amqp'),
('username@', 'amqp://[email protected]:amqp'),
- (':pass@', 'amqp://:[email protected]:amqp'),
+ (':pass@', 'amqp://:***@0.0.0.0:amqp'),
(':1234', 'amqp://0.0.0.0:1234'),
('/path', 'amqp://0.0.0.0:amqp/path'),
('foo/path', 'amqp://foo:amqp/path'),
@@ -138,10 +136,10 @@ class UrlTest(common.Test):
def testAmqps(self):
# Scheme defaults
self.assertEqual(str(Url("me:secret@myhost/foobar")),
- "amqp://me:secret@myhost:amqp/foobar")
+ "amqp://me:***@myhost:amqp/foobar")
# Correct port for amqps vs. amqps
self.assertEqual(str(Url("amqps://me:secret@myhost/foobar")),
- "amqps://me:secret@myhost:amqps/foobar")
+ "amqps://me:***@myhost:amqps/foobar")
self.assertPort(Url.Port('amqps'), 5671, 'amqps')
self.assertEqual(str(Url("host:amqps", defaults=False)),
"//host:amqps")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]