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: add Bearer scanner, defusedxml, and nh3 dependencies

LearningCircuit62464e4c5d7c
diff --git a/.github/workflows/bearer.yml b/.github/workflows/bearer.yml
new file mode 100644
index 0000000000..2b8c065cb5
--- /dev/null
+++ b/.github/workflows/bearer.yml
@@ -0,0 +1,97 @@
+name: Bearer Security Scan
+
+on:
+ push:
+ branches: [ main, dev ]
+ pull_request:
+ branches: [ main, dev ]
+ workflow_dispatch:
+ schedule:
+ # Run security scan daily at 4 AM UTC
+ - cron: '0 4 * * *'
+
+permissions: {} # Minimal top-level for OSSF Scorecard Token-Permissions
+
+jobs:
+ bearer-scan:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ security-events: write
+ actions: read
+
+ steps:
+ - name: Harden the runner (Audit all outbound calls)
+ uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0
+ with:
+ egress-policy: audit
+
+ - name: Checkout code
+ uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
+ with:
+ persist-credentials: false
+
+ - name: Run Bearer SAST Scanner
+ uses: bearer/bearer-action@828eeb928ce2f4a7ca5ed57fb8b59508cb8c79bc # v2
+ with:
+ scanner: sast,secrets
+ format: sarif
+ output: bearer-results.sarif
+
+ - name: Upload Bearer results to GitHub Security tab
+ uses: github/codeql-action/upload-sarif@32f7c15247fa6542dc765bd40f6a15dc2caeed89 # v4.31.2
+ if: always()
+ with:
+ sarif_file: bearer-results.sarif
+ category: bearer-security
+
+ - name: Upload Bearer results as artifact
+ uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
+ if: always()
+ with:
+ name: bearer-scan-results
+ path: bearer-results.sarif
+ retention-days: 7
+
+ - name: Display Bearer summary
+ if: always()
+ run: |
+ {
+ echo "## Bearer Security Scan Summary"
+ echo ""
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ if [ -f bearer-results.sarif ]; then
+ # Count findings by level
+ ERRORS=$(python3 -c "import json; data=json.load(open('bearer-results.sarif')); results=data.get('runs',[{}])[0].get('results',[]); print(len([r for r in results if r.get('level')=='error']))" 2>/dev/null || echo "0")
+ WARNINGS=$(python3 -c "import json; data=json.load(open('bearer-results.sarif')); results=data.get('runs',[{}])[0].get('results',[]); print(len([r for r in results if r.get('level')=='warning']))" 2>/dev/null || echo "0")
+ NOTES=$(python3 -c "import json; data=json.load(open('bearer-results.sarif')); results=data.get('runs',[{}])[0].get('results',[]); print(len([r for r in results if r.get('level')=='note']))" 2>/dev/null || echo "0")
+ TOTAL=$(python3 -c "import json; data=json.load(open('bearer-results.sarif')); print(len(data.get('runs',[{}])[0].get('results',[])))" 2>/dev/null || echo "0")
+
+ {
+ echo "📊 **Scan Results:**"
+ echo "- **Errors:** $ERRORS"
+ echo "- **Warnings:** $WARNINGS"
+ echo "- **Notes:** $NOTES"
+ echo "- **Total:** $TOTAL"
+ echo ""
+ } >> "$GITHUB_STEP_SUMMARY"
+
+ if [ "$ERRORS" -gt 0 ]; then
+ echo "⚠️ **Action Required:** Error-level issues found" >> "$GITHUB_STEP_SUMMARY"
+ elif [ "$WARNINGS" -gt 0 ]; then
+ echo "⚠️ **Review Recommended:** Warning-level issues found" >> "$GITHUB_STEP_SUMMARY"
+ else
+ echo "✅ **No Error or Warning level issues found**" >> "$GITHUB_STEP_SUMMARY"
+ fi
+
+ {
+ echo ""
+ echo "📋 **Details:**"
+ echo "- Bearer scans for sensitive data flow and secrets exposure"
+ echo "- Results uploaded to GitHub Security tab"
+ echo "- SARIF report available in artifacts"
+ } >> "$GITHUB_STEP_SUMMARY"
+ else
+ echo "❌ Bearer scan failed or no results generated" >> "$GITHUB_STEP_SUMMARY"
+ fi
diff --git a/pyproject.toml b/pyproject.toml
index eadefc0f75..60215542cb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -53,6 +53,8 @@ dependencies = [
"tiktoken~=0.12",
"xmltodict~=1.0",
"lxml~=6.0",
+ "defusedxml~=0.7", # XXE-safe XML parsing
+ "nh3~=0.3", # Backend HTML sanitization
"pdfplumber~=0.11",
"unstructured~=0.18",
"google-search-results~=2.4",
diff --git a/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py b/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py
index 5d8fc40120..57dab00fea 100644
--- a/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py
+++ b/src/local_deep_research/web_search_engines/engines/search_engine_pubmed.py
@@ -1,7 +1,8 @@
import re
-import xml.etree.ElementTree as ET
from typing import Any, Dict, List, Optional, Tuple
+from defusedxml import ElementTree as ET
+
from langchain_core.language_models import BaseLLM
from loguru import logger