aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_maps_expressions.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-18 14:36:32 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-05-18 14:36:32 +0100
commit79cf1be1c86e3550394d3c0fb39182e6e4b57bd8 (patch)
tree6f75ad47a00b6789b155e6db07ee26a83aa23ab1 /lualib/lua_maps_expressions.lua
parent77e594517c2966657efc7f9cf47e07062f0d47eb (diff)
downloadrspamd-79cf1be1c86e3550394d3c0fb39182e6e4b57bd8.tar.gz
rspamd-79cf1be1c86e3550394d3c0fb39182e6e4b57bd8.zip
[Minor] Add symbols and type heuristic
Diffstat (limited to 'lualib/lua_maps_expressions.lua')
-rw-r--r--lualib/lua_maps_expressions.lua22
1 files changed, 21 insertions, 1 deletions
diff --git a/lualib/lua_maps_expressions.lua b/lualib/lua_maps_expressions.lua
index 38cd0f296..f0b1f176a 100644
--- a/lualib/lua_maps_expressions.lua
+++ b/lualib/lua_maps_expressions.lua
@@ -129,7 +129,19 @@ local function create(cfg, obj, module_name)
name, module_name)
end
- local map = lua_maps.map_add_from_ucl(rule.map, rule.type or 'set',
+ if not rule.type then
+ -- Guess type
+ if name:find('ip') or name:find('ipnet') then
+ rule.type = 'radix'
+ elseif name:find('regexp') or name:find('re_') then
+ rule.type = 'regexp'
+ elseif name:find('glob') then
+ rule.type = 'regexp'
+ else
+ rule.type = 'set'
+ end
+ end
+ local map = lua_maps.map_add_from_ucl(rule.map, rule.type,
obj.description or module_name)
if not map then
rspamd_logger.errx(cfg, 'cannot add map for element %s in module %s',
@@ -174,6 +186,14 @@ local function create(cfg, obj, module_name)
ret.expr = expr
+ if obj.symbol then
+ rspamd_config:register_symbol{
+ type = 'virtual,ghost',
+ name = obj.symbol,
+ score = 0.0,
+ }
+ end
+
return ret
end