Compare commits

..

3 Commits

Author SHA1 Message Date
Jenkins Server
0d26003492 Merge remote-tracking branch 'origin/master' into jenkins-build-5 2026-09-22 12:53:19 +02:00
0b24fcdb8e OP#785 move to clamdscan command 2026-09-22 12:52:19 +02:00
Jenkins Server
b600b953ec Recommit for updates in build 4 2026-09-22 12:46:07 +02:00

View File

@@ -1,23 +1,26 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
# Set paths
SCAN_DIR="<%= @cv_scan_dir %>" SCAN_DIR="<%= @cv_scan_dir %>"
LOG_FILE="<%= @cv_logfile %>" LOG_FILE="<%= @cv_logfile %>"
TMP_ALERT="<%= @cv_alert_file %>" TMP_ALERT="<%= @cv_alert_file %>"
EMAIL="<%= @cv_alert_email %>" EMAIL="<%= @cv_alert_email %>"
# Run clamscan # Ensure the log directory exists
clamscan -r --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null mkdir -p "$(dirname "$LOG_FILE")"
# Check if infections were found # Preferred: clamdscan with multiscan + fdpass
if grep -q "Infected files: [^0]" "$LOG_FILE"; then clamdscan --multiscan --fdpass --infected --log="$LOG_FILE" "$SCAN_DIR" > /dev/null || true
echo "ClamAV has found infected files on $(hostname)!" > "$TMP_ALERT"
echo "" >> "$TMP_ALERT" # Check for infections (same logic as before)
grep "FOUND" "$LOG_FILE" >> "$TMP_ALERT" 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" mail -s "⚠️ ClamAV Alert on $(hostname)" "$EMAIL" < "$TMP_ALERT"
fi fi
# Clean up
rm -f "$TMP_ALERT" rm -f "$TMP_ALERT"