Repository navigation
fix(abstractions): normalize allowed hosts, reject userinfo, and validate URL structure - #824
Conversation
|
Hi Vincent Biret (@baywet), opened this PR to normalize allowed hosts, reject URLs with userinfo, and validate URL structure. Unit tests and SonarCloud analysis are all passing. Whenever you have time, please review. Thank you! |
|
Thanks for the review. I've pushed commit Changes
Validation
I've also updated the inline review threads with individual replies. When you have a chance, could you please take another look? Thank you for your time and feedback! |
|
I have updated the PR with a follow-up commit addressing the remaining test assertion feedback:
Whenever you have a moment, please take another look. Thank you! |
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
fb66b46 to
109a829
Compare
109a829 to
6b27606
Compare
|
|
Vincent Biret (@baywet) Thanks for helping in this. |





Description
This PR strengthens host validation and normalization in
AllowedHostsValidator:Host normalization & prefix validation:
AllowedHostsValidator.__init__now delegates toset_allowed_hoststo maintain a single normalization path.host.strip()) before storing and checking prefixes.http://andhttps://prefixes (e.g., catchingHTTP://...orhttp://...), raisingValueErrorconsistently.isinstance(host, str)), raisingTypeErrorif a non-string entry is provided.URL validation & security hardening:
o.username or o.password) outright to prevent host spoofing and credential leakage (aligning with the TypeScript implementation).scheme,netloc, andhostname) before consideringallowed_hostsempty fallback, ensuring malformed URLs are rejected even when allowed hosts are not configured.Test coverage:
cc Vincent Biret (@baywet)