~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(settings): keep a changed setting's value out of the update debug log (#6788)
Lukas90b735df8ff4
diff --git a/changelog.d/6529.security.md b/changelog.d/6529.security.mdnew file mode 100644index 0000000000..dd998cc422--- /dev/null+++ b/changelog.d/6529.security.md@@ -0,0 +1 @@+Updating a setting that triggers a warning recalculation no longer writes the setting's new value to the debug log; the line now names the key and the warning count only, the same rule the settings import already follows.diff --git a/src/local_deep_research/web/routers/settings.py b/src/local_deep_research/web/routers/settings.pyindex 0a11572385..06f64358fb 100644--- a/src/local_deep_research/web/routers/settings.py+++ b/src/local_deep_research/web/routers/settings.py@@ -5084,8 +5084,9 @@ def _api_update_setting_sync(data, key, username):if key in WARNING_AFFECTING_KEYS:warnings = calculate_warnings(username=username)response_data["warnings"] = warnings+ # Never the value: it may carry a secret (see #6201).logger.debug(- f"Setting {key} changed to {value}, calculated {len(warnings)} warnings"+ f"Setting {key} changed, calculated {len(warnings)} warnings")return response_datadiff --git a/tests/settings/test_import_settings_validation.py b/tests/settings/test_import_settings_validation.pyindex 2ef8d819e3..06f7a93f9d 100644--- a/tests/settings/test_import_settings_validation.py+++ b/tests/settings/test_import_settings_validation.py@@ -530,8 +530,6 @@ class TestUnknownUiElementImport:assert returned == "the_default"assert "Got unknown type" in loguru_caplog.text- assert returned == "the_default"- assert "Got unknown type" in loguru_caplog.textclass TestImportSkipWarningNeverLogsValue:diff --git a/tests/web/routers/test_settings_update_log_never_carries_value.py b/tests/web/routers/test_settings_update_log_never_carries_value.pynew file mode 100644index 0000000000..ef48c0cfd6--- /dev/null+++ b/tests/web/routers/test_settings_update_log_never_carries_value.py@@ -0,0 +1,62 @@+"""The settings update path must not log the value it wrote (#6529).++``_api_update_setting_sync`` logged ``Setting {key} changed to {value}`` at+debug level for every key in ``WARNING_AFFECTING_KEYS``. #6201 established+that a settings value must never be interpolated into a log line, since any+key may carry a secret; this sink was the one it did not reach. No key in the+set carries a secret today, so the test writes a distinct sentinel under one+of them.+"""++from contextlib import contextmanager+from unittest.mock import MagicMock, Mock, patch++S = "local_deep_research.web.routers.settings"+++def test_warning_affecting_update_never_logs_the_value(loguru_caplog):+ from local_deep_research.web.routers.settings import (+ WARNING_AFFECTING_KEYS,+ _api_update_setting_sync,+ )++ key = "search.iterations"+ assert key in WARNING_AFFECTING_KEYS+ sentinel = "sk-live-update-must-not-reach-the-log-6529"++ existing = Mock()+ existing.key = key+ existing.editable = True+ existing.ui_element = "text"+ query = MagicMock()+ query.first.return_value = existing+ query.filter.return_value = query+ query.filter_by.return_value = query+ session = MagicMock()+ session.query.return_value = query++ @contextmanager+ def fake_db_session(*_args, **_kwargs):+ yield session++ with (+ patch(f"{S}.get_user_db_session", side_effect=fake_db_session),+ patch(f"{S}.validate_setting", return_value=(True, None)),+ patch(f"{S}.set_setting", return_value=True),+ patch(f"{S}.invalidate_settings_caches"),+ patch(f"{S}.reschedule_document_jobs_if_needed"),+ patch(f"{S}.reschedule_zotero_jobs_if_needed"),+ patch(f"{S}.calculate_warnings", return_value=[]),+ loguru_caplog.at_level("DEBUG"),+ ):+ response = _api_update_setting_sync({"value": sentinel}, key, "alice")++ assert response == {+ "message": f"Setting {key} updated successfully",+ "warnings": [],+ }+ # POSITIVE CONTROL: the debug line fired, reached the sink, and names+ # the key and the warning count.+ assert f"Setting {key} changed" in loguru_caplog.text+ assert "calculated 0 warnings" in loguru_caplog.text+ assert sentinel not in loguru_caplog.text