Fix rabbitmq_admin __main__ using stdlib urlparse for percent-encoded passwords#1684
Open
robjarawan wants to merge 1 commit into
Open
Fix rabbitmq_admin __main__ using stdlib urlparse for percent-encoded passwords#1684robjarawan wants to merge 1 commit into
robjarawan wants to merge 1 commit into
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After #1677 removed the explicit
unquote()calls fromexec_rabbitmqadmin, the function relies onUrlParseResult.passwordreturning the decoded value. The__main__block still used plainurllib.parse.urlparse(), which does not decode percent-encoding, so passwords likepass%23wordwere passed verbatim to rabbitmqadmin instead ofpass#word.What changed
Switched
__main__to_urlparse()sourl.passwordreturns 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%23decodes to#in the subprocess argument listtest_plain_urlparse_would_pass_encoded_password— documents why plainurlparseis not sufficient hereAll pass. Full credential suite (31 tests): 31 passed, 0 failed.
Fork CI unit tests: passing — https://github.com/robjarawan/sarracenia/actions/runs/24844943442