From f94bd5466c6be32fb246b5adccd7db97df9c8d44 Mon Sep 17 00:00:00 2001 From: cschantz Date: Tue, 11 Nov 2025 21:44:40 -0500 Subject: [PATCH] Fix ImunifyAV to run synchronously - wait for scan completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed ImunifyAV from asynchronous queue mode to synchronous scan mode to ensure scanners run sequentially and each completes before the next starts. Problem: - Used "malware on-demand queue put" which queues asynchronously - Scanner immediately moved to next scanner without waiting - Broke sequential scanning requirement - Output showed "scans queued" but scan was still running Solution: - Changed to "malware on-demand start --path" (synchronous) - Blocks until scan completes - Shows progress: "→ Scanning: /path" - Extracts infected count from malicious list - Now properly sequential: ImunifyAV → ClamAV → Maldet → RKHunter Result: - All 4 scanners now run completely sequentially - Each scanner waits for previous to finish - Proper "scan complete" reporting for ImunifyAV - Infected file counts tracked correctly Ensures scan integrity and proper resource management. --- modules/security/malware-scanner.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index e60d69f..47bad9e 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -657,15 +657,22 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do log_message "ImunifyAV: Updating signatures" imunify-antivirus update &>> "$LOG_DIR/imunify.log" + log_message "ImunifyAV: Starting on-demand scan (synchronous)" + + # Use on-demand start (synchronous) instead of queue (asynchronous) for path in "${SCAN_PATHS[@]}"; do if [ -d "$path" ]; then - log_message "ImunifyAV: Queuing $path" - imunify-antivirus malware on-demand queue put "$path" &>> "$LOG_DIR/imunify.log" + log_message "ImunifyAV: Scanning $path" + echo " → Scanning: $path" + imunify-antivirus malware on-demand start --path="$path" &>> "$LOG_DIR/imunify.log" fi done - echo "✓ ImunifyAV scans queued" | tee -a "$SUMMARY_FILE" - log_message "ImunifyAV: Scans queued successfully" + # Extract malicious file count + IMUNIFY_INFECTED=$(imunify-antivirus malware malicious list 2>/dev/null | grep -c "malicious" || echo 0) + + echo "✓ ImunifyAV scan complete - Found: $IMUNIFY_INFECTED" | tee -a "$SUMMARY_FILE" + log_message "ImunifyAV: Scan complete - $IMUNIFY_INFECTED malicious files" ;; clamav)