From 0b24fcdb8ea0eb35bb0a81199016c45d1e287088 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Tue, 22 Sep 2026 12:52:19 +0200 Subject: [PATCH] OP#785 move to clamdscan command --- .vscode/settings.json | 3 +++ templates/scan.sh.erb | 25 ++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 43d2b81..f3782e0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,6 +16,7 @@ "epel", "excludepaths", "fanotify", + "fdpass", "filesize", "freshclam", "getsebool", @@ -31,12 +32,14 @@ "logsyslog", "logtime", "logverbose", + "multiscan", "mypass", "myproxy", "myusername", "NOFILE", "normalisation", "PCRE", + "pipefail", "preludeanalyzername", "preludeenable", "recieve", diff --git a/templates/scan.sh.erb b/templates/scan.sh.erb index a6b951b..19f5eac 100644 --- a/templates/scan.sh.erb +++ b/templates/scan.sh.erb @@ -1,23 +1,26 @@ #!/bin/bash +set -euo pipefail -# Set paths SCAN_DIR="<%= @cv_scan_dir %>" LOG_FILE="<%= @cv_logfile %>" TMP_ALERT="<%= @cv_alert_file %>" EMAIL="<%= @cv_alert_email %>" -# Run clamscan -clamscan -r --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null +# Ensure the log directory exists +mkdir -p "$(dirname "$LOG_FILE")" -# Check if infections were found -if grep -q "Infected files: [^0]" "$LOG_FILE"; then - echo "ClamAV has found infected files on $(hostname)!" > "$TMP_ALERT" - echo "" >> "$TMP_ALERT" - grep "FOUND" "$LOG_FILE" >> "$TMP_ALERT" +# Preferred: clamdscan with multiscan + fdpass +clamdscan --multiscan --fdpass --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null || true + +# Check for infections (same logic as before) +if grep -q "Infected files: [^0]" "$LOG_FILE" 2>/dev/null; then + { + echo "ClamAV has found infected files on $(hostname)!" + echo "" + grep "FOUND" "$LOG_FILE" || true + } > "$TMP_ALERT" - # Send the alert email mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT" fi -# Clean up -rm -f "$TMP_ALERT" +rm -f "$TMP_ALERT" \ No newline at end of file