]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Neural: Allow to blacklist specific symbols
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 4 Oct 2020 19:24:28 +0000 (20:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 4 Oct 2020 19:24:56 +0000 (20:24 +0100)
src/plugins/lua/neural.lua

index eda089abcad568dc62b621fa5478ff731a8071f2..124877927fae34476a7e75e31f6de61a6a52373f 100644 (file)
@@ -61,6 +61,7 @@ local default_options = {
   symbol_spam = 'NEURAL_SPAM',
   symbol_ham = 'NEURAL_HAM',
   max_inputs = nil, -- when PCA is used
+  blacklisted_symbols = {}, -- list of symbols skipped in neural processing
 }
 
 local redis_profile_schema = ts.shape{
@@ -1428,6 +1429,9 @@ local function process_rules_settings()
     end
 
     local function filter_symbols_predicate(sname)
+      if settings.blacklisted_symbols and settings.blacklisted_symbols[sname] then
+        return false
+      end
       local fl = rspamd_config:get_symbol_flags(sname)
       if fl then
         fl = lua_util.list_to_hash(fl)
@@ -1569,6 +1573,11 @@ local id = rspamd_config:register_symbol({
 settings = lua_util.override_defaults(settings, module_config)
 settings.rules = {} -- Reset unless validated further in the cycle
 
+if settings.blacklisted_symbols and settings.blacklisted_symbols[1] then
+  -- Transform to hash for simplicity
+  settings.blacklisted_symbols = lua_util.list_to_hash(settings.blacklisted_symbols)
+end
+
 -- Check all rules
 for k,r in pairs(rules) do
   local rule_elt = lua_util.override_defaults(default_options, r)