aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_scanners/icap.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-08-06 12:42:06 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-08-06 12:42:06 +0100
commita3b5ad3d3be5f44996d247e7b1486fcc9f8ba7e3 (patch)
tree996e39b86863fafa2d80fb0753d6469e86a0eafb /lualib/lua_scanners/icap.lua
parent0f57c944b0338b51a3cb6c37b8fa84508f75f8a9 (diff)
downloadrspamd-a3b5ad3d3be5f44996d247e7b1486fcc9f8ba7e3.tar.gz
rspamd-a3b5ad3d3be5f44996d247e7b1486fcc9f8ba7e3.zip
[Feature] Allow to save and show attachment name when inserting AV scan results
Diffstat (limited to 'lualib/lua_scanners/icap.lua')
-rw-r--r--lualib/lua_scanners/icap.lua30
1 files changed, 19 insertions, 11 deletions
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua
index af9d070dc..86def8edd 100644
--- a/lualib/lua_scanners/icap.lua
+++ b/lualib/lua_scanners/icap.lua
@@ -98,7 +98,7 @@ local function icap_config(opts)
return nil
end
-local function icap_check(task, content, digest, rule)
+local function icap_check(task, content, digest, rule, maybe_part)
local function icap_check_uncached ()
local upstream = rule.upstreams:get_upstream_round_robin()
local addr = upstream:get_addr()
@@ -162,7 +162,8 @@ local function icap_check(task, content, digest, rule)
else
rspamd_logger.errx(task, '%s: failed to scan, maximum retransmits '..
'exceed - error: %s', rule.log_prefix, err_m or '')
- common.yield_result(task, rule, 'failed - error: ' .. err_m or '', 0.0, 'fail')
+ common.yield_result(task, rule, 'failed - error: ' .. err_m or '',
+ 0.0, 'fail', maybe_part)
end
end
@@ -248,7 +249,8 @@ local function icap_check(task, content, digest, rule)
-- error returned
lua_util.debugm(rule.name, task,
'%s: icap error X-Infection-Found: %s', rule.log_prefix, icap_threat)
- common.yield_result(task, rule, icap_threat, 0, 'fail')
+ common.yield_result(task, rule, icap_threat, 0,
+ 'fail', maybe_part)
else
lua_util.debugm(rule.name, task,
'%s: icap X-Infection-Found: %s', rule.log_prefix, icap_threat)
@@ -295,10 +297,10 @@ local function icap_check(task, content, digest, rule)
end
end
if #threat_string > 0 then
- common.yield_result(task, rule, threat_string, rule.default_score)
- common.save_cache(task, digest, rule, threat_string, rule.default_score)
+ common.yield_result(task, rule, threat_string, rule.default_score, nil, maybe_part)
+ common.save_cache(task, digest, rule, threat_string, rule.default_score, maybe_part)
else
- common.save_cache(task, digest, rule, 'OK', 0)
+ common.save_cache(task, digest, rule, 'OK', 0, maybe_part)
common.log_clean(task, rule)
end
end
@@ -323,12 +325,15 @@ local function icap_check(task, content, digest, rule)
ICAP/1.0 500 Server error
]]--
rspamd_logger.errx(task, '%s: ICAP ERROR: %s', rule.log_prefix, icap_headers.icap)
- common.yield_result(task, rule, icap_headers.icap, 0.0, 'fail')
+ common.yield_result(task, rule, icap_headers.icap, 0.0,
+ 'fail', maybe_part)
return false
else
rspamd_logger.errx(task, '%s: unhandled response |%s|',
rule.log_prefix, string.gsub(result, "\r\n", ", "))
- common.yield_result(task, rule, 'unhandled icap response: ' .. icap_headers.icap or "-", 0.0, 'fail')
+ common.yield_result(task, rule,
+ 'unhandled icap response: ' .. icap_headers.icap or "-",
+ 0.0, 'fail', maybe_part)
end
end
end
@@ -371,12 +376,14 @@ local function icap_check(task, content, digest, rule)
else
rspamd_logger.errx(task, '%s: RESPMOD method not advertised: Methods: %s',
rule.log_prefix, icap_headers['Methods'])
- common.yield_result(task, rule, 'NO RESPMOD', 0.0, 'fail')
+ common.yield_result(task, rule, 'NO RESPMOD', 0.0,
+ 'fail', maybe_part)
end
else
rspamd_logger.errx(task, '%s: OPTIONS query failed: %s',
rule.log_prefix, icap_headers.icap or "-")
- common.yield_result(task, rule, 'OPTIONS query failed', 0.0, 'fail')
+ common.yield_result(task, rule, 'OPTIONS query failed', 0.0,
+ 'fail', maybe_part)
end
end
end
@@ -402,7 +409,8 @@ local function icap_check(task, content, digest, rule)
})
end
- if common.condition_check_and_continue(task, content, rule, digest, icap_check_uncached) then
+ if common.condition_check_and_continue(task, content, rule, digest,
+ icap_check_uncached, maybe_part) then
return
else
icap_check_uncached()