From f015521e4ac67946d322aa4df4fb63a12345e5cc Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 27 May 2022 21:00:49 +0100 Subject: [PATCH] [Minor] Remove legacy `default` metric --- lualib/lua_scanners/common.lua | 8 ++++---- src/plugins/lua/clickhouse.lua | 4 ++-- src/plugins/lua/elastic.lua | 4 ++-- src/plugins/lua/force_actions.lua | 2 +- src/plugins/lua/greylist.lua | 2 +- src/plugins/lua/metadata_exporter.lua | 14 +++++++------- src/plugins/lua/milter_headers.lua | 14 +++++++------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua index 2d4f2cf63..c2e314d39 100644 --- a/lualib/lua_scanners/common.lua +++ b/lualib/lua_scanners/common.lua @@ -183,8 +183,8 @@ end local function dynamic_scan(task, rule) if rule.dynamic_scan then if rule.action ~= 'reject' then - local metric_result = task:get_metric_score('default') - local metric_action = task:get_metric_action('default') + local metric_result = task:get_metric_score() + local metric_action = task:get_metric_action() local has_pre_result = task:has_pre_result() -- ToDo: needed? -- Sometimes leads to FPs @@ -482,8 +482,8 @@ end local function check_metric_results(task, rule) if rule.action ~= 'reject' then - local metric_result = task:get_metric_score('default') - local metric_action = task:get_metric_action('default') + local metric_result = task:get_metric_score() + local metric_action = task:get_metric_action() local has_pre_result = task:has_pre_result() if rule.symbol_type == 'postfilter' and metric_action == 'reject' then diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 540b87ac9..8a40bb800 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -548,7 +548,7 @@ local function clickhouse_collect(task) local message_id = lua_util.maybe_obfuscate_string(task:get_message_id() or '', settings, 'mid') - local score = task:get_metric_score('default')[1]; + local score = task:get_metric_score()[1]; local fields = { bayes = 'unknown', fuzzy = 'unknown', @@ -657,7 +657,7 @@ local function clickhouse_collect(task) gmt = true, -- The only sane way to sync stuff with different timezones })) - local action = task:get_metric_action('default') + local action = task:get_metric_action() local custom_action = '' if not predefined_actions[action] then diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua index e8b5b6434..3fffd6612 100644 --- a/src/plugins/lua/elastic.lua +++ b/src/plugins/lua/elastic.lua @@ -147,12 +147,12 @@ local function get_general_metadata(task) r.direction = "Inbound" r.user = task:get_user() or 'unknown' r.qid = task:get_queue_id() or 'unknown' - r.action = task:get_metric_action('default') + r.action = task:get_metric_action() r.rspamd_server = HOSTNAME if r.user ~= 'unknown' then r.direction = "Outbound" end - local s = task:get_metric_score('default')[1] + local s = task:get_metric_score()[1] r.score = s local rcpt = task:get_recipients('smtp') diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index 78676484a..4704b849b 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -90,7 +90,7 @@ local function gen_cb(params) return extracted end - local cact = task:get_metric_action('default') + local cact = task:get_metric_action() if not params.message and not params.subject and params.act and cact == params.act then return false end diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 405e22f9d..ae2cd02f9 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -306,7 +306,7 @@ local function greylist_check(task) end local function greylist_set(task) - local action = task:get_metric_action('default') + local action = task:get_metric_action() local ip = task:get_ip() -- Don't do anything if pre-result has been already set diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 6316ddc09..d72454f86 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -75,10 +75,10 @@ local function get_general_metadata(task, flatten, no_content) r.user = task:get_user() or 'unknown' r.qid = task:get_queue_id() or 'unknown' r.subject = task:get_subject() or 'unknown' - r.action = task:get_metric_action('default') + r.action = task:get_metric_action() r.rspamd_server = HOSTNAME - local s = task:get_metric_score('default')[1] + local s = task:get_metric_score()[1] r.score = flatten and string.format('%.2f', s) or s local fuzzy = task:get_mempool():get_variable("fuzzy_hashes", "fstrings") @@ -238,29 +238,29 @@ local selectors = { return true end, is_spam = function(task) - local action = task:get_metric_action('default') + local action = task:get_metric_action() return is_spam(action) end, is_spam_authed = function(task) if not task:get_user() then return false end - local action = task:get_metric_action('default') + local action = task:get_metric_action() return is_spam(action) end, is_reject = function(task) - local action = task:get_metric_action('default') + local action = task:get_metric_action() return (action == 'reject') end, is_reject_authed = function(task) if not task:get_user() then return false end - local action = task:get_metric_action('default') + local action = task:get_metric_action() return (action == 'reject') end, is_not_soft_reject = function(task) - local action = task:get_metric_action('default') + local action = task:get_metric_action() return (action ~= 'soft reject') end, } diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua index 4513ab7e1..93719aa58 100644 --- a/src/plugins/lua/milter_headers.lua +++ b/src/plugins/lua/milter_headers.lua @@ -246,10 +246,10 @@ local function milter_headers(task) common.symbols = task:get_symbols_all() end if not common['metric_score'] then - common['metric_score'] = task:get_metric_score('default') + common['metric_score'] = task:get_metric_score() end if not common['metric_action'] then - common['metric_action'] = task:get_metric_action('default') + common['metric_action'] = task:get_metric_action() end if local_mod.remove then remove[local_mod.header] = local_mod.remove @@ -351,7 +351,7 @@ local function milter_headers(task) local local_mod = settings.routines['x-spamd-bar'] if skip_wanted('x-rspamd-bar') then return end if not common['metric_score'] then - common['metric_score'] = task:get_metric_score('default') + common['metric_score'] = task:get_metric_score() end local score = common['metric_score'][1] local spambar @@ -374,7 +374,7 @@ local function milter_headers(task) local local_mod = settings.routines['x-spam-level'] if skip_wanted('x-spam-level') then return end if not common['metric_score'] then - common['metric_score'] = task:get_metric_score('default') + common['metric_score'] = task:get_metric_score() end local score = common['metric_score'][1] if score < 1 then @@ -389,7 +389,7 @@ local function milter_headers(task) local function spam_header (class, name, value, remove_v) if skip_wanted(class) then return end if not common['metric_action'] then - common['metric_action'] = task:get_metric_action('default') + common['metric_action'] = task:get_metric_action() end if remove_v then remove[name] = remove_v @@ -492,10 +492,10 @@ local function milter_headers(task) routines['x-spam-status'] = function() if skip_wanted('x-spam-status') then return end if not common['metric_score'] then - common['metric_score'] = task:get_metric_score('default') + common['metric_score'] = task:get_metric_score() end if not common['metric_action'] then - common['metric_action'] = task:get_metric_action('default') + common['metric_action'] = task:get_metric_action() end local score = common['metric_score'][1] local action = common['metric_action'] -- 2.39.5