Creates a requests session that validates URLs and blocks redirects to prevent SSRF.
# Source: https://github.com/crewAIInc/crewAI | License: MIT | Copyright 2025 crewAI, Inc
# Provided via justclaw.it.com; keep this notice with the code.
"""SSRF-safe HTTP fetching for crewai-tools.
``safe_get`` validates each URL and redirect hop, then fetches through a
session that pins TCP to the checked IP and ignores environment proxies.
"""
from __future__ import annotations
from typing import Any
from urllib.parse import urljoin, urlparse
import requests
from crewai_tools.security.safe_path import (
_BYPASS_HINT,
_is_escape_hatch_enabled,
validate_url,
)
from crewai_tools.security.ssrf_adapter import SSRFProtectedAdapter
_REDIRECT_STATUS_CODES = {301, 302, 303, 307, 308}
_STREAM_CHUNK_SIZE = 65536
_SENSITIVE_HEADER_NAMES = {
"authorization",
"cookie",
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key