From edb449b3b936b8721e891d7552647a0d19b84e20 Mon Sep 17 00:00:00 2001 From: denpamusic Date: Wed, 18 Sep 2019 18:29:43 +0300 Subject: [Minor] Fix typos in p0f plugin - Improved tests to include cached response cases - Changed default socket location to /var/run/p0f as per @moisseev recommendation --- lualib/lua_scanners/p0f.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lualib/lua_scanners/p0f.lua') diff --git a/lualib/lua_scanners/p0f.lua b/lualib/lua_scanners/p0f.lua index 72093577b..b27a42ef6 100644 --- a/lualib/lua_scanners/p0f.lua +++ b/lualib/lua_scanners/p0f.lua @@ -51,10 +51,10 @@ local function p0f_check(task, ip, rule) local function trim(...) local vars = {...} - for k in pairs(vars) do + for k, v in ipairs(vars) do -- skip numbers, trim only strings if tonumber(vars[k]) == nil then - vars[k] = string.gsub(vars[k], '[^%w-_\\.\\(\\) ]', '') + vars[k] = string.gsub(v, '[^%w-_\\.\\(\\) ]', '') end end @@ -71,7 +71,7 @@ local function p0f_check(task, ip, rule) data = tostring(data) -- API response must be 232 bytes long - if (#data < 232) then + if #data ~= 232 then rspamd_logger.errx(task, 'malformed response from p0f on %s, %s bytes', rule.socket, #data) @@ -112,7 +112,6 @@ local function p0f_check(task, ip, rule) local function redis_set_cb(redis_set_err) if redis_set_err then rspamd_logger.errx(task, 'redis received an error: %s', redis_set_err) - return end end @@ -156,7 +155,7 @@ local function p0f_check(task, ip, rule) end local ret = nil - if rule.redis_prams then + if rule.redis_params then local key = rule.prefix .. ip:to_string() ret = lua_redis.redis_make_request(task, rule.redis_params, -- cgit v1.2.3