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.

security: cap unbounded search_cache and cover logger.exception in hook (#3148)

LearningCircuit2a82829c884a
diff --git a/.pre-commit-hooks/check-sensitive-logging.py b/.pre-commit-hooks/check-sensitive-logging.py
index 2ca5b958d7..f31d2c34ac 100755
--- a/.pre-commit-hooks/check-sensitive-logging.py
+++ b/.pre-commit-hooks/check-sensitive-logging.py
@@ -105,6 +105,16 @@ ALLOWED_LOGGING = [
"variable": "kwargs",
"reason": "These are logger wrapper methods where kwargs are logger configuration options (like exc_info, extra), not actual data being logged",
},
+ {
+ "file_pattern": "search_engine_openlibrary.py",
+ "variable": "author_key",
+ "reason": "OpenLibrary author identifier (e.g. /authors/OL123A), not a cryptographic key",
+ },
+ {
+ "file_pattern": "web/queue/processor_v2.py",
+ "variable": "user_session",
+ "reason": "Queue routing key (username:session_id format), not session contents",
+ },
]
@@ -144,6 +154,7 @@ class SensitiveLoggingChecker(ast.NodeVisitor):
"warning",
"error",
"critical",
+ "exception",
"log",
}:
if isinstance(node.func.value, ast.Name):
diff --git a/src/local_deep_research/advanced_search_system/strategies/browsecomp_entity_strategy.py b/src/local_deep_research/advanced_search_system/strategies/browsecomp_entity_strategy.py
index 20a3693245..0c06ac4de2 100644
--- a/src/local_deep_research/advanced_search_system/strategies/browsecomp_entity_strategy.py
+++ b/src/local_deep_research/advanced_search_system/strategies/browsecomp_entity_strategy.py
@@ -49,6 +49,9 @@ class EntityCandidate:
self.constraint_matches = self.constraint_matches or {}
+MAX_LOCAL_CACHE = 200 # Cap in-memory search cache to prevent unbounded growth
+
+
class EntityKnowledgeGraph:
"""Build and maintain knowledge about discovered entities."""
@@ -834,6 +837,15 @@ Format: SCORE: X.X | REASON: explanation"""
query, normalized_results, "browsecomp_entity", ttl=1800
) # 30 minutes
+ # Also populate the in-memory search_cache (with size cap)
+ if len(self.knowledge_graph.search_cache) >= MAX_LOCAL_CACHE:
+ try:
+ oldest_key = next(iter(self.knowledge_graph.search_cache))
+ del self.knowledge_graph.search_cache[oldest_key]
+ except (StopIteration, KeyError):
+ pass
+ self.knowledge_graph.search_cache[query] = normalized_results
+
logger.debug(f"Cached new search results for: {query[:50]}...")
return normalized_results