diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-17 12:22:39 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-17 12:22:39 +0000 |
commit | caf418acf6db08f8c259611ea8601835ddb84d32 (patch) | |
tree | 097a07c1bdc81072efc023f442963eadd38e7f64 /lualib | |
parent | b53a152e069882acca3127ac591fbe2f15c7911f (diff) | |
download | rspamd-caf418acf6db08f8c259611ea8601835ddb84d32.tar.gz rspamd-caf418acf6db08f8c259611ea8601835ddb84d32.zip |
[Fix] Fix enabling/disabling symbols
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_squeeze_rules.lua | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/lualib/lua_squeeze_rules.lua b/lualib/lua_squeeze_rules.lua index f43d7383a..9401d6fcc 100644 --- a/lualib/lua_squeeze_rules.lua +++ b/lualib/lua_squeeze_rules.lua @@ -239,7 +239,7 @@ exports.squeeze_init = function() if metric_sym then v.group = metric_sym.group v.score = metric_sym.score - v.description = description + v.description = metric_sym.description if not squeezed_groups[v.group] then logger.debugm(SN, rspamd_config, 'added squeezed group: %s', v.group) @@ -262,52 +262,59 @@ exports.handle_settings = function(task, settings) if settings.default then settings = settings.default end - if settings.symbols_enabled then - for k,v in squeezed_symbols do - if not settings.symbols_enabled[k] then + local function disable_all() + for k,_ in pairs(squeezed_symbols) do + if not symbols_enabled[k] then symbols_disabled[k] = true - found = true - else - symbols_enabled[k] = true + end + end + end + + if settings.symbols_enabled then + disable_all() + found = true + for _,s in ipairs(settings.symbols_enabled) do + if squeezed_symbols[s] then + logger.debugm(SN, task, 'enable symbol %s as it is in `symbols_enabled`', s) + symbols_enabled[s] = true + symbols_disabled[s] = nil end end end if settings.groups_enabled then - for k,syms in pairs(squeezed_groups) do - if not settings.groups_enabled[k] then - for _,sym in ipairs(syms) do - if not symbols_enabled[sym] then - symbols_disabled[sym] = true - found = true - end - end - else - for _,sym in ipairs(syms) do - if symbols_disabled[sym] then - symbols_disabled[sym] = nil - end + disable_all() + found = true + for _,gr in ipairs(settings.groups_enabled) do + if squeezed_groups[gr] then + for _,sym in ipairs(squeezed_groups[gr]) do + logger.debugm(SN, task, 'enable symbol %s as it is in `groups_enabled`', sym) symbols_enabled[sym] = true + symbols_disabled[sym] = nil end end end end if settings.symbols_disabled then - for k,v in squeezed_symbols do - if settings.symbols_disabled[k] then - symbols_disabled[k] = true - found = true + found = true + for _,s in ipairs(settings.symbols_disabled) do + if not symbols_enabled[s] then + symbols_disabled[s] = true + logger.debugm(SN, task, 'disable symbol %s as it is in `symbols_disabled`', s) end end end if settings.groups_disabled then - for k,syms in pairs(squeezed_groups) do - if settings.groups_disabled[k] then - for _,sym in ipairs(syms) do - symbols_disabled[sym] = true - found = true + found = true + for _,gr in ipairs(settings.groups_disabled) do + if squeezed_groups[gr] then + for _,sym in ipairs(squeezed_groups[gr]) do + if not symbols_enabled[sym] then + logger.debugm(SN, task, 'disable symbol %s as it is in `groups_disabled`', sym) + symbols_disabled[sym] = true + end end end end |