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