From 31053e9798b02c921699deea4acc112121c436dc Mon Sep 17 00:00:00 2001 From: Carsten Rosenberg Date: Tue, 20 Mar 2018 14:37:17 +0100 Subject: [PATCH] Respect Sophos/SAVDI FAIL212 REJ4 REJ1 Return Codes in antivirus.lua --- src/plugins/lua/antivirus.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 4b69b88504..46f556c1d2 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -531,6 +531,9 @@ local function sophos_check(task, rule) local bye = 'BYE\n' local function sophos_callback(err, data, conn) + rspamd_logger.errx(task, 'err: %s', err) + rspamd_logger.errx(task, 'data: %s', tostring(data)) + if err then if err == 'IO timeout' then if retransmits > 0 then @@ -554,6 +557,7 @@ local function sophos_check(task, rule) else upstream:ok() data = tostring(data) + rspamd_logger.errx(task, 'data2: %s', data) local vname = string.match(data, 'VIRUS (%S+) ') if vname then yield_result(task, rule, vname) @@ -564,6 +568,20 @@ local function sophos_check(task, rule) rspamd_logger.infox(task, '%s [%s]: message is clean', rule['symbol'], rule['type']) end save_av_cache(task, rule, 'OK') + elseif string.find(data, 'FAIL 0212') then + if rule['savdi_report_encrypted'] then + rspamd_logger.infox(task, 'Message is ENCRYPTED (0212 SOPHOS_SAVI_ERROR_FILE_ENCRYPTED): %s', data) + yield_result(task, rule, "SAVDI_FILE_ENCRYPTED") + save_av_cache(task, rule, "SAVDI_FILE_ENCRYPTED") + end + elseif string.find(data, 'REJ 4') then + if rule['savdi_report_oversize'] then + rspamd_logger.infox(task, 'Message is OVERSIZED (SSSP reject code 4): %s', data) + yield_result(task, rule, "SAVDI_FILE_OVERSIZED") + save_av_cache(task, rule, "SAVDI_FILE_OVERSIZED") + end + elseif string.find(data, 'REJ 1') then + rspamd_logger.errx(task, 'SAVDI (Protocol error (REJ 1)): %s', data) elseif string.find(data, 'ACC') or string.find(data, 'OK SSSP') then conn:add_read(sophos_callback) else @@ -866,4 +884,3 @@ if opts and type(opts) == 'table' then lua_util.disable_module(N, 'config') end end - -- 2.47.3