~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(ci): resolve OSV findings for the v2 release gate (#6971) (#7128)
LearningCircuit4be072ae8fb5
diff --git a/.file-whitelist.txt b/.file-whitelist.txtindex a0d4478dd4..11114de165 100644--- a/.file-whitelist.txt+++ b/.file-whitelist.txt@@ -90,6 +90,7 @@^pyproject\.toml$^pdm\.lock$^\.gitleaks\.toml$+^osv-scanner\.toml$^\.zap/rules\.tsv$# ---------------------------------------------------------------------------diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex 13839ab51a..50e756a859 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -40,6 +40,7 @@/.trivyignore* @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti/.gitleaksignore @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti/.gitleaks.toml @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti+/osv-scanner.toml @LearningCircuit @hashedviking @djpetti/.semgrepignore @scottvr @tombii @prashant-sharma-cmd @elpikola @shreydekate @LearningCircuit @hashedviking @djpetti# Notificationsdiff --git a/.gitignore b/.gitignoreindex 176626b9f4..c896cb9c47 100644--- a/.gitignore+++ b/.gitignore@@ -84,6 +84,7 @@ src/local_deep_research/web/static/css/themes.css!Dockerfile!pyproject.toml!pdm.lock+!osv-scanner.toml!package.json!MANIFEST.in!eslint.config.mjsdiff --git a/changelog.d/+dependency-osv-fixes.security.md b/changelog.d/+dependency-osv-fixes.security.mdnew file mode 100644index 0000000000..e365477434--- /dev/null+++ b/changelog.d/+dependency-osv-fixes.security.md@@ -0,0 +1 @@+Require OAuthlib 4.0, urllib3 2.8, pypdf 6.19 and (with the `mcp` extra) PyJWT 2.15 or newer, and bump virtualenv (development only) and DOMPurify, closing newly disclosed vulnerabilities in these dependencies. SQLAlchemy is held on the tested 2.0 series. urllib3 2.8 percent-decodes http(s) hostnames while other HTTP clients such as httpx (used by the LLM SDKs) do not, so outbound URL validation now refuses any percent escape in an http(s) hostname, whatever the private-IP policy, and the notification validator detects encoded numeric IPv4 hosts on the raw URL text. pypdf 6.19 refuses a simple font whose `/Widths` array has more than 256 entries; pypdf-based text extraction now returns no text for a PDF containing one, including pages read before it: in the downloaders, in the library download service's fallback after pdfplumber, and in the `document_loaders` registry, whose `.pdf` entry is langchain's `PyPDFLoader` (collection file uploads, which reject the file with "Could not extract text from pdf file", and Zotero sync, which stores the item's metadata text instead of the PDF text).diff --git a/osv-scanner.toml b/osv-scanner.tomlnew file mode 100644index 0000000000..d2b3b40bad--- /dev/null+++ b/osv-scanner.toml@@ -0,0 +1,14 @@+# Release-gate exceptions for vulnerability sinks the application does not+# expose. OSV-Scanner reads this file beside pdm.lock. These IDs are narrow:+# aliases are covered, but other findings in either package still fail scans.+# Expiry makes the gate revisit both decisions after the v2 release window.++[[IgnoredVulns]]+id = "GHSA-8mgp-746c-j5xp"+ignoreUntil = 2026-10-31+reason = "NLTK is transitive; LDR does not enable pathsec or expose model-artifact path import/export APIs. tests/security/test_osv_reachability_exceptions.py guards direct use. Recheck when NLTK publishes a fix."++[[IgnoredVulns]]+id = "GHSA-4mvj-m6j5-pmf7"+ignoreUntil = 2026-10-31+reason = "LDR partitions validated local filenames, not URLs; tests/security/test_unstructured_url_partition_tripwire.py guards URL-taking sinks. Fixed unstructured >=0.24 requires Python <3.14, while LDR supports 3.14. Recheck when a compatible fix is available."diff --git a/pdm.lock b/pdm.lockindex 5e5dc30ba9..ad65cae44b 100644--- a/pdm.lock+++ b/pdm.lock@@ -4,8 +4,8 @@[metadata]groups = ["default", "dev", "mcp"]strategy = ["inherit_metadata"]-lock_version = "4.5.1"-content_hash = "sha256:b6771c8300b7cfec0d97c64e472b242caa48fc08d5c797b648d070b71e4652f4"+lock_version = "4.5.0"+content_hash = "sha256:2ddf256726a5df80ca27c2fcaf9cd73cba92bd21a5b73990896fede0fecb176d"[[metadata.targets]]requires_python = ">=3.12,<3.15"@@ -4920,6 +4920,20 @@ files = [{file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"},]+[[package]]+name = "python-discovery"+version = "1.6.1"+requires_python = ">=3.8"+summary = "Python interpreter discovery"+groups = ["dev"]+dependencies = [+ "filelock>=3.15.4",+]+files = [+ {file = "python_discovery-1.6.1-py3-none-any.whl", hash = "sha256:d43fcdef879fe795352bd13ccf8d185ba5a9f86f36cfcd00529f596e737442b3"},+ {file = "python_discovery-1.6.1.tar.gz", hash = "sha256:cf87d3627dfb4412437fdd5b13eae402607722998d21567993aedbc59b23c15e"},+]+[[package]]name = "python-docx"version = "1.2.0"@@ -6698,21 +6712,22 @@ files = [[[package]]name = "virtualenv"-version = "20.39.1"-requires_python = ">=3.8"+version = "21.14.5"+requires_python = ">=3.9"summary = "Virtual Python Environment builder"groups = ["dev"]dependencies = ["distlib<1,>=0.3.7",- "filelock<4,>=3.24.2; python_version >= \"3.10\"",+ "filelock<5,>=3.24.2; python_version >= \"3.10\"","filelock<=3.19.1,>=3.16.1; python_version < \"3.10\"",- "importlib-metadata>=6.6; python_version < \"3.8\"",+ "packaging>=23.1","platformdirs<5,>=3.9.1",+ "python-discovery>=1.6","typing-extensions>=4.13.2; python_version < \"3.11\"",]files = [- {file = "virtualenv-20.39.1-py3-none-any.whl", hash = "sha256:a00332e0b089ba64edefbf94ef34e6db33f45fe5184df0652cf0b754dcd36190"},- {file = "virtualenv-20.39.1.tar.gz", hash = "sha256:c551ea1072d7717a273dd9a4a0adad8f45571af134b0f63a12430e85f6ac1c08"},+ {file = "virtualenv-21.14.5-py3-none-any.whl", hash = "sha256:b0651e0174982bba17cc6f0aaa2ef496730cb85a3f35eb5d1119d1c904f7d1da"},+ {file = "virtualenv-21.14.5.tar.gz", hash = "sha256:c4cb6c13e46b57225a999c7e22a09b163393878facc7ac4c059a57f46faa1647"},][[package]]diff --git a/pyproject.toml b/pyproject.tomlindex c554cdd8cd..a7df50b63c 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -53,7 +53,7 @@ dependencies = ["sqlalchemy-utc~=0.14","wikipedia~=1.4","arxiv~=2.4",- "pypdf~=6.15", # CVE-2026-33123, CVE-2026-31826, GHSA-9m86-7pmv-2852, CVE-2026-27888, CVE-2026-27024, CVE-2026-0777, CVE-2025-55197, GHSA-3crg-w4f6-42mx, GHSA-248m-82v9-q6g6, GHSA-cj93-chg6-vgv8, GHSA-jm82-fx9c-mx94, CVE-2026-71852, CVE-2026-71870 fixes+ "pypdf>=6.19,<7", # GHSA-fp3h-c4fm-7vvf, GHSA-g9cg-prrw-2r8q, GHSA-jw7q-gvrg-4vj3 (fixed 6.18.1), GHSA-php9-fj8v-98fj, GHSA-v247-6f48-mgcj, GHSA-w23x-9jrw-r45c (fixed 6.19.0), CVE-2026-33123, CVE-2026-31826, GHSA-9m86-7pmv-2852, CVE-2026-27888, CVE-2026-27024, CVE-2026-0777, CVE-2025-55197, GHSA-3crg-w4f6-42mx, GHSA-248m-82v9-q6g6, GHSA-cj93-chg6-vgv8, GHSA-jm82-fx9c-mx94, CVE-2026-71852, CVE-2026-71870 fixes"sentence-transformers~=5.2","faiss-cpu~=1.13.0", # 1.14.x wheels SIGILL on CPUs without AVX2 (#4480); unpin criteria tracked in #4499"pydantic~=2.12",@@ -62,7 +62,7 @@ dependencies = ["platformdirs~=4.5","dynaconf~=3.2","requests>=2.32", # CVE-2026-25645 patched in 2.33; PDM override ensures 2.33+ in dev- "urllib3~=2.7", # CVE-2026-44431 CVE-2026-44432 fix+ "urllib3>=2.8,<3", # CVE-2026-44431 CVE-2026-44432 fix; 2.8.0 fixes GHSA-8988-9cw3-xx77, GHSA-gh4c-6fx4-qh6g, GHSA-vxq7-64xx-v4gw"tiktoken~=0.12","xmltodict~=1.0","lxml>=5.3", # >=5.3 to satisfy crawl4ai; PDM override ensures >=6.0 in dev@@ -111,6 +111,7 @@ dependencies = [# floor: never resolve below it, and re-check the parser contract and# its tests before raising the ceiling."apprise>=1.12.0,<2",+ "oauthlib>=4,<5", # Apprise -> requests-oauthlib; 4.0.0 fixes GHSA-hj66-6f7g-4r5v and GHSA-xpv3-w29h-x7cv"markdown~=3.10","pypandoc-binary~=1.16","datasets~=4.5",@@ -193,6 +194,7 @@ dependencies = [[project.optional-dependencies]mcp = ["mcp[cli]~=1.2",+ "PyJWT>=2.15.0,<3", # MCP transitive dependency; 2.14.0 fixes GHSA-w6j9-cwv2-h6wq and ten sibling advisories, 2.15.0 fixes GHSA-42vr-xj54-vc7v][project.urls]@@ -260,7 +262,7 @@ lxml = ">=6.0"[dependency-groups]dev = [- "virtualenv~=20.36",+ "virtualenv>=21.7.13,<22", # GHSA-9h9j-4vrj-gf7g (21.7.11), GHSA-94p9-xgh2-xp45 and GHSA-x78j-v8h9-3j2q (21.7.12), GHSA-p58f-9548-mpm2 (21.7.13)"pre-commit~=4.5","cookiecutter~=2.6","pytest-mock~=3.15",diff --git a/src/local_deep_research/security/egress/validators.py b/src/local_deep_research/security/egress/validators.pyindex c12127b742..af0e562cb9 100644--- a/src/local_deep_research/security/egress/validators.py+++ b/src/local_deep_research/security/egress/validators.py@@ -309,9 +309,12 @@ def _engine_url_origin(value):the HTTP client (urllib3) about which host a hostile URL names:URLs containing RFC-forbidden characters (backslash, whitespace,control chars — the parser-differential class) return ``None``, and- the host is NOT percent-decoded (urllib3 doesn't decode either, so- decoding here would match a destination the client never connects- to). Returns ``None`` for anything that isn't a cleanly parseable+ the host is NOT percent-decoded here (urllib3 before 2.8 did not+ decode http(s) hosts and 2.8+ does, so this parser stays decode-free:+ an escaped host matches only an allowlist entry written with the same+ escapes, never a plain entry by decoding, and ``validate_url`` refuses+ percent-encoded hosts at fetch time). Returns ``None`` for anything+ that isn't a cleanly parseablehttp(s) URL with a hostname; every failure mode therefore failsCLOSED (no allowlist match), never open."""diff --git a/src/local_deep_research/security/legacy_ipv4.py b/src/local_deep_research/security/legacy_ipv4.pyindex 5d6ba3450e..626ac55cb0 100644--- a/src/local_deep_research/security/legacy_ipv4.py+++ b/src/local_deep_research/security/legacy_ipv4.py@@ -53,6 +53,60 @@ def is_percent_encoded_numeric_ipv4_host(hostname: str) -> bool:return isinstance(parsed_ip, ipaddress.IPv4Address)+def raw_authority_host(url: str) -> str | None:+ """Return the host text of ``url``'s authority exactly as written.++ The authority is the part between ``//`` and the first ``/``, ``?`` or+ ``#``; userinfo (up to the last ``@``) and a trailing ``:port`` are+ dropped and nothing is decoded or lowercased. Returns ``None`` when the+ URL has no ``//`` authority or the host is a bracketed IP literal.+ """+ start = url.find("//")+ if start < 0:+ return None+ rest = url[start + 2 :]+ end = len(rest)+ for delimiter in "/?#":+ found = rest.find(delimiter)+ if found >= 0:+ end = min(end, found)+ authority = rest[:end].rpartition("@")[2]+ if authority.startswith("["):+ return None+ host, _, port = authority.rpartition(":")+ if not host or not (port == "" or port.isdigit()):+ host = authority+ return host+++def has_percent_encoded_numeric_ipv4_authority(url: str) -> bool:+ """Return whether ``url`` spells its host as percent-encoded IPv4.++ Deliberately works on the raw URL text, never on a parser's host: urllib3+ 2.8 percent-decodes http(s) hosts (2.7 did not), so a parsed host can no+ longer show that the URL was encoded. Callers must refuse these URLs+ whatever the private-IP policy, since the encoded spelling is what the+ policy checks cannot see through.+ """+ host = raw_authority_host(url)+ return host is not None and is_percent_encoded_numeric_ipv4_host(host)+++def has_percent_escape_in_authority_host(url: str) -> bool:+ """Return whether ``url``'s raw authority host contains any ``%``.++ urllib3 2.8 percent-decodes escapes of unreserved characters in http(s)+ hosts (``ev%69l.example`` parses as ``evil.example``), while other HTTP+ clients such as httpx send the escaped text to the resolver unchanged.+ A validator that checks the decoded host therefore checks a different+ name from the one those clients resolve. No real DNS name needs a+ percent escape, so callers refuse these hosts outright. Bracketed IP+ literals (whose IPv6 zone id is written ``%25``) are not covered.+ """+ host = raw_authority_host(url)+ return host is not None and "%" in host++def _decode_percent_escapes(hostname: str) -> str | None:"""Decode only well-formed ASCII percent escapes without recursive decoding."""position = 0diff --git a/src/local_deep_research/security/ssrf_validator.py b/src/local_deep_research/security/ssrf_validator.pyindex 6e6cada560..ef1d236b0e 100644--- a/src/local_deep_research/security/ssrf_validator.py+++ b/src/local_deep_research/security/ssrf_validator.py@@ -19,6 +19,8 @@ from .log_sanitizer import redact_and_bound_for_logfrom .ip_ranges import NAT64_PREFIXESfrom .legacy_ipv4 import (is_ambiguous_numeric_ipv4_host,+ has_percent_encoded_numeric_ipv4_authority,+ has_percent_escape_in_authority_host,is_percent_encoded_numeric_ipv4_host,)@@ -394,8 +396,10 @@ def validate_url(Checks:1. URL scheme is allowed (http/https only)- 2. Hostname is not an internal/private IP address- 3. Hostname does not resolve to an internal/private IP+ 2. The host is not percent-encoded (any ``%`` outside a bracketed IP+ literal is refused, whatever the private-IP policy)+ 3. Hostname is not an internal/private IP address+ 4. Hostname does not resolve to an internal/private IPArgs:url: URL to validate@@ -453,6 +457,21 @@ def validate_url(except LocationParseError:logger.warning("Blocked URL: urllib3 parser rejected it")return False+ # Encoded numeric IPv4 authorities are refused on the raw URL text,+ # before the parsed host is looked at: urllib3 >= 2.8 percent-decodes+ # http(s) hosts, so ``http://127%2e0%2e0%2e1/`` would otherwise parse+ # to a plain IP literal and be accepted under allow_private_ips.+ if has_percent_encoded_numeric_ipv4_authority(url):+ logger.warning("Blocked URL with encoded numeric IPv4 host")+ return False+ # Any other percent escape in the host is refused too. urllib3 >= 2.8+ # decodes ``ev%69l.example`` to ``evil.example`` while httpx (the LLM+ # SDKs' client) resolves the escaped text unchanged, so checking the+ # decoded host would vet a different name from the one those clients+ # connect to. No real DNS name needs a percent escape.+ if has_percent_escape_in_authority_host(url):+ logger.warning("Blocked URL with percent-encoded host")+ return Falsehostname = u3.host# Authority must be ASCII printable. urllib3 currently rejects# non-ASCII via LocationParseError, but this guard keeps usdiff --git a/tests/security/test_encoded_numeric_host.py b/tests/security/test_encoded_numeric_host.pyindex f3d929fe60..736d0e274a 100644--- a/tests/security/test_encoded_numeric_host.py+++ b/tests/security/test_encoded_numeric_host.py@@ -20,13 +20,18 @@ _PUBLIC_ADDRINFO = [_PUBLIC_RESOLVED_IPS = [ipaddress.IPv4Address("93.184.216.34")]_AMBIGUOUS_NUMERIC_IPV4_ERROR = "Ambiguous numeric IPv4 host"_ENCODED_NUMERIC_IPV4_ERROR = "Encoded numeric IPv4 host"-_PRESERVED_PERCENT_ENCODED_URLS = (+_PERCENT_ENCODED_NON_NUMERIC_HOST_URLS = ("https://ex%61mple.com/","https://ex%61mple.com./","https://127.0.0.1%252e/",+)+_PERCENT_ESCAPE_OUTSIDE_HOST_URLS = ("https://%32%31%33%30%37%30%36%34%33%[email protected]/","https://public.example/%32%31%33%30%37%30%36%34%33%33",)+_PRESERVED_PERCENT_ENCODED_URLS = (+ _PERCENT_ENCODED_NON_NUMERIC_HOST_URLS + _PERCENT_ESCAPE_OUTSIDE_HOST_URLS+)_ENCODED_NUMERIC_IPV4_URLS = (("http://%32%31%33%30%37%30%36%34%33%33/",@@ -61,12 +66,15 @@ def test_non_numeric_percent_encoded_hosts_preserve_current_outcomes():):# When: percent escapes occur outside a numeric network authority.for url in _PRESERVED_PERCENT_ENCODED_URLS:- # Then: both public validators retain their existing outcomes.- assert validate_url(url) is True+ # Then: the notification validator retains its existing outcome+ # (Apprise refuses a '%' host itself, so it never dials one).assert NotificationURLValidator.validate_service_url(url) == (True,None,)+ # And: validate_url still accepts escapes outside the host.+ for url in _PERCENT_ESCAPE_OUTSIDE_HOST_URLS:+ assert validate_url(url) is True@pytest.mark.parametrize("scheme", ("http", "https"))@@ -287,3 +295,112 @@ def test_encoded_numeric_host_plugin_rejects_before_dns(url):# Then: it is structurally rejected before host resolution.assert result == (False, _ENCODED_NUMERIC_IPV4_ERROR)assert resolver.call_count == 0+++ ("url", "expected"),+ (+ ("http://127%2e0%2e0%2e1/", True),+ ("http://user:p%40ss@127%2e0%2e0%2e1:8080/x", True),+ ("http://2130706433%2e?q=1", True),+ ("http://127.0.0.1/", False),+ ("http://[::1]/", False),+ ("https://ex%61mple.com/", False),+ ("https://%32%31%33%30%37%30%36%34%33%[email protected]/", False),+ ("https://public.example/%32%31%33%30%37%30%36%34%33%33", False),+ ("no-authority", False),+ ),+)+def test_raw_authority_detection_is_independent_of_urllib3_decoding(+ url, expected+):+ from local_deep_research.security.legacy_ipv4 import (+ has_percent_encoded_numeric_ipv4_authority,+ )++ assert has_percent_encoded_numeric_ipv4_authority(url) is expected+++_PERCENT_ENCODED_HOST_POLICIES = (+ {},+ {"allow_localhost": True},+ {"allow_private_ips": True},+ {"allow_localhost": True, "allow_private_ips": True},+)++[email protected]("policy", _PERCENT_ENCODED_HOST_POLICIES)+ "url",+ _PERCENT_ENCODED_NON_NUMERIC_HOST_URLS+ + (+ "http://ev%69l.attacker.com/v1",+ "http://EV%49L.attacker.com:11434/v1",+ "http://u:p@ev%69l.attacker.com./v1",+ "http://ex%2fample.com/",+ )+ + tuple(url for url, _ in _ENCODED_NUMERIC_IPV4_URLS)+ + tuple(url for url, _ in _ENCODED_TRAILING_DOT_NUMERIC_IPV4_URLS),+)+def test_validate_url_refuses_percent_encoded_host_under_every_policy(+ url, policy+):+ # Given: DNS answers that would pass every policy for the decoded name.+ with patch(+ "local_deep_research.security.ssrf_validator.socket.getaddrinfo",+ return_value=_PUBLIC_ADDRINFO,+ ) as resolver:+ # When: validate_url receives a percent-encoded host. urllib3 >= 2.8+ # decodes it, while httpx (the LLM SDKs' client) resolves the+ # escaped text, so the two would name different hosts.+ result = validate_url(url, **policy)++ # Then: it is refused before DNS, whatever the private-IP policy.+ assert result is False+ assert resolver.call_count == 0+++def test_llm_base_url_with_percent_encoded_host_is_refused():+ from local_deep_research.security.ssrf_validator import (+ assert_base_url_safe,+ )++ # Given: a public DNS answer for the decoded name.+ with patch(+ "local_deep_research.security.ssrf_validator.socket.getaddrinfo",+ return_value=_PUBLIC_ADDRINFO,+ ):+ # When/Then: the LLM base_url guard refuses the encoded host.+ with pytest.raises(ValueError):+ assert_base_url_safe(+ "http://ev%69l.attacker.com/v1", setting_key="llm.ollama.url"+ )+ # And: the plain spelling still passes.+ assert (+ assert_base_url_safe(+ "http://evil.attacker.com/v1", setting_key="llm.ollama.url"+ )+ == "http://evil.attacker.com/v1"+ )+++ ("url", "expected"),+ (+ ("http://ev%69l.example/", True),+ ("http://user:p%40ss@ex%61mple.com:8080/x", True),+ ("http://127%2e0%2e0%2e1/", True),+ ("http://a%zz.example/", True),+ ("http://example.com/", False),+ ("http://u%40x:p%[email protected]/", False),+ ("http://example.com/%69?q=%69#%69", False),+ ("http://[fe80::1%25eth0]/", False),+ ("no-authority", False),+ ),+)+def test_raw_authority_percent_escape_detection(url, expected):+ from local_deep_research.security.legacy_ipv4 import (+ has_percent_escape_in_authority_host,+ )++ assert has_percent_escape_in_authority_host(url) is expecteddiff --git a/tests/security/test_osv_reachability_exceptions.py b/tests/security/test_osv_reachability_exceptions.pynew file mode 100644index 0000000000..ef3adbc3f7--- /dev/null+++ b/tests/security/test_osv_reachability_exceptions.py@@ -0,0 +1,141 @@+# allow: no-sut-import — policy guardian over OSV configuration and source imports.+"""Keep release-gate OSV exceptions narrow and tied to reachable sinks."""++from __future__ import annotations++import ast+import datetime as dt+import tomllib+from pathlib import Path++from packaging.requirements import Requirement+from packaging.specifiers import SpecifierSet+from packaging.utils import canonicalize_name+from packaging.version import Version+++ROOT = Path(__file__).resolve().parents[2]+SOURCE = ROOT / "src" / "local_deep_research"+++def test_osv_exceptions_are_exact_and_expiring() -> None:+ config = tomllib.loads(+ (ROOT / "osv-scanner.toml").read_text(encoding="utf-8")+ )+ assert set(config) == {"IgnoredVulns"}+ exceptions = config["IgnoredVulns"]+ assert {entry["id"] for entry in exceptions} == {+ "GHSA-8mgp-746c-j5xp",+ "GHSA-4mvj-m6j5-pmf7",+ }+ assert len(exceptions) == 2+ for entry in exceptions:+ assert set(entry) == {"id", "ignoreUntil", "reason"}+ assert isinstance(entry["ignoreUntil"], dt.date)+ assert dt.date.today() < entry["ignoreUntil"]+ assert len(entry["reason"]) > 80+++def test_no_first_party_nltk_model_artifact_imports() -> None:+ """NLTK pathsec bypass requires callers to use its model-path APIs."""+ modules = sorted(SOURCE.rglob("*.py"))+ assert len(modules) > 100, "application source tree not found"+ offenders = []+ for module in modules:+ tree = ast.parse(+ module.read_text(encoding="utf-8"), filename=str(module)+ )+ for node in ast.walk(tree):+ if isinstance(node, ast.Import):+ names = [alias.name for alias in node.names]+ elif isinstance(node, ast.ImportFrom) and node.module:+ names = [node.module]+ else:+ continue+ if any(+ name == "nltk" or name.startswith("nltk.") for name in names+ ):+ offenders.append(f"{module.relative_to(SOURCE)}:{node.lineno}")+ assert not offenders, (+ "NLTK is now called directly; review GHSA-8mgp-746c-j5xp before "+ "keeping its OSV exception: " + ", ".join(offenders)+ )+++# First version that OSV lists as fixed for every advisory the v2 release+# lock bump closed. A floor below this lets a fresh pip install (which does+# not read pdm.lock) resolve a still-vulnerable release.+FIRST_FIXED = {+ "oauthlib": "4.0.0", # GHSA-hj66-6f7g-4r5v, GHSA-xpv3-w29h-x7cv+ "pyjwt": "2.15.0", # GHSA-42vr-xj54-vc7v (the 2.14.0 set is older)+ "pypdf": "6.19.0", # GHSA-php9-fj8v-98fj, GHSA-v247-6f48-mgcj, ...+ "urllib3": "2.8.0", # GHSA-8988-9cw3-xx77, GHSA-gh4c-6fx4-qh6g, ...+ "virtualenv": "21.7.13", # GHSA-p58f-9548-mpm2+}+++def _declared_requirements() -> dict[str, list[SpecifierSet]]:+ project = tomllib.loads(+ (ROOT / "pyproject.toml").read_text(encoding="utf-8")+ )+ raw = list(project["project"]["dependencies"])+ for extra in project["project"].get("optional-dependencies", {}).values():+ raw.extend(extra)+ for group in project.get("dependency-groups", {}).values():+ raw.extend(item for item in group if isinstance(item, str))+ declared: dict[str, list[SpecifierSet]] = {}+ for line in raw:+ req = Requirement(line)+ declared.setdefault(canonicalize_name(req.name), []).append(+ req.specifier+ )+ return declared+++def _locked_versions() -> dict[str, set[Version]]:+ lock = tomllib.loads((ROOT / "pdm.lock").read_text(encoding="utf-8"))+ locked: dict[str, set[Version]] = {}+ for package in lock["package"]:+ locked.setdefault(canonicalize_name(package["name"]), set()).add(+ Version(package["version"])+ )+ return locked+++def _floor(spec: SpecifierSet) -> Version | None:+ floors = [+ Version(item.version)+ for item in spec+ if item.operator in {">=", ">", "~=", "=="}+ ]+ return max(floors) if floors else None+++def test_security_floors_reach_first_fixed_version() -> None:+ declared = _declared_requirements()+ locked = _locked_versions()+ for name, fixed in FIRST_FIXED.items():+ fixed_version = Version(fixed)+ assert name in declared, f"{name} lost its security floor"+ for spec in declared[name]:+ floor = _floor(spec)+ assert floor is not None and floor >= fixed_version, (+ f"{name}{spec} still admits releases below {fixed}"+ )+ assert locked.get(name), f"{name} missing from pdm.lock"+ assert min(locked[name]) >= fixed_version, (+ f"pdm.lock pins {name} below {fixed}"+ )+++def test_sqlalchemy_stays_on_tested_2_0_series() -> None:+ """#6876: 2.1.1 was reported to segfault; 2.1 also URL-decodes paths."""+ declared = _declared_requirements()["sqlalchemy"]+ for spec in declared:+ assert spec.contains("2.0.52")+ assert not spec.contains("2.1.0")+ assert not spec.contains("2.1.1")+ locked = _locked_versions()["sqlalchemy"]+ assert locked and all(+ Version("2.0") <= version < Version("2.1") for version in locked+ )