summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-01 15:55:25 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-01 15:58:42 +0100
commite660bc91c0fe21b578d0ab612665adf7c2866b8a (patch)
treec407ede538811184b37400786a52db2044871735 /src
parentc0ee70e9ce757e20e8df8c4bc17c26a98a4cc0b2 (diff)
downloadrspamd-e660bc91c0fe21b578d0ab612665adf7c2866b8a.tar.gz
rspamd-e660bc91c0fe21b578d0ab612665adf7c2866b8a.zip
[Feature] Distinguish AV failure from clean result
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/milter_headers.lua36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index 5e7fb21ed..a1d34f92d 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -73,6 +73,8 @@ local settings = {
remove = 1,
status_clean = nil,
status_infected = nil,
+ status_fail = nil,
+ symbols_fail = {},
symbols = {}, -- needs config
},
['x-spamd-bar'] = {
@@ -339,10 +341,12 @@ local function milter_headers(task)
local virii = {}
for _, sym in ipairs(settings.routines['x-virus'].symbols) do
local s = common.symbols_hash[sym]
- if ((s or E).options or E)[1] then
- table.insert(virii, table.concat(s.options, ','))
- elseif s then
- table.insert(virii, 'unknown')
+ if s then
+ if (s.options or E)[1] then
+ table.insert(virii, table.concat(s.options, ','))
+ elseif s then
+ table.insert(virii, 'unknown')
+ end
end
end
if #virii > 0 then
@@ -351,8 +355,28 @@ local function milter_headers(task)
virusstatus = settings.routines['x-virus'].status_infected .. ', ' .. virusstatus
end
add_header('x-virus', virusstatus)
- elseif settings.routines['x-virus'].status_clean then
- add_header('x-virus', settings.routines['x-virus'].status_clean)
+ else
+ local failed = false
+ local fail_reason = 'unknown'
+ for _, sym in ipairs(settings.routines['x-virus'].symbols_fail) do
+ local s = common.symbols_hash[sym]
+ if s then
+ failed = true
+ if (s.options or E)[1] then
+ fail_reason = table.concat(s.options, ',')
+ end
+ end
+ end
+ if not failed then
+ if settings.routines['x-virus'].status_clean then
+ add_header('x-virus', settings.routines['x-virus'].status_clean)
+ end
+ else
+ if settings.routines['x-virus'].status_clean then
+ add_header('x-virus', string.format('%s(%s)',
+ settings.routines['x-virus'].status_fail, fail_reason))
+ end
+ end
end
end