From 2116d177cd6da39c29c46338c090106b9aea3b22 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 4 Oct 2020 20:24:28 +0100 Subject: [PATCH] [Minor] Neural: Allow to blacklist specific symbols --- src/plugins/lua/neural.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua index eda089abc..124877927 100644 --- a/src/plugins/lua/neural.lua +++ b/src/plugins/lua/neural.lua @@ -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) -- 2.39.5