commit 58ed3fa: [Fix] Fix allowed_settings for neural
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Feb 25 13:07:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-02-25 13:02:40 +0000
URL: https://github.com/rspamd/rspamd/commit/58ed3fae4fe7c3c972e801698a0e8f1c615213ce (HEAD -> master)
[Fix] Fix allowed_settings for neural
Issue: #3270
---
lualib/lua_settings.lua | 2 ++
src/plugins/lua/neural.lua | 14 +++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lualib/lua_settings.lua b/lualib/lua_settings.lua
index 61cc9d2ad..bb0ea0457 100644
--- a/lualib/lua_settings.lua
+++ b/lualib/lua_settings.lua
@@ -170,6 +170,8 @@ local function numeric_settings_id(str)
return ret
end
+exports.numeric_settings_id = numeric_settings_id
+
-- Used to do the following:
-- If there is a group of symbols_allowed, it checks if that is an array
-- If that is a hash table then we transform it to a normal list, probably adding symbols to adjust scores
diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua
index 12dadd8d6..da569e698 100644
--- a/src/plugins/lua/neural.lua
+++ b/src/plugins/lua/neural.lua
@@ -1293,7 +1293,11 @@ local function process_rules_settings()
-- We set table rule.settings[id] -> { name = name, symbols = symbols, digest = digest }
for s,_ in pairs(rule.allowed_settings) do
-- Here, we have a name, set of symbols and
- local selt = lua_settings.settings_by_id(s)
+ local settings_id = s
+ if type(settings_id) ~= 'number' then
+ settings_id = lua_settings.numeric_settings_id(s)
+ end
+ local selt = lua_settings.settings_by_id(settings_id)
local nelt = {
symbols = selt.symbols, -- Already sorted
@@ -1308,16 +1312,16 @@ local function process_rules_settings()
lua_util.debugm(N, rspamd_config,
'added reference from settings id %s to %s; same symbols',
nelt.name, ex.name)
- rule.settings[s] = id
+ rule.settings[settings_id] = id
nelt = nil
end
end
end
if nelt then
- rule.settings[s] = nelt
- lua_util.debugm(N, rspamd_config, 'added new settings id %s to %s',
- nelt.name, rule.prefix)
+ rule.settings[settings_id] = nelt
+ lua_util.debugm(N, rspamd_config, 'added new settings id %s(%s) to %s',
+ nelt.name, settings_id, rule.prefix)
end
end
end
More information about the Commits
mailing list