~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
Pin third-party GitHub Actions to SHA and improve Dockerfile security (#1359)
LearningCircuitad9515225712
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.ymlindex d79eaa51ff..f3ddf5bb21 100644--- a/.github/workflows/docker-publish.yml+++ b/.github/workflows/docker-publish.yml@@ -192,7 +192,7 @@ jobs:uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0- name: Install Syft- uses: anchore/sbom-action/download-syft@v0+ uses: anchore/sbom-action/download-syft@43a17d6e7add2b5535efe4dcae9952337c479a93 # v0.20.11- name: Determine version tagid: versiondiff --git a/.github/workflows/mobile-ui-tests.yml b/.github/workflows/mobile-ui-tests.ymlindex f4a4ac7a10..679324f7fb 100644--- a/.github/workflows/mobile-ui-tests.yml+++ b/.github/workflows/mobile-ui-tests.yml@@ -117,7 +117,7 @@ jobs:- name: Publish Test Resultsif: always() && matrix.python-version == '3.12'- uses: EnricoMi/publish-unit-test-result-action@v2+ uses: EnricoMi/publish-unit-test-result-action@34d7c956a59aed1bfebf31df77b8de55db9bbaaf # v2.21.0with:files: tests/ui_tests/test-results.xmlcheck_name: Mobile UI Test Resultsdiff --git a/.github/workflows/owasp-zap-scan.yml b/.github/workflows/owasp-zap-scan.ymlindex 0002da616a..5501b6c127 100644--- a/.github/workflows/owasp-zap-scan.yml+++ b/.github/workflows/owasp-zap-scan.yml@@ -74,7 +74,7 @@ jobs:fi- name: Run ZAP Baseline Scan- uses: zaproxy/[email protected]+ uses: zaproxy/action-baseline@de8ad967d3548d44ef623df22cf95c3b0baf8b25 # v0.15.0with:target: 'http://localhost:5000'rules_file_name: '.zap/rules.tsv'@@ -162,7 +162,7 @@ jobs:fi- name: Run ZAP Full Scan- uses: zaproxy/[email protected]+ uses: zaproxy/action-full-scan@3c58388149901b9a03b7718852c5ba889646c27c # v0.13.0with:target: 'http://localhost:5000'rules_file_name: '.zap/rules.tsv'@@ -256,7 +256,7 @@ jobs:echo "Using automatic API endpoint discovery"- name: Run ZAP API Scan- uses: zaproxy/[email protected]+ uses: zaproxy/action-api-scan@5158fe4d9d8fcc75ea204db81317cce7f9e5453d # v0.10.0with:target: 'http://localhost:5000/api/v1'format: 'openapi'diff --git a/Dockerfile b/Dockerfileindex ca5d4cfbf5..9b1e6ef6ac 100644--- a/Dockerfile+++ b/Dockerfile@@ -16,8 +16,11 @@ RUN apt-get update && apt-get upgrade -y \pkg-config \curl \ca-certificates \- # Note: NodeSource install script from trusted source (https://github.com/nodesource/distributions)- && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \+ gnupg \+ # Add NodeSource GPG key and repository directly (pinned to Node.js 22.x LTS)+ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --batch --dearmor -o /usr/share/keyrings/nodesource.gpg \+ && echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \+ && apt-get update \&& apt-get install -y --no-install-recommends nodejs \&& rm -rf /var/lib/apt/lists/*@@ -59,12 +62,10 @@ FROM builder-base AS ldr-test# Note: Explicitly set even though inherited from builder-base for hadolint static analysisSHELL ["/bin/bash", "-o", "pipefail", "-c"]-# Install runtime dependencies for SQLCipher, Node.js, and testing tools+# Install additional runtime dependencies for testing tools+# Note: Node.js is already installed from builder-baseRUN apt-get update && apt-get upgrade -y \&& apt-get install -y --no-install-recommends \- sqlcipher \- libsqlcipher1 \- curl \xauth \xvfb \# Dependencies for Chromium@@ -86,9 +87,6 @@ RUN apt-get update && apt-get upgrade -y \libxkbcommon0 \libxrandr2 \xdg-utils \- # Note: NodeSource install script from trusted source (https://github.com/nodesource/distributions)- && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \- && apt-get install -y --no-install-recommends nodejs \&& rm -rf /var/lib/apt/lists/*# Set up Puppeteer environmentdiff --git a/src/local_deep_research/__version__.py b/src/local_deep_research/__version__.pyindex ddcaa45ea9..c45d9dbf3a 100644--- a/src/local_deep_research/__version__.py+++ b/src/local_deep_research/__version__.py@@ -1 +1 @@-__version__ = "1.3.11"+__version__ = "1.3.12"diff --git a/tests/settings/test_checkbox_save.py b/tests/settings/test_checkbox_save.pynew file mode 100644index 0000000000..bd058e6ad4--- /dev/null+++ b/tests/settings/test_checkbox_save.py@@ -0,0 +1,244 @@+"""+Tests for checkbox settings save behavior.++Verifies that checkbox settings (booleans) can be correctly saved as both+true and false values, and that the value persists correctly.+"""++from tests.test_utils import add_src_to_path++add_src_to_path()+++class TestCheckboxBooleanSave:+ """Test that boolean settings can be saved as true and false."""++ def test_parse_boolean_false_string(self):+ """parse_boolean should return False for 'false' string."""+ from src.local_deep_research.settings.manager import parse_boolean++ assert parse_boolean("false") is False+ assert parse_boolean("False") is False+ assert parse_boolean("FALSE") is False++ def test_parse_boolean_true_string(self):+ """parse_boolean should return True for 'true' string."""+ from src.local_deep_research.settings.manager import parse_boolean++ assert parse_boolean("true") is True+ assert parse_boolean("True") is True+ assert parse_boolean("TRUE") is True++ def test_parse_boolean_actual_booleans(self):+ """parse_boolean should handle actual boolean values."""+ from src.local_deep_research.settings.manager import parse_boolean++ assert parse_boolean(True) is True+ assert parse_boolean(False) is False++ def test_get_typed_setting_value_checkbox_false(self):+ """get_typed_setting_value should convert 'false' to False for checkbox."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Test with string "false" (as sent by hidden input)+ result = get_typed_setting_value(+ key="app.allow_registrations",+ value="false",+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result is False, (+ f"Expected False, got {result} (type: {type(result)})"+ )++ def test_get_typed_setting_value_checkbox_true(self):+ """get_typed_setting_value should convert 'true' to True for checkbox."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Test with string "true" (as sent by checkbox)+ result = get_typed_setting_value(+ key="app.allow_registrations",+ value="true",+ ui_element="checkbox",+ default=False,+ check_env=False,+ )+ assert result is True, (+ f"Expected True, got {result} (type: {type(result)})"+ )++ def test_get_typed_setting_value_checkbox_boolean_false(self):+ """get_typed_setting_value should preserve False boolean for checkbox."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Test with actual False boolean (as sent by AJAX)+ result = get_typed_setting_value(+ key="app.allow_registrations",+ value=False,+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result is False, (+ f"Expected False, got {result} (type: {type(result)})"+ )++ def test_get_typed_setting_value_checkbox_boolean_true(self):+ """get_typed_setting_value should preserve True boolean for checkbox."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Test with actual True boolean (as sent by AJAX)+ result = get_typed_setting_value(+ key="app.allow_registrations",+ value=True,+ ui_element="checkbox",+ default=False,+ check_env=False,+ )+ assert result is True, (+ f"Expected True, got {result} (type: {type(result)})"+ )+++class TestCheckboxFormDataHandling:+ """Test how form data is processed for checkbox settings."""++ def test_form_data_false_string_is_converted(self):+ """Form data with 'false' string should be converted to False boolean."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Simulate what happens when hidden fallback sends "false"+ form_value = "false" # This is what the hidden input sends+ result = get_typed_setting_value(+ key="app.debug",+ value=form_value,+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result is False+ assert isinstance(result, bool)++ def test_ajax_json_false_is_preserved(self):+ """AJAX JSON with false boolean should be preserved as False."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Simulate what happens when AJAX sends JSON with false+ json_value = False # This is what checkbox.checked returns+ result = get_typed_setting_value(+ key="app.debug",+ value=json_value,+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result is False+ assert isinstance(result, bool)+++class TestCheckboxMissingValue:+ """Test handling of missing checkbox values (key not in form data)."""++ def test_missing_checkbox_value_none_returns_default(self):+ """When checkbox value is None, default value is returned."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # When value is None, get_typed_setting_value returns the default+ # This is correct for settings that weren't included in form data+ result = get_typed_setting_value(+ key="app.debug",+ value=None,+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ # With value=None, the function returns the default+ assert result is True++ def test_parse_boolean_none_is_false(self):+ """parse_boolean treats None as False (HTML semantics)."""+ from src.local_deep_research.settings.manager import parse_boolean++ # parse_boolean directly returns False for None+ assert parse_boolean(None) is False++ def test_empty_string_is_false(self):+ """Empty string checkbox value should be treated as False."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ result = get_typed_setting_value(+ key="app.debug",+ value="",+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result is False+++class TestAllowRegistrationsSetting:+ """Specific tests for the app.allow_registrations setting."""++ def test_allow_registrations_default_value(self):+ """app.allow_registrations should have correct default in settings."""+ import json+ from pathlib import Path++ # Read the default settings file+ defaults_path = (+ Path(__file__).parent.parent.parent+ / "src"+ / "local_deep_research"+ / "defaults"+ / "default_settings.json"+ )+ if defaults_path.exists():+ with open(defaults_path) as f:+ defaults = json.load(f)++ setting = defaults.get("app.allow_registrations", {})+ assert setting.get("ui_element") == "checkbox"+ assert setting.get("value") is True # Default should be True++ def test_allow_registrations_can_be_set_false(self):+ """app.allow_registrations should be able to be set to False."""+ from src.local_deep_research.settings.manager import (+ get_typed_setting_value,+ )++ # Test setting to false via AJAX (boolean)+ result_ajax = get_typed_setting_value(+ key="app.allow_registrations",+ value=False,+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result_ajax is False++ # Test setting to false via POST (string)+ result_post = get_typed_setting_value(+ key="app.allow_registrations",+ value="false",+ ui_element="checkbox",+ default=True,+ check_env=False,+ )+ assert result_post is Falsediff --git a/tests/ui_tests/test_toast_notifications.js b/tests/ui_tests/test_toast_notifications.jsnew file mode 100644index 0000000000..67c5fe451d--- /dev/null+++ b/tests/ui_tests/test_toast_notifications.js@@ -0,0 +1,344 @@+/**+ * Test for toast notifications when saving settings+ *+ * This test verifies that toast notifications appear when checkbox settings are changed.+ */++const puppeteer = require('puppeteer');+const AuthHelper = require('./auth_helper');+const { getPuppeteerLaunchOptions } = require('./puppeteer_config');++const TEST_CONFIG = {+ TIMEOUTS: {+ SETTINGS_LOAD: 5000,+ TOAST_APPEAR: 5000,+ AJAX_SAVE: 3000,+ NAVIGATION: 30000+ },+ URLS: {+ BASE: 'http://localhost:5000',+ SETTINGS: 'http://localhost:5000/settings'+ },+ SELECTORS: {+ CHECKBOX: 'input[type="checkbox"].ldr-settings-checkbox',+ TOAST_CONTAINER: '#toast-container',+ TOAST: '.toast, .ldr-toast',+ TOAST_VISIBLE: '.toast.visible, .ldr-toast.visible'+ }+};++(async () => {+ let browser;+ let page;+ const consoleLogs = [];+ const networkRequests = [];+ const networkResponses = [];++ try {+ console.log('=== Testing Toast Notifications ===\n');++ browser = await puppeteer.launch(getPuppeteerLaunchOptions());+ page = await browser.newPage();+ await page.setViewport({ width: 1920, height: 1080 });++ // Capture ONLY toast-related console logs+ page.on('console', msg => {+ const text = msg.text();+ const type = msg.type();++ // Only log toast-related items+ if (text.includes('showMessage') ||+ text.includes('[Notification]') ||+ text.includes('toast') ||+ text.includes('Toast') ||+ text.includes('[DEBUG]') ||+ text.includes('[submitSettingsData]') ||+ text.includes('originalSettings cache')) {+ consoleLogs.push({ type, text, timestamp: Date.now() });+ console.log(`[BROWSER] ${text}`);+ }+ });++ // Capture page errors+ page.on('pageerror', error => {+ console.error(`[PAGE ERROR] ${error.message}`);+ consoleLogs.push({ type: 'pageerror', text: error.message, timestamp: Date.now() });+ });++ // Capture network requests+ page.on('request', req => {+ if (req.url().includes('save_all_settings') || req.url().includes('settings')) {+ networkRequests.push({+ url: req.url(),+ method: req.method(),+ timestamp: Date.now()+ });+ }+ });++ // Capture network responses+ page.on('response', async resp => {+ if (resp.url().includes('save_all_settings')) {+ try {+ const text = await resp.text();+ networkResponses.push({+ url: resp.url(),+ status: resp.status(),+ body: text.substring(0, 500),+ timestamp: Date.now()+ });+ console.log(`[NETWORK] Response from save_all_settings: ${resp.status()}`);+ } catch (e) {+ // Response already consumed+ }+ }+ });++ // Authenticate with a consistent user+ console.log('🔐 Authenticating...');+ const authHelper = new AuthHelper(page);+ const testUser = 'toast_test_user';+ const testPassword = 'T3st!Secure#2024$LDR';++ // Try to register/login this specific user+ try {+ await authHelper.ensureAuthenticated(testUser, testPassword);+ } catch (e) {+ console.log('Initial auth failed, trying direct registration...');+ try {+ await authHelper.register(testUser, testPassword);+ } catch (regErr) {+ console.log('Registration failed (user may exist), trying login...');+ await authHelper.login(testUser, testPassword);+ }+ }+ console.log('✅ Authenticated\n');++ // Navigate to settings+ console.log('📄 Navigating to settings page...');+ await page.goto(TEST_CONFIG.URLS.SETTINGS, {+ waitUntil: 'networkidle2',+ timeout: TEST_CONFIG.TIMEOUTS.NAVIGATION+ });++ // Check current URL+ let currentUrl = page.url();+ console.log(`Current URL: ${currentUrl}`);++ // Check if we got redirected to login - try login with our test user+ if (currentUrl.includes('/auth/login')) {+ console.log('⚠️ Redirected to login, attempting login...');+ await authHelper.login(testUser, testPassword);+ await page.goto(TEST_CONFIG.URLS.SETTINGS, {+ waitUntil: 'networkidle2',+ timeout: TEST_CONFIG.TIMEOUTS.NAVIGATION+ });+ currentUrl = page.url();+ console.log(`After re-login URL: ${currentUrl}`);+ }++ // Wait longer for settings to load (they load dynamically)+ console.log('Waiting for settings page to fully load...');+ await new Promise(resolve => setTimeout(resolve, 5000));++ // Debug: check page content+ const pageDebug = await page.evaluate(() => ({+ title: document.title,+ url: window.location.href,+ allCheckboxes: document.querySelectorAll('input[type="checkbox"]').length,+ ldrCheckboxes: document.querySelectorAll('input[type="checkbox"].ldr-settings-checkbox').length,+ anyInputs: document.querySelectorAll('input').length,+ settingsContent: !!document.getElementById('settings-content'),+ bodyText: document.body.textContent.substring(0, 500)+ }));+ console.log('Page debug info:', JSON.stringify(pageDebug, null, 2));++ // Try different selectors+ let checkboxSelector = TEST_CONFIG.SELECTORS.CHECKBOX;+ let checkboxes = await page.$$(checkboxSelector);++ if (checkboxes.length === 0) {+ console.log('No ldr-settings-checkbox found, trying any checkbox...');+ checkboxSelector = 'input[type="checkbox"]';+ checkboxes = await page.$$(checkboxSelector);+ }++ if (checkboxes.length === 0) {+ // Take screenshot for debugging+ await page.screenshot({ path: '/tmp/settings_no_checkboxes.png', fullPage: true });+ console.log('📸 Screenshot saved to /tmp/settings_no_checkboxes.png');+ throw new Error(`No checkboxes found. Page has ${pageDebug.anyInputs} inputs total.`);+ }++ console.log(`✅ Settings page loaded - found ${checkboxes.length} checkboxes\n`);++ // Check if window.ui is available+ const uiCheck = await page.evaluate(() => {+ return {+ windowUi: !!window.ui,+ showMessage: !!(window.ui && window.ui.showMessage),+ toastContainer: !!document.getElementById('toast-container')+ };+ });+ console.log('UI availability check:', JSON.stringify(uiCheck, null, 2));++ // Get first checkbox info+ const firstCheckbox = checkboxes[0];+ const checkboxInfo = await firstCheckbox.evaluate(el => ({+ name: el.name,+ checked: el.checked,+ id: el.id+ }));+ console.log('Testing checkbox:', JSON.stringify(checkboxInfo, null, 2));++ // Clear console logs before toggling+ consoleLogs.length = 0;+ networkRequests.length = 0;+ networkResponses.length = 0;++ console.log('\n🔄 Toggling checkbox...');+ const initialState = checkboxInfo.checked;+ await firstCheckbox.click();++ // Wait for AJAX save to complete+ console.log('⏳ Waiting for AJAX save...');+ await new Promise(resolve => setTimeout(resolve, TEST_CONFIG.TIMEOUTS.AJAX_SAVE));++ // Check checkbox state changed+ const newState = await firstCheckbox.evaluate(el => el.checked);+ console.log(`Checkbox state: ${initialState} → ${newState}`);++ // Check for toast in DOM+ const toastCheck = await page.evaluate(() => {+ const container = document.getElementById('toast-container');+ const toasts = document.querySelectorAll('.toast, .ldr-toast');+ const visibleToasts = document.querySelectorAll('.toast.visible, .ldr-toast.visible');++ let containerStyles = null;+ if (container) {+ const computed = window.getComputedStyle(container);+ containerStyles = {+ position: computed.position,+ top: computed.top,+ right: computed.right,+ zIndex: computed.zIndex,+ display: computed.display,+ visibility: computed.visibility+ };+ }++ let toastInfo = [];+ toasts.forEach((t, i) => {+ const computed = window.getComputedStyle(t);+ toastInfo.push({+ index: i,+ className: t.className,+ innerHTML: t.innerHTML.substring(0, 100),+ opacity: computed.opacity,+ transform: computed.transform,+ display: computed.display,+ visibility: computed.visibility+ });+ });++ return {+ containerExists: !!container,+ containerStyles,+ totalToasts: toasts.length,+ visibleToasts: visibleToasts.length,+ toastInfo+ };+ });++ console.log('\n📋 Toast DOM state:');+ console.log(JSON.stringify(toastCheck, null, 2));++ // Wait a bit more for toast animation+ await new Promise(resolve => setTimeout(resolve, 500));++ // Check again for visible toasts+ const finalToastCheck = await page.evaluate(() => {+ const visibleToasts = document.querySelectorAll('.toast.visible, .ldr-toast.visible');+ return {+ visibleToastsCount: visibleToasts.length,+ visibleToastsHTML: Array.from(visibleToasts).map(t => t.innerHTML.substring(0, 100))+ };+ });+ console.log('\n📋 Final toast check:');+ console.log(JSON.stringify(finalToastCheck, null, 2));++ // Print relevant console logs+ console.log('\n📝 Relevant browser console logs:');+ const relevantLogs = consoleLogs.filter(log =>+ log.text.includes('showMessage') ||+ log.text.includes('Notification') ||+ log.text.includes('toast') ||+ log.text.includes('DEBUG') ||+ log.text.includes('submitSettingsData') ||+ log.text.includes('originalSettings') ||+ log.type === 'error'+ );++ if (relevantLogs.length === 0) {+ console.log(' (No relevant logs captured - this is suspicious!)');+ } else {+ relevantLogs.forEach(log => {+ console.log(` [${log.type}] ${log.text}`);+ });+ }++ // Print network activity+ console.log('\n🌐 Network activity:');+ console.log(` Requests: ${networkRequests.length}`);+ networkRequests.forEach(req => {+ console.log(` ${req.method} ${req.url}`);+ });+ console.log(` Responses: ${networkResponses.length}`);+ networkResponses.forEach(resp => {+ console.log(` ${resp.status} ${resp.url}`);+ if (resp.body) {+ console.log(` Body: ${resp.body.substring(0, 200)}`);+ }+ });++ // Take screenshot+ const screenshotPath = '/tmp/toast_test_screenshot.png';+ await page.screenshot({ path: screenshotPath, fullPage: false });+ console.log(`\n📸 Screenshot saved to: ${screenshotPath}`);++ // Toggle back to original state+ console.log('\n🔄 Restoring original checkbox state...');+ await firstCheckbox.click();+ await new Promise(resolve => setTimeout(resolve, 1000));++ // Final verdict+ console.log('\n' + '='.repeat(60));+ if (finalToastCheck.visibleToastsCount > 0) {+ console.log('✅ SUCCESS: Toast notification appeared!');+ } else if (toastCheck.totalToasts > 0) {+ console.log('⚠️ PARTIAL: Toast created but not visible (CSS issue)');+ } else if (networkResponses.length > 0 && networkResponses[0].status === 200) {+ console.log('❌ ISSUE: Save succeeded but no toast was created');+ console.log(' Check if notification code is being reached');+ } else {+ console.log('❌ ISSUE: No save request or toast notification detected');+ }+ console.log('='.repeat(60));++ } catch (error) {+ console.error('\n❌ Test failed:', error.message);+ console.error(error.stack);++ // Print all console logs on failure+ console.log('\n📝 All browser console logs:');+ consoleLogs.forEach(log => {+ console.log(` [${log.type}] ${log.text}`);+ });++ process.exit(1);+ } finally {+ if (browser) {+ await browser.close();+ }+ }+})();