summaryrefslogtreecommitdiffstats
path: root/lualib/lua_scanners/kaspersky_av.lua
diff options
context:
space:
mode:
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>2019-01-13 00:25:05 +0100
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>2019-01-13 00:25:05 +0100
commit2703711c00e1ab689e8fc1099abae15c21fb089a (patch)
tree4648b4032bd389dee851227e39469bfd630d83f5 /lualib/lua_scanners/kaspersky_av.lua
parent776a0273b5dc02498fcc24373bdb76ae608219fa (diff)
downloadrspamd-2703711c00e1ab689e8fc1099abae15c21fb089a.tar.gz
rspamd-2703711c00e1ab689e8fc1099abae15c21fb089a.zip
[Minor] lua_scanners - module_name, typos, logging
Diffstat (limited to 'lualib/lua_scanners/kaspersky_av.lua')
-rw-r--r--lualib/lua_scanners/kaspersky_av.lua37
1 files changed, 23 insertions, 14 deletions
diff --git a/lualib/lua_scanners/kaspersky_av.lua b/lualib/lua_scanners/kaspersky_av.lua
index 40cb6eb76..b9b439f05 100644
--- a/lualib/lua_scanners/kaspersky_av.lua
+++ b/lualib/lua_scanners/kaspersky_av.lua
@@ -26,15 +26,16 @@ local rspamd_util = require "rspamd_util"
local rspamd_logger = require "rspamd_logger"
local common = require "lua_scanners/common"
-local N = "kaspersky"
+local module_name = "kaspersky"
local default_message = '${SCANNER}: virus found: "${VIRUS}"'
local function kaspersky_config(opts)
local kaspersky_conf = {
- scan_mime_parts = true;
- scan_text_mime = false;
- scan_image_mime = false;
+ module_name = module_name,
+ scan_mime_parts = true,
+ scan_text_mime = false,
+ scan_image_mime = false,
product_id = 0,
log_clean = false,
timeout = 5.0,
@@ -48,6 +49,14 @@ local function kaspersky_config(opts)
kaspersky_conf = lua_util.override_defaults(kaspersky_conf, opts)
+ if not kaspersky_conf.log_prefix then
+ if kaspersky_conf.name:lower() == kaspersky_conf.type:lower() then
+ kaspersky_conf.log_prefix = kaspersky_conf.name
+ else
+ kaspersky_conf.log_prefix = kaspersky_conf.name .. ' (' .. kaspersky_conf.type .. ')'
+ end
+ end
+
if not kaspersky_conf['servers'] then
rspamd_logger.errx(rspamd_config, 'no servers defined')
@@ -58,7 +67,7 @@ local function kaspersky_config(opts)
kaspersky_conf['servers'], 0)
if kaspersky_conf['upstreams'] then
- lua_util.add_debug_alias('antivirus', N)
+ lua_util.add_debug_alias('antivirus', kaspersky_conf.module_name)
return kaspersky_conf
end
@@ -110,7 +119,7 @@ local function kaspersky_check(task, content, digest, rule)
upstream = rule.upstreams:get_upstream_round_robin()
addr = upstream:get_addr()
- lua_util.debugm(N, task,
+ lua_util.debugm(rule.module_name, task,
'%s [%s]: retry IP: %s', rule['symbol'], rule['type'], addr)
tcp.request({
@@ -134,7 +143,7 @@ local function kaspersky_check(task, content, digest, rule)
upstream:ok()
data = tostring(data)
local cached
- lua_util.debugm(N, task, '%s [%s]: got reply: %s',
+ lua_util.debugm(rule.module_name, task, '%s [%s]: got reply: %s',
rule['symbol'], rule['type'], data)
if data == 'stream: OK' then
cached = 'OK'
@@ -142,13 +151,13 @@ local function kaspersky_check(task, content, digest, rule)
rspamd_logger.infox(task, '%s [%s]: message or mime_part is clean',
rule['symbol'], rule['type'])
else
- lua_util.debugm(N, task, '%s [%s]: message or mime_part is clean',
+ lua_util.debugm(rule.module_name, task, '%s [%s]: message or mime_part is clean',
rule['symbol'], rule['type'])
end
else
local vname = string.match(data, ': (.+) FOUND')
if vname then
- common.yield_result(task, rule, vname, N)
+ common.yield_result(task, rule, vname)
cached = vname
else
rspamd_logger.errx(task, 'unhandled response: %s', data)
@@ -156,7 +165,7 @@ local function kaspersky_check(task, content, digest, rule)
end
end
if cached then
- common.save_av_cache(task, digest, rule, cached, N)
+ common.save_av_cache(task, digest, rule, cached)
end
end
end
@@ -172,8 +181,8 @@ local function kaspersky_check(task, content, digest, rule)
})
end
- if common.need_av_check(task, content, rule, N) then
- if common.check_av_cache(task, digest, rule, kaspersky_check_uncached, N) then
+ if common.need_av_check(task, content, rule) then
+ if common.check_av_cache(task, digest, rule, kaspersky_check_uncached) then
return
else
kaspersky_check_uncached()
@@ -186,5 +195,5 @@ return {
description = 'kaspersky antivirus',
configure = kaspersky_config,
check = kaspersky_check,
- name = 'kaspersky'
-} \ No newline at end of file
+ name = module_name
+}