diff options
-rw-r--r-- | lualib/lua_util.lua | 9 | ||||
-rw-r--r-- | src/plugins/lua/clickhouse.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/dmarc.lua | 5 | ||||
-rw-r--r-- | src/plugins/lua/greylist.lua | 9 | ||||
-rw-r--r-- | src/plugins/lua/ip_score.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 3 |
6 files changed, 23 insertions, 7 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua index 387952fef..c401610d5 100644 --- a/lualib/lua_util.lua +++ b/lualib/lua_util.lua @@ -135,4 +135,13 @@ exports.remove_email_aliases = function(email_addr) end end +exports.is_rspamc_or_controller = function(task) + local ua = task:get_request_header('User-Agent') or '' + local pwd = task:get_request_header('Password') + local is_rspamc = false + if tostring(ua) == 'rspamc' or pwd then is_rspamc = true end + + return is_rspamc +end + return exports diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index baee79ca7..eb4ad57b7 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -16,6 +16,7 @@ limitations under the License. local rspamd_logger = require 'rspamd_logger' local rspamd_http = require "rspamd_http" +local rspamd_lua_utils = require "lua_util" if confighelp then return @@ -345,6 +346,7 @@ local function clickhouse_quote(str) end local function clickhouse_collect(task) + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end local from_domain = '' local from_user = '' if task:has_from('smtp') then diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 02dc0bb97..10aa95589 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -197,11 +197,14 @@ end local dmarc_grammar = gen_dmarc_grammar() -local function dmarc_report(task, spf_ok, dkim_ok, disposition, sampled_out, hfromdom, spfdom, dres, spf_result) +local function dmarc_report(task, spf_ok, dkim_ok, disposition, + sampled_out, hfromdom, spfdom, dres, spf_result) local ip = task:get_from_ip() if not ip:is_valid() then return nil end + local rspamd_lua_utils = require "lua_util" + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end local dkim_pass = table.concat(dres.pass or E, '|') local dkim_fail = table.concat(dres.fail or E, '|') local dkim_temperror = table.concat(dres.temperror or E, '|') diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 424cf5509..586661d44 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -62,6 +62,7 @@ local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" local fun = require "fun" local hash = require "rspamd_cryptobox_hash" +local rspamd_lua_utils = require "lua_util" local function data_key(task) local cached = task:get_mempool():get_variable("grey_bodyhash") @@ -206,9 +207,7 @@ local function greylist_check(task) end_time, type) task:insert_result(settings['symbol'], 0.0, 'greylisted', end_time) - local ua = task:get_request_header('User-Agent') or '' - if tostring(ua) == 'rspamc' then return end -- Likely rspamc scan - + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end if settings.message_func then task:set_pre_result('soft reject', settings.message_func(task, end_time)) @@ -310,9 +309,7 @@ local function greylist_set(task) end end - local ua = task:get_request_header('User-Agent') or '' - local is_rspamc = false - if tostring(ua) == 'rspamc' then is_rspamc = true end + local is_rspamc = rspamd_lua_utils.is_rspamc_or_controller(task) if is_whitelisted then if action == 'greylist' then diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index a1a88d4b2..879aff74c 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -22,6 +22,7 @@ end local rspamd_logger = require "rspamd_logger" local rspamd_regexp = require "rspamd_regexp" local rspamd_util = require "rspamd_util" +local rspamd_lua_utils = require "lua_util" -- Default settings local redis_params = nil @@ -96,6 +97,7 @@ end -- Set score based on metric's action local ip_score_set = function(task) + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end local function new_score_set(score, old_score, old_total) local new_total if old_total == -1 or old_total ~= old_total then diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 02e9d4d6f..beb9eb283 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -48,6 +48,7 @@ end local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" +local rspamd_lua_utils = require "lua_util" local fun = require "fun" local user_keywords = {'user'} @@ -545,6 +546,7 @@ end --- Check limit local function rate_test(task) + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end rate_test_set(task, check_limits) end --- Update limit @@ -552,6 +554,7 @@ local function rate_set(task) local action = task:get_metric_action('default') if action ~= 'soft reject' then + if rspamd_lua_utils.is_rspamc_or_controller(task) then return end rate_test_set(task, set_limits) end end |