summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-18 12:47:18 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-18 12:47:18 +0000
commit617c1bd77dfb532fe47bd27e58a1202d744b0af1 (patch)
treeefecbd4df4b8cb0e612704722592c4460c426dbd /lualib
parente2c1dc95b2e24fdd96553a6f40bfa1f477ea834b (diff)
downloadrspamd-617c1bd77dfb532fe47bd27e58a1202d744b0af1.tar.gz
rspamd-617c1bd77dfb532fe47bd27e58a1202d744b0af1.zip
[Minor] P0f: Fix output
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_scanners/common.lua2
-rw-r--r--lualib/lua_scanners/p0f.lua26
2 files changed, 19 insertions, 9 deletions
diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua
index 117945dd4..80032676b 100644
--- a/lualib/lua_scanners/common.lua
+++ b/lualib/lua_scanners/common.lua
@@ -104,9 +104,9 @@ local function yield_result(task, rule, vname, dyn_weight, is_fail)
rspamd_logger.infox(task, '%s: "%s" is in whitelist', rule.log_prefix, tm)
else
all_whitelisted = false
- task:insert_result(symname, symscore, tm)
rspamd_logger.infox(task, '%s: result - %s: "%s - score: %s"',
rule.log_prefix, threat_info, tm, symscore)
+ task:insert_result(symname, symscore, tm)
end
end
diff --git a/lualib/lua_scanners/p0f.lua b/lualib/lua_scanners/p0f.lua
index 056c0ad8b..0e7bd4279 100644
--- a/lualib/lua_scanners/p0f.lua
+++ b/lualib/lua_scanners/p0f.lua
@@ -99,8 +99,13 @@ local function p0f_check(task, ip, rule)
task:get_mempool():set_variable('os_fingerprint', os_string, link_type,
uptime_min, distance)
- common.yield_result(task, rule, {
- os_string, link_type, 'distance:' .. distance }, 0.0)
+ if link_type and #link_type > 0 then
+ common.yield_result(task, rule, string.format('%s, link=%s, distance: %s',
+ os_string, link_type, distance), 0.0)
+ else
+ common.yield_result(task, rule, string.format('%s, distance: %s',
+ os_string, distance), 0.0)
+ end
return data
end
@@ -115,17 +120,22 @@ local function p0f_check(task, ip, rule)
end
end
+ if err then
+ rspamd_logger.errx(task, 'p0f received an error: %s', err)
+ return
+ end
+
data = parse_p0f_response(data)
if rule.redis_params and data then
local key = rule.prefix .. ip:to_string()
local ret = lua_redis.redis_make_request(task,
- rule.redis_params,
- key,
- true,
- redis_set_cb,
- 'SETEX',
- { key, tostring(rule.expire), data }
+ rule.redis_params,
+ key,
+ true,
+ redis_set_cb,
+ 'SETEX',
+ { key, tostring(rule.expire), data }
)
if not ret then