Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test: isolate redirect checks from live DNS (#6983) (#7130)

LearningCircuitc2abd89125e7
diff --git a/tests/security/test_ssrf_redirect_bypass.py b/tests/security/test_ssrf_redirect_bypass.py
index 8bdb020a63..c81fc82324 100644
--- a/tests/security/test_ssrf_redirect_bypass.py
+++ b/tests/security/test_ssrf_redirect_bypass.py
@@ -9,13 +9,15 @@ Verifies:
"""
import io
+import ipaddress
+import socket
import pytest
from unittest.mock import patch, MagicMock
import requests
-from local_deep_research.security import ssrf_validator
+from local_deep_research.security import dns_pinning, ssrf_validator
from local_deep_research.security.safe_requests import (
safe_get,
@@ -28,6 +30,40 @@ from local_deep_research.security.safe_requests import (
)
[email protected](autouse=True)
+def deterministic_pinning_dns(monkeypatch):
+ """Keep the real pinning guard, with DNS answers for test hosts only.
+
+ Pinning captures its resolver at import time, so patching socket DNS
+ for URL validation alone still lets these mocked HTTP tests use the
+ network. Preserve literal addresses so private-IP checks stay meaningful.
+ """
+ public_hosts = {
+ "example.com",
+ "other.com",
+ "final.com",
+ "hop2.com",
+ "hop3.com",
+ }
+
+ def resolve(host, port, *args, **kwargs):
+ if host in public_hosts:
+ host = "93.184.216.34"
+ try:
+ address = ipaddress.ip_address(host)
+ except ValueError:
+ pytest.fail(
+ f"Declare a deterministic DNS answer for test host {host!r}"
+ )
+ if address.version == 6:
+ family, endpoint = socket.AF_INET6, (str(address), port, 0, 0)
+ else:
+ family, endpoint = socket.AF_INET, (str(address), port)
+ return [(family, socket.SOCK_STREAM, socket.IPPROTO_TCP, "", endpoint)]
+
+ monkeypatch.setattr(dns_pinning, "_real_getaddrinfo", resolve)
+
+
@pytest.fixture
def mock_validate_url():
with patch.object(