]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Remove legacy `default` metric
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 May 2022 20:00:49 +0000 (21:00 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 27 May 2022 20:00:49 +0000 (21:00 +0100)
lualib/lua_scanners/common.lua
src/plugins/lua/clickhouse.lua
src/plugins/lua/elastic.lua
src/plugins/lua/force_actions.lua
src/plugins/lua/greylist.lua
src/plugins/lua/metadata_exporter.lua
src/plugins/lua/milter_headers.lua

index 2d4f2cf633b7e9703c7429128967ac9e1e4625c0..c2e314d39cd2f6ff9d58e8b4e17a377e011f25c0 100644 (file)
@@ -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
index 540b87ac93df5eda9ff62f36471ba1ce6e4eed1b..8a40bb80076e0b149b88d10626532044e2f94acd 100644 (file)
@@ -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
index e8b5b6434e20bc4f30337612a886e66d483a1d73..3fffd6612a0127e19ff2b155f7c38f4084362476 100644 (file)
@@ -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')
index 78676484a9586553aff234dc6044e59cc63b5ea6..4704b849beea8e4d9900620958610557e5cb594f 100644 (file)
@@ -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
index 405e22f9ddcb794a2e0909e9a9cc845a6edde6e0..ae2cd02f90daf389a54272ab7f9718ac53565f6d 100644 (file)
@@ -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
index 6316ddc09dd4ec04c64efe40587555b9ffa12bda..d72454f861681b54f4297eeabf7cceca20e7168c 100644 (file)
@@ -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,
 }
index 4513ab7e1d36606a4f3c8b6c987f7e82fb91edeb..93719aa58bf561b073648f5cbfcb5e648d71b575 100644 (file)
@@ -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']