~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: address review feedback for file write security check
LearningCircuite1bddb43eae0
diff --git a/.github/workflows/security-file-write-check.yml b/.github/workflows/security-file-write-check.ymlindex 4af61d87d7..8126bd3660 100644--- a/.github/workflows/security-file-write-check.yml+++ b/.github/workflows/security-file-write-check.yml@@ -30,13 +30,14 @@ jobs:echo "========================================="# Patterns that might indicate writing sensitive data to disk+ # Note: Using basic grep patterns without lookaheadsSUSPICIOUS_PATTERNS=(# Python patterns- "\.write\(.*\).*#.*(?!test|mock|stub)"- "\.save\(.*\).*#.*(?!test|mock|stub)"- "\.dump\(.*\).*#.*(?!test|mock|stub)"- "open\(.*['\"]w['\"]"- "open\(.*['\"]wb['\"]"+ "\.write\("+ "\.save\("+ "\.dump\("+ "open\(.*['\"]w['\"].*\)"+ "open\(.*['\"]wb['\"].*\)""\.to_csv\(""\.to_json\(""\.to_excel\("@@ -55,7 +56,6 @@ jobs:"fs\.writeFileSync""fs\.createWriteStream""fs\.appendFile"- # Exclude certain directories)# Directories to exclude from checks@@ -85,6 +85,16 @@ jobs:"**/migrations/*.py")+ # Safe keywords that indicate encrypted or safe operations+ # Empty for now - will add on case-by-case basis+ SAFE_KEYWORDS=(+ )++ # Known safe usage patterns (logs, configs, etc.)+ # Empty for now - will add on case-by-case basis+ SAFE_USAGE_PATTERNS=(+ )+# Build exclude arguments for grepEXCLUDE_ARGS=""for dir in "${EXCLUDE_DIRS[@]}"; do@@ -97,57 +107,82 @@ jobs:# Track if we found any issuesFOUND_ISSUES=0+ ALL_MATCHES=""- # Check each pattern- for pattern in "${SUSPICIOUS_PATTERNS[@]}"; do- echo "Checking pattern: $pattern"-- # Use grep to find matches, but continue even if none found- matches=$(grep -rn "$pattern" . $EXCLUDE_ARGS --include="*.py" --include="*.js" --include="*.ts" 2>/dev/null || true)+ echo "Scanning codebase for suspicious patterns..."+ # Single pass to collect all matches+ for pattern in "${SUSPICIOUS_PATTERNS[@]}"; do+ matches=$(grep -rn -- "$pattern" . $EXCLUDE_ARGS --include="*.py" --include="*.js" --include="*.ts" 2>/dev/null || true)if [ -n "$matches" ]; then- # Filter out false positives- filtered_matches=""- while IFS= read -r line; do- # Skip if line contains certain keywords that indicate it's safe- if ! echo "$line" | grep -qE "(encrypted|encrypt|cipher|test_|mock_|stub_|# Safe:|# OK:|# TODO: encrypt|\.encrypted|_encrypted|get_encrypted_|set_encrypted_|storage/database|storage/encrypted|web/services/pdf_service\.py|web/services/research_service\.py:.*export_report_to_memory)"; then- # Skip known safe usages (logs, configs that don't contain sensitive data)- if ! echo "$line" | grep -qE "(logger\.|logging\.|print\(|console\.log|debug|\.write\(['\"](Starting|Stopping|Error|Warning|Info)|config\.toml|settings\.toml|\.env\.template)"; then- filtered_matches="$filtered_matches$line\n"- fi- fi- done <<< "$matches"-- if [ -n "$filtered_matches" ]; then- echo "⚠️ Found potential unencrypted file writes:"- echo -e "$filtered_matches"- FOUND_ISSUES=1- fi+ ALL_MATCHES="$ALL_MATCHES$matches\n"fidone- echo "========================================="+ # Also check for specific problematic patterns in one pass+ temp_matches=$(grep -rn -E "get_report_as_temp_file|tmp_path|tempfile|/tmp/" . $EXCLUDE_ARGS --include="*.py" 2>/dev/null || true)+ if [ -n "$temp_matches" ]; then+ ALL_MATCHES="$ALL_MATCHES$temp_matches\n"+ fi- # Check for specific problematic patterns- echo "Checking for temp file usage without proper cleanup..."- temp_issues=$(grep -rn "get_report_as_temp_file\|tmp_path\|tempfile\|/tmp/" . $EXCLUDE_ARGS --include="*.py" 2>/dev/null | grep -v "test" | grep -v "mock" | grep -v "# Safe:" || true)+ db_matches=$(grep -rn -E "report_content.*open|report_content.*write|markdown_content.*open|markdown_content.*write" . $EXCLUDE_ARGS --include="*.py" 2>/dev/null || true)+ if [ -n "$db_matches" ]; then+ ALL_MATCHES="$ALL_MATCHES$db_matches\n"+ fi- if [ -n "$temp_issues" ]; then- echo "⚠️ Found temporary file usage that might leave unencrypted data:"- echo "$temp_issues"- FOUND_ISSUES=1+ export_matches=$(grep -rn -E "export.*Path|export.*path\.open|export.*\.write" . --include="*.py" 2>/dev/null || true)+ if [ -n "$export_matches" ]; then+ ALL_MATCHES="$ALL_MATCHES$export_matches\n"fi- echo "========================================="+ # Now filter all matches at once+ if [ -n "$ALL_MATCHES" ]; then+ echo "Filtering results for false positives..."++ # Remove duplicates and sort+ ALL_MATCHES=$(echo -e "$ALL_MATCHES" | sort -u)- # Check for direct database content writes to files- echo "Checking for database content being written to files..."- db_write_issues=$(grep -rn "report_content.*open\|report_content.*write\|markdown_content.*open\|markdown_content.*write" . $EXCLUDE_ARGS --include="*.py" 2>/dev/null | grep -v "test" | grep -v "mock" || true)+ filtered_matches=""+ while IFS= read -r line; do+ [ -z "$line" ] && continue- if [ -n "$db_write_issues" ]; then- echo "⚠️ Found database content being written to files:"- echo "$db_write_issues"- FOUND_ISSUES=1+ # Check if line contains safe keywords+ skip_line=0+ for safe_pattern in "${SAFE_KEYWORDS[@]}"; do+ if echo "$line" | grep -qE -- "$safe_pattern"; then+ skip_line=1+ break+ fi+ done++ # Check if line contains safe usage patterns+ if [ "$skip_line" -eq 0 ]; then+ for usage_pattern in "${SAFE_USAGE_PATTERNS[@]}"; do+ if echo "$line" | grep -qE -- "$usage_pattern"; then+ skip_line=1+ break+ fi+ done+ fi++ # Additional filters for test/mock files that might not be caught by path exclusion+ if [ "$skip_line" -eq 0 ]; then+ if echo "$line" | grep -qE "test|mock|stub" | grep -qv "#"; then+ skip_line=1+ fi+ fi++ if [ "$skip_line" -eq 0 ]; then+ filtered_matches="$filtered_matches$line\n"+ FOUND_ISSUES=1+ fi+ done <<< "$ALL_MATCHES"++ if [ -n "$filtered_matches" ] && [ "$FOUND_ISSUES" -eq 1 ]; then+ echo "⚠️ Found potential unencrypted file writes:"+ echo "========================================="+ echo -e "$filtered_matches"+ fifiecho "========================================="@@ -166,16 +201,3 @@ jobs:elseecho "✅ Security check passed: No suspicious unencrypted file writes detected"fi-- - name: Check for export patterns- run: |- echo "Checking for export methods that might bypass encryption..."-- # Check if export methods are using in-memory patterns- if grep -rn "export.*Path\|export.*path\.open\|export.*\.write" . --include="*.py" | grep -v "test" | grep -v "export_report_to_memory" | grep -v "# Safe:"; then- echo "⚠️ Found export methods that might write to disk"- echo "Consider using in-memory patterns like export_report_to_memory()"- exit 1- fi-- echo "✅ Export methods appear to use safe patterns"