8import urllib.parse
9
10▶from langchain_core._security._exceptions import SSRFBlockedError
11
12# ---------------------------------------------------------------------------
· · ·
195 """Validate a resolved IP address against the SSRF policy.
196
197▶ Raises SSRFBlockedError if the IP is blocked.
198 """
199 try:
· · ·
200 addr = ipaddress.ip_address(ip_str)
201▶ except ValueError as exc:
202 msg = "invalid IP address"
203 raise SSRFBlockedError(msg) from exc
· · ·
203▶ raise SSRFBlockedError(msg) from exc
204
205 if isinstance(addr, ipaddress.IPv6Address):
· · ·
210 reason = _ip_in_blocked_networks(addr, policy)
211 if reason is not None:
212▶ raise SSRFBlockedError(reason)
213
214
+ 12 more matches in this file