Skip to content

Fix rabbitmq_admin __main__ using stdlib urlparse for percent-encoded passwords#1684

Open
robjarawan wants to merge 1 commit into
MetPX:developmentfrom
robjarawan:fix/rabbitmq-admin-urlparse
Open

Fix rabbitmq_admin __main__ using stdlib urlparse for percent-encoded passwords#1684
robjarawan wants to merge 1 commit into
MetPX:developmentfrom
robjarawan:fix/rabbitmq-admin-urlparse

Conversation

@robjarawan

Copy link
Copy Markdown
Contributor

After #1677 removed the explicit unquote() calls from exec_rabbitmqadmin, the function relies on UrlParseResult.password returning the decoded value. The __main__ block still used plain urllib.parse.urlparse(), which does not decode percent-encoding, so passwords like pass%23word were passed verbatim to rabbitmqadmin instead of pass#word.

What changed

Switched __main__ to _urlparse() so url.password returns the decoded value consistently with all other code paths.

Tests

Added in tests/sarracenia/rabbitmq_admin_test.py:

  • test_encoded_hash_password_decoded_for_command — confirms %23 decodes to # in the subprocess argument list
  • test_plain_urlparse_would_pass_encoded_password — documents why plain urlparse is not sufficient here

All pass. Full credential suite (31 tests): 31 passed, 0 failed.

Fork CI unit tests: passing — https://github.com/robjarawan/sarracenia/actions/runs/24844943442

… passwords

After commit 72a8d19 removed unquote() calls from exec_rabbitmqadmin,
the function relies on UrlParseResult.password to return the decoded value.
The __main__ block used urllib.parse.urlparse() (plain ParseResult) which
does not decode percent-encoding, so passwords like 'pass%23word' were
passed verbatim to rabbitmqadmin instead of 'pass#word', breaking auth
for anyone invoking the script directly with an encoded password.

Switch __main__ to _urlparse() so url.password returns the decoded value
consistently with the non-main code paths.

Add three tests: two confirming decoded passwords reach the subprocess,
one pinning the stdlib urlparse behaviour to document why _urlparse is needed.
@robjarawan robjarawan self-assigned this Apr 24, 2026
@robjarawan robjarawan added the bug Something isn't working label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant