~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
Enhance CI security checks with comprehensive file type detection (#444)
LearningCircuita08b8291f495
diff --git a/.github/workflows/file-whitelist-check.yml b/.github/workflows/file-whitelist-check.ymlindex e8778e7bf6..64345a2440 100644--- a/.github/workflows/file-whitelist-check.yml+++ b/.github/workflows/file-whitelist-check.yml@@ -1,4 +1,5 @@name: File Whitelist Security Check+# Enhanced security checks with comprehensive file type detectionon:pull_request:@@ -55,11 +56,40 @@ jobs:"installers/.*\.(bat|ps1|iss|ico)$")- # Get list of changed files+ # Get list of files to check+ echo "🔧 DEBUG: GITHUB_EVENT_NAME=$GITHUB_EVENT_NAME"+ echo "🔧 DEBUG: GITHUB_BASE_REF=$GITHUB_BASE_REF"+if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then- CHANGED_FILES=$(git diff --name-only origin/$GITHUB_BASE_REF..HEAD)+ # For PRs: check all files that would be added/modified in the entire PR+ echo "🔍 Checking all files in PR commits from $GITHUB_BASE_REF to HEAD..."++ echo "🔧 DEBUG: Running git diff command..."+ CHANGED_FILES=$(git diff --name-only --diff-filter=AM origin/$GITHUB_BASE_REF..HEAD)+ echo "🔧 DEBUG: git diff found $(echo "$CHANGED_FILES" | wc -l) files"++ echo "🔧 DEBUG: Running git log command..."+ # Also get newly added files across all commits in the PR+ # Use a more robust approach that handles edge cases+ ALL_NEW_FILES=$(git log --name-only --pretty=format: --diff-filter=A origin/$GITHUB_BASE_REF..HEAD 2>/dev/null | grep -v '^$' | sort | uniq || echo "")+ echo "🔧 DEBUG: git log found $(echo "$ALL_NEW_FILES" | wc -w) files"++ # Combine both lists and remove duplicates - handle empty ALL_NEW_FILES+ if [ -n "$ALL_NEW_FILES" ]; then+ CHANGED_FILES=$(echo -e "$CHANGED_FILES\n$ALL_NEW_FILES" | sort | uniq | grep -v '^$')+ fi+ echo "🔧 DEBUG: Combined list has $(echo "$CHANGED_FILES" | wc -l) files"else- CHANGED_FILES=$(git diff --name-only HEAD~1..HEAD)+ # For direct pushes: check files in the current commit+ echo "🔧 DEBUG: Direct push mode - checking HEAD~1..HEAD"+ CHANGED_FILES=$(git diff --name-only --diff-filter=AM HEAD~1..HEAD)+ echo "🔧 DEBUG: Found $(echo "$CHANGED_FILES" | wc -l) files in direct push"+ fi++ echo "🔧 DEBUG: Files to check:"+ echo "$CHANGED_FILES" | head -10+ if [ $(echo "$CHANGED_FILES" | wc -l) -gt 10 ]; then+ echo "🔧 DEBUG: ... and $(echo "$CHANGED_FILES" | wc -l | awk '{print $1-10}') more files"fiecho "🔍 Running comprehensive security checks..."@@ -76,10 +106,17 @@ jobs:HIGH_ENTROPY_VIOLATIONS=()HARDCODED_PATH_VIOLATIONS=()HARDCODED_IP_VIOLATIONS=()+ SUSPICIOUS_FILETYPE_VIOLATIONS=()+ echo "🔧 DEBUG: Starting file processing loop..."+ FILE_COUNT=0for file in $CHANGED_FILES; do+ FILE_COUNT=$((FILE_COUNT + 1))+ echo "🔧 DEBUG: Processing file $FILE_COUNT: $file"+# Skip deleted filesif [ ! -f "$file" ]; then+ echo "🔧 DEBUG: File $file does not exist, skipping"continuefi@@ -237,10 +274,52 @@ jobs:fififi++ # 7. Suspicious file type check - detect potentially dangerous file types+ if [ -f "$file" ]; then+ # Check for suspicious file extensions+ if echo "$file" | grep -iE "\.(exe|dll|so|dylib|bin|deb|rpm|msi|dmg|pkg|app)$" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (executable/binary)")+ elif echo "$file" | grep -iE "\.(zip|tar|gz|rar|7z|tar\.gz|tar\.bz2|tgz)$" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (compressed archive)")+ elif echo "$file" | grep -iE "\.(log|tmp|temp|cache|bak|backup|swp|swo|DS_Store|thumbs\.db|desktop\.ini|~|\.orig|\.rej|\.patch)$" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (temporary/cache)")+ elif echo "$file" | grep -iE "\.(png|jpg|jpeg|gif|bmp|tiff|svg|ico|webp)$" >/dev/null; then+ # Images are suspicious unless in specific directories+ if ! echo "$file" | grep -qE "(docs/|\.github/|installers/.*\.(ico|png)$)"; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (image file)")+ fi+ elif echo "$file" | grep -iE "\.(mp3|mp4|wav|avi|mov|mkv|flv|wmv|webm|m4a|ogg)$" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (media file)")+ elif echo "$file" | grep -iE "\.(csv|xlsx|xls|doc|docx|pdf|ppt|pptx)$" >/dev/null; then+ # Documents are suspicious unless in docs directory+ if ! echo "$file" | grep -qE "docs/"; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (document file)")+ fi+ elif echo "$file" | grep -iE "\.(db|sqlite|sqlite3)$" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (database file)")+ elif echo "$file" | grep -iE "node_modules/|__pycache__/|\.pyc$|\.pyo$|\.egg-info/|dist/|build/|\.cache/" >/dev/null; then+ SUSPICIOUS_FILETYPE_VIOLATIONS+=("$file (build artifact/cache)")+ fi+ fifidone# Report all violations with detailed explanations+ echo "🔧 DEBUG: File processing completed. Checking violations..."+ echo "🔧 DEBUG: Whitelist violations: ${#WHITELIST_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Large files: ${#LARGE_FILES[@]}"+ echo "🔧 DEBUG: Binary files: ${#BINARY_FILES[@]}"+ echo "🔧 DEBUG: Secret violations: ${#SECRET_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Suspicious files: ${#SUSPICIOUS_FILES[@]}"+ echo "🔧 DEBUG: Research data violations: ${#RESEARCH_DATA_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Flask secret violations: ${#FLASK_SECRET_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Env file violations: ${#ENV_FILE_VIOLATIONS[@]}"+ echo "🔧 DEBUG: High entropy violations: ${#HIGH_ENTROPY_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Hardcoded path violations: ${#HARDCODED_PATH_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Hardcoded IP violations: ${#HARDCODED_IP_VIOLATIONS[@]}"+ echo "🔧 DEBUG: Suspicious filetype violations: ${#SUSPICIOUS_FILETYPE_VIOLATIONS[@]}"+TOTAL_VIOLATIONS=0if [ ${#WHITELIST_VIOLATIONS[@]} -gt 0 ]; then@@ -487,6 +566,67 @@ jobs:TOTAL_VIOLATIONS=$((TOTAL_VIOLATIONS + ${#HARDCODED_IP_VIOLATIONS[@]}))fi+ if [ ${#SUSPICIOUS_FILETYPE_VIOLATIONS[@]} -gt 0 ]; then+ echo ""+ echo "❌ SUSPICIOUS FILE TYPES - Potentially dangerous file types detected:"+ echo " These file types are commonly used for malware, data leaks, or bloat the repository."+ echo ""+ for violation in "${SUSPICIOUS_FILETYPE_VIOLATIONS[@]}"; do+ echo " 🚨 $violation"++ FILE_PATH="${violation%% (*}"+ FILE_CATEGORY="${violation##*\\(}"+ FILE_CATEGORY="${FILE_CATEGORY%\\)}"++ # Provide specific guidance based on file category+ case "$FILE_CATEGORY" in+ "executable/binary")+ echo " → Issue: Executable/binary files can contain malware"+ echo " → Fix: Remove executable files, use package managers instead"+ ;;+ "compressed archive")+ echo " → Issue: Compressed archives hide their contents from review"+ echo " → Fix: Extract contents and commit individual files instead"+ ;;+ "temporary/cache")+ echo " → Issue: Temporary/cache files should not be committed"+ echo " → Fix: Add to .gitignore and remove from repository"+ ;;+ "image file")+ echo " → Issue: Image files should only be in docs/ or .github/ directories"+ echo " → Fix: Move to docs/ directory or remove if unnecessary"+ ;;+ "media file")+ echo " → Issue: Media files are large and rarely needed in code repos"+ echo " → Fix: Use external hosting or remove if unnecessary"+ ;;+ "document file")+ echo " → Issue: Office documents should be in docs/ directory if needed"+ echo " → Fix: Move to docs/ directory or convert to markdown"+ ;;+ "database file")+ echo " → Issue: Database files contain data that shouldn't be in source control"+ echo " → Fix: Add to .gitignore and use migrations/seeds instead"+ ;;+ "build artifact/cache")+ echo " → Issue: Build artifacts and cache files bloat the repository"+ echo " → Fix: Add to .gitignore and remove from repository"+ ;;+ esac++ # Show file info if available+ if [ -f "$FILE_PATH" ]; then+ FILE_SIZE=$(stat -c%s "$FILE_PATH" 2>/dev/null || echo "unknown")+ if [ "$FILE_SIZE" != "unknown" ]; then+ READABLE_SIZE=$(echo $FILE_SIZE | awk '{if($1>=1048576) printf "%.1fMB", $1/1048576; else if($1>=1024) printf "%.1fKB", $1/1024; else printf "%dB", $1}')+ echo " → File size: $READABLE_SIZE"+ fi+ fi+ echo ""+ done+ TOTAL_VIOLATIONS=$((TOTAL_VIOLATIONS + ${#SUSPICIOUS_FILETYPE_VIOLATIONS[@]}))+ fi+# Final resultif [ $TOTAL_VIOLATIONS -eq 0 ]; thenecho ""@@ -503,6 +643,8 @@ jobs:echo " - Use .env.example files instead of .env"echo " - Replace absolute paths with relative paths or configs"echo " - Use DNS names instead of hardcoded IP addresses"+ echo " - Remove suspicious file types (executables, archives, temp files)"+ echo " - Move images/documents to appropriate directories (docs/, .github/)"echo ""echo "⚠️ SECURITY REMINDER: This is a public repository!"echo " Never commit sensitive data, API keys, or personal information."