From 6692491ac02f47237391522302c760e94dc7214d Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Mon, 24 Oct 2016 11:40:49 +0200 Subject: [PATCH] [Feature] Allow for excluding messages from AV scanning based on size --- src/plugins/lua/antivirus.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 42c1fbf24..d4a0f7bba 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -162,18 +162,24 @@ local function sophos_config(opts) return nil end +local function message_not_too_large(task, rule) + local max_size = tonumber(rule['max_size']) + if not max_size then return true end + if task:get_size() > max_size then return false end + return true +end local function need_av_check(task, rule) if rule['attachments_only'] then for _,p in ipairs(task:get_parts()) do if p:get_filename() and not p:is_image() then - return true + return message_not_too_large(task, rule) end end return false else - return true + return message_not_too_large(task, rule) end end -- 2.39.5