~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
feat: Add danger zone alert system for security-critical files
LearningCircuitc348771a12d3
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERSindex 87318a6e97..26ce10eb14 100644--- a/.github/CODEOWNERS+++ b/.github/CODEOWNERS@@ -6,18 +6,27 @@* @LearningCircuit @hashedviking @djpetti# Critical infrastructure and release files require maintainer approval-/.github/ @LearningCircuit @hashedviking @djpetti-/pyproject.toml @LearningCircuit @hashedviking @djpetti/Dockerfile @LearningCircuit @hashedviking @djpetti/src/local_deep_research/__version__.py @LearningCircuit @hashedviking @djpetti-# CI/CD workflows and release automation-/.github/workflows/ @LearningCircuit @hashedviking @djpetti--# Core API and configuration changes+# Core API changes/src/local_deep_research/api/ @LearningCircuit @hashedviking @djpetti-/src/local_deep_research/config/ @LearningCircuit @hashedviking @djpetti# Database migrations and metrics (sensitive for data integrity)/src/local_deep_research/metrics/ @LearningCircuit @hashedviking @djpetti/src/local_deep_research/migrate*.py @LearningCircuit @hashedviking @djpetti++# Database and encryption - critical for security+/src/local_deep_research/database/ @LearningCircuit @hashedviking @djpetti+/src/local_deep_research/web/database/ @LearningCircuit @hashedviking @djpetti++# Authentication and security+/src/local_deep_research/web/auth/ @LearningCircuit @hashedviking @djpetti+/src/local_deep_research/security/ @LearningCircuit @hashedviking @djpetti++# Core application+/src/local_deep_research/web/app.py @LearningCircuit @hashedviking @djpetti++# Security configurations+/.secrets.baseline @LearningCircuit @hashedviking @djpetti+/docker-compose*.yml @LearningCircuit @hashedviking @djpettidiff --git a/.github/workflows/danger-zone-alert.yml b/.github/workflows/danger-zone-alert.ymlnew file mode 100644index 0000000000..3cdc79b75e--- /dev/null+++ b/.github/workflows/danger-zone-alert.yml@@ -0,0 +1,240 @@+name: 🚨 Danger Zone Alert++on:+ pull_request:+ types: [opened, synchronize]+ paths:+ # Only trigger for truly dangerous files+ - 'src/local_deep_research/database/encrypted_db.py'+ - 'src/local_deep_research/database/sqlcipher_*.py'+ - 'src/local_deep_research/web/auth/**'+ - 'src/local_deep_research/security/**'+ - '.secrets.baseline'+ - '**/password*.py'+ - '**/encrypt*.py'+ - '**/decrypt*.py'+ - '**/crypto*.py'++permissions:+ pull-requests: write+ checks: write++jobs:+ danger-alert:+ runs-on: ubuntu-latest++ steps:+ - name: Checkout code+ uses: actions/checkout@v5+ with:+ fetch-depth: 0++ - name: Analyze dangerous changes+ id: analyze+ run: |+ # Get list of modified files+ DANGEROUS_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -E "(encrypted_db|sqlcipher|auth/|security/|password|encrypt|decrypt|crypto|\.secrets)" || true)++ if [ -z "$DANGEROUS_FILES" ]; then+ echo "No dangerous files modified"+ echo "has_dangers=false" >> $GITHUB_OUTPUT+ exit 0+ fi++ echo "has_dangers=true" >> $GITHUB_OUTPUT++ # Analyze each dangerous file+ RISK_LEVEL="HIGH"+ ENCRYPTION_MODIFIED=false+ AUTH_MODIFIED=false+ SECRETS_MODIFIED=false++ for file in $DANGEROUS_FILES; do+ if [[ "$file" == *"encrypted_db"* ]] || [[ "$file" == *"sqlcipher"* ]]; then+ ENCRYPTION_MODIFIED=true+ RISK_LEVEL="CRITICAL"+ fi+ if [[ "$file" == *"auth/"* ]] || [[ "$file" == *"password"* ]]; then+ AUTH_MODIFIED=true+ RISK_LEVEL="CRITICAL"+ fi+ if [[ "$file" == *".secrets"* ]]; then+ SECRETS_MODIFIED=true+ fi+ done++ echo "risk_level=$RISK_LEVEL" >> $GITHUB_OUTPUT+ echo "encryption_modified=$ENCRYPTION_MODIFIED" >> $GITHUB_OUTPUT+ echo "auth_modified=$AUTH_MODIFIED" >> $GITHUB_OUTPUT+ echo "secrets_modified=$SECRETS_MODIFIED" >> $GITHUB_OUTPUT+ echo "dangerous_files<<EOF" >> $GITHUB_OUTPUT+ echo "$DANGEROUS_FILES" >> $GITHUB_OUTPUT+ echo "EOF" >> $GITHUB_OUTPUT++ - name: Post danger warning comment+ if: steps.analyze.outputs.has_dangers == 'true'+ uses: actions/github-script@v7+ with:+ script: |+ const risk_level = '${{ steps.analyze.outputs.risk_level }}';+ const encryption_modified = '${{ steps.analyze.outputs.encryption_modified }}' === 'true';+ const auth_modified = '${{ steps.analyze.outputs.auth_modified }}' === 'true';+ const secrets_modified = '${{ steps.analyze.outputs.secrets_modified }}' === 'true';+ const files = `${{ steps.analyze.outputs.dangerous_files }}`.split('\n').filter(f => f);++ // Build the warning message+ let message = risk_level === 'CRITICAL'+ ? '# 🚨🚨🚨 CRITICAL SECURITY FILES MODIFIED 🚨🚨🚨\n\n'+ : '# ⚠️ Security-Sensitive Files Modified\n\n';++ message += '**This PR modifies security-critical files. Please review with extra care!**\n\n';++ // Add specific warnings+ if (encryption_modified) {+ message += '### 🔐 DATABASE ENCRYPTION CHANGES DETECTED\n';+ message += '- Changes to encryption can corrupt existing databases\n';+ message += '- Verify SQLCipher pragma order is correct\n';+ message += '- Test with existing encrypted databases\n';+ message += '- Ensure backward compatibility\n\n';+ }++ if (auth_modified) {+ message += '### 🔑 AUTHENTICATION CHANGES DETECTED\n';+ message += '- Could affect user access and security\n';+ message += '- Verify session handling is secure\n';+ message += '- Test login/logout flows thoroughly\n';+ message += '- Check for privilege escalation risks\n\n';+ }++ if (secrets_modified) {+ message += '### 🤫 SECRETS CONFIGURATION MODIFIED\n';+ message += '- Changes to secret detection baseline\n';+ message += '- Verify no actual secrets are exposed\n\n';+ }++ // List modified files+ message += '### 📁 Modified Security Files:\n';+ for (const file of files) {+ const emoji = file.includes('encrypt') || file.includes('sqlcipher') ? '🔐'+ : file.includes('auth') || file.includes('password') ? '🔑'+ : file.includes('secret') ? '🤫'+ : '⚠️';+ message += `- ${emoji} \`${file}\`\n`;+ }++ // Add review checklist+ message += '\n---\n\n';+ message += '## ✅ Required Review Checklist\n\n';+ message += '**Reviewers: Please verify ALL items before approving:**\n\n';++ if (encryption_modified) {+ message += '### Encryption Review:\n';+ message += '- [ ] SQLCipher pragmas are in correct order (key before other pragmas)\n';+ message += '- [ ] No hardcoded encryption keys or passwords\n';+ message += '- [ ] Backward compatibility maintained\n';+ message += '- [ ] Tested with existing encrypted databases\n';+ message += '- [ ] Migration path provided if schema changes\n\n';+ }++ if (auth_modified) {+ message += '### Authentication Review:\n';+ message += '- [ ] No bypass of authentication checks\n';+ message += '- [ ] Session management is secure\n';+ message += '- [ ] Password hashing uses proper algorithms\n';+ message += '- [ ] No privilege escalation vulnerabilities\n';+ message += '- [ ] Rate limiting still enforced\n\n';+ }++ message += '### General Security Review:\n';+ message += '- [ ] No secrets or credentials in code\n';+ message += '- [ ] No debug code that bypasses security\n';+ message += '- [ ] Error messages don\'t leak sensitive info\n';+ message += '- [ ] Logging doesn\'t expose sensitive data\n';+ message += '- [ ] Input validation is proper\n\n';++ message += '---\n\n';+ message += '💡 **Tips for reviewers:**\n';+ message += '- Take extra time with these changes\n';+ message += '- Test locally with production-like data\n';+ message += '- When in doubt, request additional review\n';+ message += '- Consider running security tests manually\n\n';++ if (risk_level === 'CRITICAL') {+ message += '**⚠️ Due to the critical nature of these changes, please get a second reviewer if possible.**';+ }++ // Check if we already posted a comment+ const { data: comments } = await github.rest.issues.listComments({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number+ });++ const botComment = comments.find(comment =>+ comment.user.type === 'Bot' &&+ comment.body.includes('SECURITY FILES MODIFIED')+ );++ if (botComment) {+ // Update existing comment+ await github.rest.issues.updateComment({+ owner: context.repo.owner,+ repo: context.repo.repo,+ comment_id: botComment.id,+ body: message+ });+ } else {+ // Create new comment+ await github.rest.issues.createComment({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number,+ body: message+ });+ }++ - name: Create status check+ if: steps.analyze.outputs.has_dangers == 'true'+ uses: actions/github-script@v7+ with:+ script: |+ const risk_level = '${{ steps.analyze.outputs.risk_level }}';++ // Create a status check that shows in the PR+ await github.rest.checks.create({+ owner: context.repo.owner,+ repo: context.repo.repo,+ name: 'Security Review Required',+ head_sha: context.sha,+ status: 'completed',+ conclusion: 'neutral',+ output: {+ title: `⚠️ ${risk_level} Risk Security Changes`,+ summary: 'This PR contains changes to security-critical files. Please review the danger zone checklist in the PR comments before approving.'+ }+ });++ - name: Add labels+ if: steps.analyze.outputs.has_dangers == 'true'+ uses: actions/github-script@v7+ with:+ script: |+ const labels = ['security-review-needed'];++ if ('${{ steps.analyze.outputs.encryption_modified }}' === 'true') {+ labels.push('touches-encryption');+ }+ if ('${{ steps.analyze.outputs.auth_modified }}' === 'true') {+ labels.push('touches-authentication');+ }+ if ('${{ steps.analyze.outputs.risk_level }}' === 'CRITICAL') {+ labels.push('critical-changes');+ }++ // Add labels to PR+ await github.rest.issues.addLabels({+ owner: context.repo.owner,+ repo: context.repo.repo,+ issue_number: context.issue.number,+ labels: labels+ });diff --git a/docs/SECURITY_REVIEW_PROCESS.md b/docs/SECURITY_REVIEW_PROCESS.mdnew file mode 100644index 0000000000..61dd9483a4--- /dev/null+++ b/docs/SECURITY_REVIEW_PROCESS.md@@ -0,0 +1,110 @@+# Security Review Process++## Overview++This repository uses an automated alert system to highlight when PRs modify security-critical files. Instead of blocking development, we provide clear warnings and checklists to ensure dangerous changes get proper scrutiny.++## How It Works++### 🚨 Automatic Detection+When a PR modifies any of these files:+- Database encryption (`encrypted_db.py`, `sqlcipher_*.py`)+- Authentication (`/auth/` directory, `password*.py`)+- Security utilities (`/security/` directory)+- Encryption/decryption code (`*encrypt*.py`, `*decrypt*.py`, `*crypto*.py`)+- Secrets baseline (`.secrets.baseline`)++The CI will:+1. **Post a prominent warning comment** with security-specific review checklist+2. **Add labels** to the PR (`security-review-needed`, `touches-encryption`, etc.)+3. **Create a status check** showing "Security Review Required" (informational, not blocking)++### 📋 Review Checklists++The bot creates specific checklists based on what was modified:++#### For Encryption Changes:+- SQLCipher pragma order (key must come first)+- No hardcoded keys+- Backward compatibility+- Migration paths++#### For Authentication Changes:+- No auth bypasses+- Secure session handling+- Proper password hashing+- No privilege escalation++#### For All Security Changes:+- No exposed secrets+- No debug bypasses+- Safe error messages+- Secure logging++## For Developers++### When You Modify Security Files:++1. **Expect the warning** - It's not a failure, just a heads-up+2. **Self-review first** - Go through the checklist yourself+3. **Document your changes** - Explain WHY the security code needed to change+4. **Test thoroughly** - Especially with existing encrypted databases+5. **Be patient** - Security reviews take time++### Red Flags to Avoid:++❌ Changing pragma order in SQLCipher code+❌ Adding "temporary" auth bypasses+❌ Logging passwords or encryption keys+❌ Hardcoding credentials+❌ Disabling security checks "for testing"++## For Reviewers++### When You See the Warning:++1. **Take it seriously** - These files can break security if done wrong+2. **Go through the checklist** - Don't just check boxes, verify each item+3. **Test locally** - Especially encryption changes with real databases+4. **Ask questions** - If something seems off, dig deeper+5. **Get a second opinion** - For CRITICAL changes, ask another reviewer++### What Caused Our Previous Issue:++The SQLCipher pragma order bug that corrupted databases happened because:+- Pragmas were applied BEFORE setting the encryption key+- This wasn't caught in review despite being in "hotfix" branch+- The change seemed logical but was actually breaking++**Lesson:** Even "obvious" changes to encryption code need careful review!++## The Philosophy++- **Warnings, not blocks** - We trust developers but want awareness+- **Specific guidance** - Checklists for what to look for+- **Risk-based** - More critical files get scarier warnings+- **Educational** - Help reviewers know what to check++## Labels Added Automatically++- `security-review-needed` - Always added for security files+- `touches-encryption` - Database encryption modified+- `touches-authentication` - Auth system modified+- `critical-changes` - Multiple security systems affected++## It's Not Perfect++This system won't catch everything:+- Logic bugs in security code+- Subtle vulnerabilities+- Dependencies with security issues++It's meant to make reviewers **pause and think** when touching dangerous code.++## Questions?++If you're unsure about a security change:+1. Ask in the PR for additional reviewers+2. Test with production-like data+3. Consider doing a security-focused code review session+4. When in doubt, be more cautious