Fix ImunifyAV to run synchronously - wait for scan completion

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.
This commit is contained in:
cschantz
2025-11-11 21:44:40 -05:00
parent e6eb8fb160
commit 399181dd7b
+11 -4
View File
@@ -657,15 +657,22 @@ for scanner in "${AVAILABLE_SCANNERS[@]}"; do
log_message "ImunifyAV: Updating signatures" log_message "ImunifyAV: Updating signatures"
imunify-antivirus update &>> "$LOG_DIR/imunify.log" 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 for path in "${SCAN_PATHS[@]}"; do
if [ -d "$path" ]; then if [ -d "$path" ]; then
log_message "ImunifyAV: Queuing $path" log_message "ImunifyAV: Scanning $path"
imunify-antivirus malware on-demand queue put "$path" &>> "$LOG_DIR/imunify.log" echo " → Scanning: $path"
imunify-antivirus malware on-demand start --path="$path" &>> "$LOG_DIR/imunify.log"
fi fi
done done
echo "✓ ImunifyAV scans queued" | tee -a "$SUMMARY_FILE" # Extract malicious file count
log_message "ImunifyAV: Scans queued successfully" 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) clamav)