diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-18 14:36:47 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-18 14:36:47 +0100 |
commit | 57f72e3540397ee0801abd4aabd14ef9a5cc5424 (patch) | |
tree | 39c6182e17dac38fb3f926f8c4bacc9563676bf8 | |
parent | 4a5f7b6caecf1cc1f1911018610953e68733e139 (diff) | |
download | rspamd-57f72e3540397ee0801abd4aabd14ef9a5cc5424.tar.gz rspamd-57f72e3540397ee0801abd4aabd14ef9a5cc5424.zip |
[Minor] Fix phishing maps logic
-rw-r--r-- | src/plugins/lua/phishing.lua | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua index 69aec219f..3f81cd036 100644 --- a/src/plugins/lua/phishing.lua +++ b/src/plugins/lua/phishing.lua @@ -228,27 +228,40 @@ local function phishing_map(mapname, phishmap, id) else xd[1] = opts[mapname] end + + local found_maps = {} + for _,d in ipairs(xd) do local s = string.find(d, ':[^:]+$') if s then local sym = string.sub(d, s + 1, -1) local map = string.sub(d, 1, s - 1) - rspamd_config:register_virtual_symbol(sym, 1, id) - local rmap = rspamd_config:add_map ({ - type = 'set', - url = map, - description = 'Phishing ' .. mapname .. ' map', - }) - if rmap then - local rule = {symbol = sym, map = rmap} - table.insert(phishmap, rule) + + if found_maps[sym] then + table.insert(found_maps[sym], map) else - rspamd_logger.infox(rspamd_config, 'cannot add map: ' .. map .. ' for symbol: ' .. sym) + found_maps[sym] = {map} end else rspamd_logger.infox(rspamd_config, mapname .. ' option must be in format <map>:<symbol>') end end + + for sym,urls in pairs(found_maps) do + local rmap = rspamd_config:add_map ({ + type = 'set', + url = urls, + description = 'Phishing ' .. mapname .. ' map', + }) + if rmap then + rspamd_config:register_virtual_symbol(sym, 1, id) + local rule = {symbol = sym, map = rmap} + table.insert(phishmap, rule) + else + rspamd_logger.infox(rspamd_config, 'cannot add map: %s for symbol: %s', + table.concat(urls, ";"), sym) + end + end end end |