Repository navigation
fix(sanitize): redact credentials in URLs of any scheme - #512
Open
liwenjie200543 wants to merge 1 commit into
Open
liwenjie200543 wants to merge 1 commit into
liwenjie200543 wants to merge 1 commit into
Conversation
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.
_URL_CREDENTIALonly matcheshttp(s)://, so the sameuser:password@block in adatabase or broker URL is left in the text:
DATABASE_URL=postgres://…,MONGODB_URI=mongodb+srv://…,BROKER=amqp://…andREDIS_URL=redis://:…all reachthe model with the password intact, while the same credentials under
http://areredacted.
The scheme is now any RFC 3986 scheme (
[A-Za-z][A-Za-z0-9+.-]*://) and the userpart may be empty, which is how Redis writes a password-only URL. A plain
ssh://git@host/pathhas no:before its@, so it is still not matched.Before → after (
sanitize_model_input):Tests:
test_redacts_credentials_in_urls_of_any_schemeinmemhub/apps/core/tests/test_input_sanitization.py. 23 passed / 1 failed before thechange, 24 passed after. Ran the two sanitization test files standalone (the package
conftest.pyimportspwd, which does not exist on Windows).Found in the same audit as #511. That one is
_AUTHORIZATION(header value withpunctuation, redacted or not); this one is
_URL_CREDENTIAL(which schemes arecovered at all) — separate patterns, separate tests, and the #511 case still leaks on
this branch. Say the word and I will fold both into one PR instead.