is_safe_url() — langchain Function Reference
Architecture documentation for the is_safe_url() function in _ssrf_protection.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e2a2ad8d_3007_a96a_a496_583f379150e4["is_safe_url()"] 76eef743_34da_b2b6_eda1_09a024269dbd["_ssrf_protection.py"] e2a2ad8d_3007_a96a_a496_583f379150e4 -->|defined in| 76eef743_34da_b2b6_eda1_09a024269dbd 6c828a82_ad0c_f5f1_d776_92c196a03eaf["validate_safe_url()"] e2a2ad8d_3007_a96a_a496_583f379150e4 -->|calls| 6c828a82_ad0c_f5f1_d776_92c196a03eaf style e2a2ad8d_3007_a96a_a496_583f379150e4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/_security/_ssrf_protection.py lines 256–287
def is_safe_url(
url: str | AnyHttpUrl,
*,
allow_private: bool = False,
allow_http: bool = True,
) -> bool:
"""Check if a URL is safe (non-throwing version of validate_safe_url).
Args:
url: The URL to check
allow_private: If True, allows private IPs and localhost
allow_http: If True, allows both HTTP and HTTPS
Returns:
True if URL is safe, False otherwise
Examples:
>>> is_safe_url("https://example.com")
True
>>> is_safe_url("http://127.0.0.1:8080")
False
>>> is_safe_url("http://localhost:8080", allow_private=True)
True
"""
try:
validate_safe_url(url, allow_private=allow_private, allow_http=allow_http)
except ValueError:
return False
else:
return True
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does is_safe_url() do?
is_safe_url() is a function in the langchain codebase, defined in libs/core/langchain_core/_security/_ssrf_protection.py.
Where is is_safe_url() defined?
is_safe_url() is defined in libs/core/langchain_core/_security/_ssrf_protection.py at line 256.
What does is_safe_url() call?
is_safe_url() calls 1 function(s): validate_safe_url.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free