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.

Remove sensitive data from debug logs (#1896)

LearningCircuit482d059d16b3
diff --git a/src/local_deep_research/web/routes/history_routes.py b/src/local_deep_research/web/routes/history_routes.py
index ca6d155416..01eb1d9812 100644
--- a/src/local_deep_research/web/routes/history_routes.py
+++ b/src/local_deep_research/web/routes/history_routes.py
@@ -221,7 +221,7 @@ def get_research_status(research_id):
def get_research_details(research_id):
"""Get detailed progress log for a specific research"""
- logger.info(f"Details route accessed for research_id: {research_id}")
+ logger.debug(f"Details route accessed for research_id: {research_id}")
username = session.get("username")
if not username:
@@ -234,16 +234,14 @@ def get_research_details(research_id):
all_research = db_session.query(
ResearchHistory.id, ResearchHistory.query
).all()
- logger.info(
- f"All research for user {username}: {[(r.id, r.query[:30]) for r in all_research]}"
- )
+ logger.debug(f"All research count for user: {len(all_research)}")
research = (
db_session.query(ResearchHistory)
.filter_by(id=research_id)
.first()
)
- logger.info(f"Research query result: {research}")
+ logger.debug(f"Research found: {research.id if research else None}")
except Exception:
logger.exception("Database error")
return jsonify(
diff --git a/tests/security/test_sensitive_data_logging.py b/tests/security/test_sensitive_data_logging.py
new file mode 100644
index 0000000000..051c95ddd0
--- /dev/null
+++ b/tests/security/test_sensitive_data_logging.py
@@ -0,0 +1,100 @@
+"""Tests for sensitive data logging changes in history_routes.
+
+Verifies that PR #1896 changes are in place:
+- logger.debug used instead of logger.info for research detail lookups
+- Request headers are not logged
+- Request URL is not logged
+- Full research query results are not logged
+"""
+
+import ast
+from pathlib import Path
+
+# Resolve the source file path relative to this test file
+_ROUTES_FILE = (
+ Path(__file__).resolve().parents[2]
+ / "src"
+ / "local_deep_research"
+ / "web"
+ / "routes"
+ / "history_routes.py"
+)
+
+
+def _read_source() -> str:
+ """Read the history_routes.py source file directly from disk."""
+ return _ROUTES_FILE.read_text(encoding="utf-8")
+
+
+class TestSensitiveDataLogging:
+ """Verify that sensitive data is not exposed through logging."""
+
+ def test_uses_debug_not_info_for_details_route(self):
+ """logger.info should not be used for the details route access log."""
+ source = _read_source()
+ assert 'logger.info(f"Details route' not in source, (
+ "Details route log should use logger.debug, not logger.info"
+ )
+ assert "logger.debug" in source, (
+ "history_routes should contain at least one logger.debug call"
+ )
+
+ def test_no_request_headers_logging(self):
+ """Request headers must not be logged as they may contain auth tokens."""
+ source = _read_source()
+ assert "request.headers" not in source, (
+ "request.headers should not appear in history_routes.py"
+ )
+
+ def test_no_request_url_logging(self):
+ """Request URL must not be logged as it may contain sensitive params."""
+ source = _read_source()
+ assert "request.url" not in source, (
+ "request.url should not appear in history_routes.py"
+ )
+
+ def test_no_full_research_query_result_logging(self):
+ """Full research query result objects should not be logged."""
+ source = _read_source()
+ assert 'logger.info(f"Research query result' not in source, (
+ "Full research query result should not be logged via logger.info"
+ )
+
+ def test_no_user_research_list_logging(self):
+ """Full list of user research entries should not be logged."""
+ source = _read_source()
+ assert 'logger.info(f"All research for user' not in source, (
+ "Full user research list should not be logged via logger.info"
+ )
+
+ def test_research_count_uses_debug(self):
+ """Research count log should use debug level."""
+ source = _read_source()
+ assert "All research count" in source, (
+ "Should log research count (not full list)"
+ )
+ assert 'logger.debug(f"All research count' in source, (
+ "Research count should be logged at debug level"
+ )
+
+ def test_research_found_uses_debug_with_id_only(self):
+ """Research found log should use debug and only include the ID."""
+ source = _read_source()
+ assert 'logger.debug(f"Research found:' in source, (
+ "Research found log should use logger.debug"
+ )
+ assert "research.id if research else None" in source, (
+ "Should log only research.id, not the full object"
+ )
+
+ def test_request_import_removed(self):
+ """The request import from flask should be removed."""
+ source = _read_source()
+ tree = ast.parse(source)
+
+ for node in ast.walk(tree):
+ if isinstance(node, ast.ImportFrom) and node.module == "flask":
+ imported_names = [alias.name for alias in node.names]
+ assert "request" not in imported_names, (
+ "request should no longer be imported from flask"
+ )