commit f6722f0: [Fix] Distinguish type from flags in register_symbol

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Apr 27 12:28:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-04-27 13:26:09 +0100
URL: https://github.com/rspamd/rspamd/commit/f6722f0534ff166c8e5a78221781d701d33d62d2 (HEAD -> master)

[Fix] Distinguish type from flags in register_symbol

---
 src/plugins/lua/asn.lua        |  4 ++--
 src/plugins/lua/mime_types.lua |  6 ++++--
 src/plugins/lua/neural.lua     | 12 ++++++++----
 src/plugins/lua/p0f.lua        |  4 ++--
 src/plugins/lua/ratelimit.lua  |  4 ++--
 src/plugins/lua/rbl.lua        |  3 ++-
 src/plugins/lua/replies.lua    |  6 ++++--
 src/plugins/lua/reputation.lua |  3 ++-
 src/plugins/lua/settings.lua   |  4 ++--
 9 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua
index 7f236ca99..89bc0dc85 100644
--- a/src/plugins/lua/asn.lua
+++ b/src/plugins/lua/asn.lua
@@ -126,10 +126,10 @@ end
 if configure_asn_module() then
   local id = rspamd_config:register_symbol({
     name = 'ASN_CHECK',
-    type = 'prefilter,nostat',
+    type = 'prefilter',
     callback = asn_check,
     priority = 8,
-    flags = 'empty',
+    flags = 'empty,nostat',
   })
   if options['symbol'] then
     rspamd_config:register_symbol({
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index b4c71e3f2..863e3a31a 100644
--- a/src/plugins/lua/mime_types.lua
+++ b/src/plugins/lua/mime_types.lua
@@ -573,7 +573,8 @@ if opts then
     local id = rspamd_config:register_symbol({
       name = 'MIME_TYPES_CALLBACK',
       callback = check_mime_type,
-      type = 'callback,nostat',
+      type = 'callback',
+      flags = 'nostat',
       group = 'mime_types',
     })
 
@@ -633,10 +634,11 @@ if opts then
       group = 'mime_types',
     })
     rspamd_config:register_symbol({
-      type = 'virtual,nostat',
+      type = 'virtual',
       name = 'MIME_TRACE',
       parent = id,
       group = 'mime_types',
+      flags = 'nostat',
       score = 0,
     })
   else
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index 37532d99d..732ab6dc2 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -1390,7 +1390,8 @@ end
 
 local id = rspamd_config:register_symbol({
   name = 'NEURAL_CHECK',
-  type = 'postfilter,nostat',
+  type = 'postfilter',
+  flags = 'nostat',
   priority = 6,
   callback = ann_scores_filter
 })
@@ -1426,7 +1427,8 @@ for k,r in pairs(rules) do
   })
   rspamd_config:register_symbol({
     name = rule_elt.symbol_spam,
-    type = 'virtual,nostat',
+    type = 'virtual',
+    flags = 'nostat',
     parent = id
   })
 
@@ -1438,14 +1440,16 @@ for k,r in pairs(rules) do
   })
   rspamd_config:register_symbol({
     name = rule_elt.symbol_ham,
-    type = 'virtual,nostat',
+    type = 'virtual',
+    flags = 'nostat',
     parent = id
   })
 end
 
 rspamd_config:register_symbol({
   name = 'NEURAL_LEARN',
-  type = 'idempotent,nostat,explicit_disable',
+  type = 'idempotent',
+  flags = 'nostat,explicit_disable',
   priority = 5,
   callback = ann_push_vector
 })
diff --git a/src/plugins/lua/p0f.lua b/src/plugins/lua/p0f.lua
index 3242e73b0..fcf54c0ee 100644
--- a/src/plugins/lua/p0f.lua
+++ b/src/plugins/lua/p0f.lua
@@ -85,10 +85,10 @@ if rule then
 
   local id = rspamd_config:register_symbol({
     name = 'P0F_CHECK',
-    type = 'prefilter,nostat',
+    type = 'prefilter',
     callback = check_p0f,
     priority = 8,
-    flags = 'empty',
+    flags = 'empty,nostat',
     group = N
   })
 
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua
index 731bd7ac3..db65415a9 100644
--- a/src/plugins/lua/ratelimit.lua
+++ b/src/plugins/lua/ratelimit.lua
@@ -856,11 +856,11 @@ if opts then
     lua_util.disable_module(N, "redis")
   else
     local s = {
-      type = 'prefilter,nostat',
+      type = 'prefilter',
       name = 'RATELIMIT_CHECK',
       priority = 7,
       callback = ratelimit_cb,
-      flags = 'empty',
+      flags = 'empty,nostat',
     }
 
     if settings.symbol then
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 430afaf34..73bddfdc9 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -990,7 +990,8 @@ local function add_rbl(key, rbl, global_opts)
 
     -- Failure symbol
     rspamd_config:register_symbol{
-      type = 'virtual,nostat',
+      type = 'virtual',
+      flags = 'nostat',
       name = rbl.symbol .. '_FAIL',
       parent = id,
       score = 0.0,
diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua
index 2160b0c50..247fcdd60 100644
--- a/src/plugins/lua/replies.lua
+++ b/src/plugins/lua/replies.lua
@@ -279,8 +279,9 @@ if opts then
 
       local id = rspamd_config:register_symbol({
         name = 'REPLIES_CHECK',
-        type = 'prefilter,nostat',
+        type = 'prefilter',
         callback = replies_check_cookie,
+        flags = 'nostat',
         priority = 10,
         group = "replies"
       })
@@ -302,7 +303,8 @@ if opts then
     })
     local id = rspamd_config:register_symbol({
       name = 'REPLIES_CHECK',
-      type = 'prefilter,nostat',
+      type = 'prefilter',
+      flags = 'nostat',
       callback = replies_check,
       priority = 10,
       group = "replies"
diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua
index f88973d71..86fd20767 100644
--- a/src/plugins/lua/reputation.lua
+++ b/src/plugins/lua/reputation.lua
@@ -1197,7 +1197,8 @@ local function parse_rule(name, tbl)
     -- Also register a postfilter
     rspamd_config:register_symbol{
       name = rule.symbol .. '_POST',
-      type = 'postfilter,nostat',
+      type = 'postfilter',
+      flags = 'nostat',
       callback = callback_gen(reputation_postfilter_cb, rule),
     }
   end
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index b497d4388..f9e3e2524 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -1149,10 +1149,10 @@ if redis_section then
   fun.each(function(id, h)
     rspamd_config:register_symbol({
       name = 'REDIS_SETTINGS' .. tostring(id),
-      type = 'prefilter,nostat',
+      type = 'prefilter',
       callback = gen_redis_callback(h, id),
       priority = 10,
-      flags = 'empty',
+      flags = 'empty,nostat',
     })
   end, redis_key_handlers)
 end


More information about the Commits mailing list