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.

fix(deps): retain basic-ftp 6.2.2 and redact research CLI errors (#7200)

LearningCircuitd492770d0a75
diff --git a/changelog.d/7200.security.md b/changelog.d/7200.security.md
new file mode 100644
index 0000000000..7092d06f99
--- /dev/null
+++ b/changelog.d/7200.security.md
@@ -0,0 +1 @@
+The `ldr-research` CLI script no longer echoes raw exception text to stdout (captured by CI into `::error::` annotations and the `response.json` workflow artifact): errors are rendered through the security module's scrub pipeline (`scrub_error` with the in-scope provider key literals, then `sanitize_error_for_client`), falling back to the bare exception class name if the sanitizer is unreachable, so provider/HTTP error messages can no longer leak the submitted API keys.
diff --git a/scripts/ldr-research.py b/scripts/ldr-research.py
index 151931c3df..811fb4e991 100755
--- a/scripts/ldr-research.py
+++ b/scripts/ldr-research.py
@@ -187,7 +187,22 @@ def main():
print(json.dumps(output))
except Exception as e:
- print(json.dumps({"error": str(e)}))
+ message = type(e).__name__
+ try:
+ from local_deep_research.security.log_sanitizer import (
+ sanitize_error_for_client,
+ scrub_error,
+ )
+
+ secrets = [
+ os.environ[name]
+ for name in ("OPENROUTER_API_KEY", "SERPER_API_KEY")
+ if os.environ.get(name)
+ ]
+ message = sanitize_error_for_client(scrub_error(e, *secrets))
+ except Exception: # noqa: silent-exception
+ pass
+ print(json.dumps({"error": message}))
sys.exit(1)
finally:
try:
diff --git a/tests/accessibility_tests/package-lock.json b/tests/accessibility_tests/package-lock.json
index f077b326f0..c04662a0c6 100644
--- a/tests/accessibility_tests/package-lock.json
+++ b/tests/accessibility_tests/package-lock.json
@@ -678,9 +678,9 @@
}
},
"node_modules/basic-ftp": {
- "version": "6.2.1",
- "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-6.2.1.tgz",
- "integrity": "sha512-bK67isD+lKq46AU8vNtjvMaT2ZqAOAmNCbxUHlFBRD4k15NWxyEjmaKtZPlgce58So4BNTjITGQOVTjL9y0ECA==",
+ "version": "6.2.2",
+ "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-6.2.2.tgz",
+ "integrity": "sha512-LIkJcf/F6bTTfvE3k2YcTxrJsLKKVXiEpHZYkQP6JoqTb7khng7c13ckRTDQbqRh5IkehVH3F00sSlAa2F6DwA==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
diff --git a/tests/accessibility_tests/package.json b/tests/accessibility_tests/package.json
index 21e302f1ab..4368e3fb83 100644
--- a/tests/accessibility_tests/package.json
+++ b/tests/accessibility_tests/package.json
@@ -25,7 +25,7 @@
"lodash": "^4.18.0",
"lodash-es": "^4.18.0",
"uuid": "^14.0.0",
- "basic-ftp": "^6.2.1",
+ "basic-ftp": "^6.2.2",
"ip-address": "^10.1.1",
"ws": "^8.20.1",
"qs": "^6.15.2",
diff --git a/tests/puppeteer/package.json b/tests/puppeteer/package.json
index bb32f3a137..b597c4148d 100644
--- a/tests/puppeteer/package.json
+++ b/tests/puppeteer/package.json
@@ -30,7 +30,7 @@
"yauzl": "^3.2.1",
"flatted": "^3.4.0",
"fast-uri": "^3.1.2",
- "basic-ftp": "^6.2.1",
+ "basic-ftp": "^6.2.2",
"ip-address": "^10.1.1",
"js-yaml": "^4.2.0"
},
diff --git a/tests/security/test_ldr_research_error_redaction.py b/tests/security/test_ldr_research_error_redaction.py
new file mode 100644
index 0000000000..0d2a36bb03
--- /dev/null
+++ b/tests/security/test_ldr_research_error_redaction.py
@@ -0,0 +1,146 @@
+"""Pin the error-redaction contract of ``scripts/ldr-research.py``.
+
+The script prints its error JSON to stdout, where the CI workflow captures it
+into a ``::error::`` annotation and uploads ``response.json`` as a workflow
+artifact. Provider and HTTP errors can embed the submitted API keys in their
+message text, so the script must render the exception through the security
+module's scrub pipeline (``scrub_error`` with the in-scope key literals, then
+``sanitize_error_for_client``) and fall back to the bare exception class name
+whenever the sanitizer cannot be imported or fails. These tests run the real
+script as a subprocess with the live sanitizer package and its dependencies,
+so a revert to raw ``str(e)`` fails here instead of leaking keys into CI logs
+and artifacts.
+"""
+
+import json
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+import local_deep_research
+
+SCRIPT = Path(__file__).resolve().parents[2] / "scripts" / "ldr-research.py"
+PACKAGE = Path(local_deep_research.__file__).resolve().parent
+
+OR_KEY = "sk-or-v1-test0123456789abcdef"
+# Prefixless provider-key shape: not matched by any credential regex, so it
+# only gets redacted because the script passes the in-scope literal to
+# scrub_error().
+SERPER_KEY = "f4a8b2c9d7e61530aaaabbbb"
+
+API_INIT = """\
+import os
+
+
+def quick_summary(**kwargs):
+ mode = os.environ.get("STUB_MODE", "raise")
+ if mode == "ok":
+ return {
+ "formatted_findings": "findings text",
+ "sources": [],
+ "findings": [],
+ "iterations": 2,
+ }
+ raise RuntimeError(os.environ.get("STUB_ERROR", "boom"))
+"""
+
+SETTINGS_UTILS = "def create_settings_snapshot(overrides=None):\n return {'overrides': True}\n"
+
+
+def build_stub(root, security_init=""):
+ """Materialize a stub local_deep_research package shadowing the real one.
+
+ Stub only the research API. Extend package search paths to the live
+ package so sanitizer imports include their transitive dependencies;
+ copying individual files can silently exercise the fallback instead.
+ """
+ pkg = root / "local_deep_research"
+ (pkg / "api").mkdir(parents=True)
+ (pkg / "security").mkdir(parents=True)
+ (pkg / "__init__.py").write_text(
+ f"__path__.append({str(PACKAGE)!r})\n", encoding="utf-8"
+ )
+ (pkg / "api" / "__init__.py").write_text(API_INIT, encoding="utf-8")
+ (pkg / "api" / "settings_utils.py").write_text(
+ SETTINGS_UTILS, encoding="utf-8"
+ )
+ (pkg / "security" / "__init__.py").write_text(
+ f"__path__.append({str(PACKAGE / 'security')!r})\n{security_init}",
+ encoding="utf-8",
+ )
+ return root
+
+
+def run_script(stub_root, mode="raise", error_msg="boom"):
+ env = {
+ "PATH": "/usr/bin:/bin",
+ "PYTHONPATH": str(stub_root),
+ "OPENROUTER_API_KEY": OR_KEY,
+ "SERPER_API_KEY": SERPER_KEY,
+ "LDR_PROVIDER": "openrouter",
+ "LDR_SEARCH_TOOL": "serper",
+ "STUB_MODE": mode,
+ "STUB_ERROR": error_msg,
+ }
+ return subprocess.run(
+ [sys.executable, str(SCRIPT)],
+ input="what is rag?\n",
+ capture_output=True,
+ text=True,
+ env=env,
+ timeout=60,
+ )
+
+
+def test_credential_shaped_keys_are_redacted(tmp_path):
+ stub = build_stub(tmp_path)
+ proc = run_script(
+ stub, error_msg=f"401 Unauthorized: Invalid API key {OR_KEY}"
+ )
+ assert proc.returncode == 1
+ payload = json.loads(proc.stdout)
+ assert OR_KEY not in payload["error"]
+ assert "REDACTED" in payload["error"]
+
+
+def test_bare_provider_key_literal_is_redacted(tmp_path):
+ stub = build_stub(tmp_path)
+ proc = run_script(
+ stub, error_msg=f"serper error: key {SERPER_KEY} rejected"
+ )
+ assert proc.returncode == 1
+ payload = json.loads(proc.stdout)
+ assert SERPER_KEY not in payload["error"]
+ assert "REDACTED" in payload["error"]
+
+
+ "security_init",
+ [
+ 'raise ImportError("stub: security package absent")\n',
+ "from . import log_sanitizer\n"
+ "def fail(*args, **kwargs):\n"
+ " raise RuntimeError('stub: scrubber failure')\n"
+ "log_sanitizer.scrub_error = fail\n",
+ ],
+ ids=["import-unavailable", "scrubber-failure"],
+)
+def test_fails_closed_to_exception_class_when_sanitizer_unreachable(
+ tmp_path, security_init
+):
+ stub = build_stub(tmp_path, security_init=security_init)
+ proc = run_script(stub, error_msg=f"401 Unauthorized: {OR_KEY}")
+ assert proc.returncode == 1
+ payload = json.loads(proc.stdout)
+ assert payload["error"] == "RuntimeError"
+ assert OR_KEY not in proc.stdout
+
+
+def test_success_path_still_emits_research_json(tmp_path):
+ stub = build_stub(tmp_path)
+ proc = run_script(stub, mode="ok")
+ assert proc.returncode == 0
+ payload = json.loads(proc.stdout)
+ assert payload["research"] == "findings text"