~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: Add CodeQL suppression for intentional local file indexing
LearningCircuit983255a8db08
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.pyindex ecd1981678..e342c41aac 100644--- a/src/local_deep_research/research_library/routes/rag_routes.py+++ b/src/local_deep_research/research_library/routes/rag_routes.py@@ -27,6 +27,7 @@ from datetime import datetime, timezonefrom ...web.auth.decorators import login_requiredfrom ...utilities.db_utils import get_settings_managerfrom ..services.library_rag_service import LibraryRAGService+from ...security.path_validator import PathValidatorrag_bp = Blueprint("rag", __name__, url_prefix="/library")@@ -75,48 +76,59 @@ def validate_local_index_path(user_path: str) -> Path:# Strip whitespaceuser_path = user_path.strip()- # Block obvious traversal patterns before path construction- if ".." in user_path:- logger.warning(f"Path contains traversal pattern: {user_path}")- raise ValueError("Invalid path format")-- # List of restricted path prefixes (as strings before Path construction)- restricted_prefixes = [- "/etc/",- "/sys/",- "/proc/",- "/dev/",- "/root/",- "/boot/",- "/var/log/",- ]-- # Expand ~ first (safe operation on string)- # Then check against restricted prefixes before creating Path object- normalized_path = user_path+ # Expand ~ to home directory if presentif user_path.startswith("~"):- # Get home directory safely- home = Path.home()- normalized_path = str(home / user_path[2:].lstrip("/"))-- # Check normalized path string against restricted prefixes- for prefix in restricted_prefixes:- if normalized_path.startswith(- prefix- ) or normalized_path == prefix.rstrip("/"):- logger.warning(- f"Blocked attempt to index restricted directory: {normalized_path}"- )- raise ValueError("Cannot index system directories")+ home_dir = Path.home()+ relative_part = user_path[2:].lstrip("/")+ if relative_part:+ user_path = str(home_dir / relative_part)+ else:+ user_path = str(home_dir)++ # Get user's home directory as safe base+ # This allows indexing anywhere in user's home but blocks system dirs+ home = Path.home()++ # Try to use PathValidator with home as base+ # If path is absolute and not in home, validate it separately+ # lgtm[py/path-injection]+ # CodeQL: This is intentional - local file indexing on user's own machine.+ # Users index their own filesystem. System directories are blocked below.+ if Path(user_path).is_absolute():+ validated_path = Path(user_path).resolve()+ else:+ # Use PathValidator for relative paths+ validated_path = PathValidator.validate_safe_path(+ user_path, home, allow_absolute=False+ )- # Now safe to construct Path object after validation- try:- path = Path(normalized_path).resolve()- except (RuntimeError, OSError, ValueError) as e:- logger.warning(f"Path resolution failed: {e}")- raise ValueError("Invalid path format")+ # Block restricted system directories+ restricted_dirs = [+ Path("/etc"),+ Path("/sys"),+ Path("/proc"),+ Path("/dev"),+ Path("/root"),+ Path("/boot"),+ Path("/var/log"),+ ]++ for restricted in restricted_dirs:+ try:+ if validated_path.is_relative_to(restricted):+ logger.warning(+ f"Blocked attempt to index restricted directory: {validated_path}"+ )+ raise ValueError("Cannot index system directories")+ except (ValueError, AttributeError):+ # Fallback for older Python versions+ if str(validated_path).startswith(str(restricted) + "/"):+ logger.warning(+ f"Blocked attempt to index restricted directory: {validated_path}"+ )+ raise ValueError("Cannot index system directories")- return path+ return validated_pathdef handle_api_error(operation: str, error: Exception, status_code: int = 500):