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(security): make Bearer SQLi suppressions in migrations 0013/0008 actually work (#4792)

LearningCircuit840e1b34f5d6
diff --git a/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py b/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
index 1a243ecd14..4a5ebae0d0 100644
--- a/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
+++ b/src/local_deep_research/database/migrations/versions/0008_fix_research_strategy_fk.py
@@ -48,9 +48,14 @@ depends_on = None
def _table_row_count(bind, table_name: str) -> int:
+ # ``table_name`` is always a hardcoded literal, never user input — so this
+ # f-string SQL is a false positive. Bearer honors the directive ONLY on its
+ # own line directly above the statement with the rule id alone; a same-line
+ # directive, or any trailing prose after the rule id, is silently ignored.
+ # bearer:disable python_lang_sql_injection
return (
bind.execute(
- text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608 — hardcoded name # bearer:disable python_lang_sql_injection — table_name is always a hardcoded literal
+ text(f"SELECT COUNT(*) FROM {table_name}") # noqa: S608 — hardcoded name
).scalar()
or 0
)
diff --git a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
index 530b2cba99..c2b1a1d8f2 100644
--- a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
+++ b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
@@ -170,8 +170,14 @@ def _rewrite_queued_research_snapshots(conn) -> None:
def _rewrite_benchmark_search_configs(conn, table: str) -> None:
+ # ``table`` is always a hardcoded literal ("benchmark_runs" /
+ # "benchmark_configs"), never user input — so this f-string SQL is a false
+ # positive. Bearer honors the directive ONLY on its own line directly above
+ # the statement with the rule id alone; a same-line directive, or any
+ # trailing prose after the rule id, is silently ignored.
+ # bearer:disable python_lang_sql_injection
rows = conn.execute(
- sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608 # bearer:disable python_lang_sql_injection — table is always a hardcoded literal ("benchmark_runs"/"benchmark_configs")
+ sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608
).fetchall()
rewritten = 0
@@ -183,9 +189,15 @@ def _rewrite_benchmark_search_configs(conn, table: str) -> None:
continue
if config.get("search_tool") in REMOVED_ENGINES:
config["search_tool"] = REPLACEMENT_ENGINE
+ # ``table`` is always a hardcoded literal ("benchmark_runs" /
+ # "benchmark_configs"), never user input — so this f-string SQL is a
+ # false positive. Bearer honors the directive ONLY on its own line
+ # directly above the statement with the rule id alone; a same-line
+ # directive, or any trailing prose after the rule id, is ignored.
+ # bearer:disable python_lang_sql_injection
conn.execute(
sa.text(
- f"UPDATE {table} SET search_config = :config " # noqa: S608 # bearer:disable python_lang_sql_injection — table is always a hardcoded literal ("benchmark_runs"/"benchmark_configs")
+ f"UPDATE {table} SET search_config = :config " # noqa: S608
"WHERE id = :id"
),
{"config": json.dumps(config), "id": row_id},