diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-30 18:09:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-30 18:09:47 +0100 |
commit | 416f92636ecc6db7305db352638f2cc83f824449 (patch) | |
tree | 46f8fae1c45482a7959c945076bf12f3acf5e778 /src/plugins | |
parent | 2cf3ff82308ecdc16a70571bf97aa947262be602 (diff) | |
download | rspamd-416f92636ecc6db7305db352638f2cc83f824449.tar.gz rspamd-416f92636ecc6db7305db352638f2cc83f824449.zip |
[Feature] Add failure symbol for AV module
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/antivirus.lua | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 564f4162c..5abf652f8 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -471,10 +471,12 @@ local function clamav_check(task, rule) }) else rspamd_logger.errx(task, 'failed to scan, maximum retransmits exceed') + task:insert_result(rule['symbol_fail'], 0.0, 'retransmits exceed') upstream:fail() end else rspamd_logger.errx(task, 'failed to scan: %s', err) + task:insert_result(rule['symbol_fail'], 0.0, 'failed to scan') upstream:fail() end else @@ -496,6 +498,7 @@ local function clamav_check(task, rule) cached = vname else rspamd_logger.errx(task, 'unhandled response: %s', data) + task:insert_result(rule['symbol_fail'], 0.0, 'unhandled response') end end if cached then @@ -549,10 +552,12 @@ local function sophos_check(task, rule) }) else rspamd_logger.errx(task, 'failed to scan, maximum retransmits exceed') + task:insert_result(rule['symbol_fail'], 0.0, 'retransmits exceed') upstream:fail() end else rspamd_logger.errx(task, 'failed to scan: %s', err) + task:insert_result(rule['symbol_fail'], 0.0, 'failed to scan') upstream:fail() end else @@ -586,6 +591,7 @@ local function sophos_check(task, rule) conn:add_read(sophos_callback) else rspamd_logger.errx(task, 'unhandled response: %s', data) + task:insert_result(rule['symbol_fail'], 0.0, 'unhandled response') end end end @@ -712,9 +718,11 @@ local function savapi_check(task, rule) else rspamd_logger.errx(task, 'failed to scan, maximum retransmits exceed') upstream:fail() + task:insert_result(rule['symbol_fail'], 0.0, 'retransmits exceed') end else rspamd_logger.errx(task, 'failed to scan: %s', err) + task:insert_result(rule['symbol_fail'], 0.0, 'failed to scan') upstream:fail() end else @@ -774,6 +782,10 @@ local function add_antivirus_rule(sym, opts) if not opts['symbol'] then opts['symbol'] = sym end local cfg = av_types[opts['type']] + if not opts['symbol_fail'] then + opts['symbol_fail'] = string.upper(opts['type']) .. '_FAIL' + end + if not cfg then rspamd_logger.errx(rspamd_config, 'unknown antivirus type: %s', opts['type']) @@ -830,11 +842,17 @@ if opts and type(opts) == 'table' then if not cb then rspamd_logger.errx(rspamd_config, 'cannot add rule: "' .. k .. '"') else - local id = rspamd_config:register_symbol({ + rspamd_config:register_symbol({ type = 'normal', name = m['symbol'], callback = cb, }) + rspamd_config:register_symbol({ + type = 'virtual', + name = m['symbol_fail'], + parent = m['symbol'], + score = 0.0, + }) has_valid = true if type(m['patterns']) == 'table' then if m['patterns'][1] then @@ -844,7 +862,7 @@ if opts and type(opts) == 'table' then rspamd_config:register_symbol({ type = 'virtual', name = sym, - parent = id + parent = m['symbol'] }) end end @@ -854,7 +872,7 @@ if opts and type(opts) == 'table' then rspamd_config:register_symbol({ type = 'virtual', name = sym, - parent = id + parent = m['symbol'] }) end end |