From: Carsten Rosenberg Date: Wed, 26 Sep 2018 12:31:47 +0000 (+0200) Subject: [Minor] Antivirus - configureable mime_part scanning X-Git-Tag: 1.8.1~135^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb58fb5440a4bc4dc02abbf7f61faa9bf01f17b6;p=thirdparty%2Frspamd.git [Minor] Antivirus - configureable mime_part scanning --- diff --git a/conf/modules.d/antivirus.conf b/conf/modules.d/antivirus.conf index 16f38fbdae..803820dbb2 100644 --- a/conf/modules.d/antivirus.conf +++ b/conf/modules.d/antivirus.conf @@ -18,8 +18,12 @@ antivirus { clamav { # If set force this action if any virus is found (default unset: no action is forced) # action = "reject"; - # if `true` only messages with non-image attachments will be checked (default true) - attachments_only = true; + # message = '${SCANNER}: virus found: "${VIRUS}"'; + # Scan mime_parts seperately - otherwise the complete mail will be transfered to AV Scanner + #scan_mime_parts = true; + # Scanning Text is suitable for some av scanner databases (e.g. Sanesecurity) + #scan_text_mime = false; + #scan_image_mime = false; # If `max_size` is set, messages > n bytes in size are not scanned #max_size = 20000000; # symbol to add (add it to metric if you want non-zero weight) diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 976e521f48..047035fc11 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -871,11 +871,17 @@ local function add_antivirus_rule(sym, opts) end return function(task) - if rule.attachments_only then + if rule.scan_mime_parts then local parts = task:get_parts() or {} for _,p in ipairs(parts) do - if not p:is_image() and not p:is_text() and not p:is_multipart() then + if ( + (p:is_image() and rule.scan_image_mime) + or (p:is_text() and rule.scan_text_mime) + or (p:is_multipart() and rule.scan_text_mime) + or (not p:is_image() and not p:is_text() and not p:is_multipart()) + ) then + local content = p:get_content() if content and #content > 0 then