commit 2a4a393: [Minor] Add implicit score for rbl and multimap rules

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jun 12 15:21:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-06-12 16:16:11 +0100
URL: https://github.com/rspamd/rspamd/commit/2a4a393ff51b2f110426ea9d52936d136a5ddcd3

[Minor] Add implicit score for rbl and multimap rules

---
 src/plugins/lua/multimap.lua | 12 +++++++++---
 src/plugins/lua/rbl.lua      |  6 ++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua
index c3225ff25..f82a4fb38 100644
--- a/src/plugins/lua/multimap.lua
+++ b/src/plugins/lua/multimap.lua
@@ -1265,6 +1265,10 @@ if opts and type(opts) == 'table' then
         rule['symbols_set'][s] = 1
       end, rule['symbols'])
     end
+    if not rule.score then
+      rspamd_logger.infox(rspamd_config, 'set default score 0 for multimap rule %s', rule.symbol)
+      rule.score = 0
+    end
     if rule['score'] then
       -- Register metric symbol
       rule.name = rule.symbol
@@ -1275,11 +1279,13 @@ if opts and type(opts) == 'table' then
     end
   end, fun.filter(function(r) return not r['prefilter'] end, rules))
 
-  fun.each(function(r)
+  -- prefilter symbils
+  fun.each(function(rule)
     rspamd_config:register_symbol({
       type = 'prefilter',
-      name = r['symbol'],
-      callback = gen_multimap_callback(r),
+      name = rule['symbol'],
+      score = rule.score or 0,
+      callback = gen_multimap_callback(rule),
     })
   end, fun.filter(function(r) return r['prefilter'] end, rules))
 
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index d299575ee..f0165c4ab 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -954,6 +954,8 @@ local function add_rbl(key, rbl, global_opts)
         rspamd_config:register_symbol{
           type = 'virtual',
           parent = id,
+          group = 'rbl',
+          score = 0,
           name = prefix .. '_' .. rbl.symbol,
         }
       end
@@ -969,6 +971,8 @@ local function add_rbl(key, rbl, global_opts)
         type = 'callback',
         callback = callback,
         name = rbl.symbol,
+        group = 'rbl',
+        score = 0,
         flags = table.concat(flags_tbl, ',')
       }
       if not (rbl.is_whitelist or rbl.ignore_whitelist) then
@@ -1008,6 +1012,8 @@ local function add_rbl(key, rbl, global_opts)
             type = 'virtual',
             parent = id,
             name = s,
+            group = 'rbl',
+            score = 0,
           }
         end
         if rbl.is_whitelist then


More information about the Commits mailing list