Repository navigation
Conversation
The reference-image URL fetch used plain requests.get, so HTTP(S)_PROXY and ALL_PROXY bypassed the address check, and NAT64 addresses such as 64:ff9b::7f00:1 passed ipaddress.is_global. Use build_guarded_session() and validate_download_url(), keeping the per-hop redirect validation and 422s. Assisted-by: Claude <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
_download_search_imagefetched the reference-image URL with plainrequests.get. That left two gaps in the allow-list:HTTP_PROXY/HTTPS_PROXY/ALL_PROXYmade the request go through a proxy instead of the address that was checked, and64:ff9b::/96(NAT64) reportsis_global == True, so64:ff9b::7f00:1mapped back to 127.0.0.1.The fetch now uses
build_guarded_session()(ignores ambient proxies, checks the connected peer) and_assert_url_host_alloweddelegates tovalidate_download_url(), which blocks the NAT64 prefixes as reserved. The manual per-hop redirect loop and the 422 responses are unchanged.Related Issues / Discussions
Closes #9633
QA Instructions
The three new/updated tests in
test_image_map.py(redirect re-validation through the guarded session, NAT64 literal and hostname rejected with 422 before any request, proxy env vars ignored) fail onmainand pass with this change.ruff checkandruff format --checkpass.Review
Small change in one router; no API schema change.
Checklist
What's Newcopy (if doing a release after this PR)AI assistance: this change was prepared with Claude (an AI coding assistant) and tested as described above.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.