summaryrefslogtreecommitdiffstats
path: root/lualib/lua_squeeze_rules.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-15 12:44:46 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-15 12:44:46 +0100
commit90dca8a51be79ea3b8704afafb2cd75b2d65e31f (patch)
tree1a384bd7173201e817af09ca377bfda4f56e3b70 /lualib/lua_squeeze_rules.lua
parent7f5ca7ae3db6da0939e42ae88db375aa9b63fe76 (diff)
downloadrspamd-90dca8a51be79ea3b8704afafb2cd75b2d65e31f.tar.gz
rspamd-90dca8a51be79ea3b8704afafb2cd75b2d65e31f.zip
[Feature] Be more error-prone in squeezed rules
Diffstat (limited to 'lualib/lua_squeeze_rules.lua')
-rw-r--r--lualib/lua_squeeze_rules.lua68
1 files changed, 38 insertions, 30 deletions
diff --git a/lualib/lua_squeeze_rules.lua b/lualib/lua_squeeze_rules.lua
index 4309e1f97..a6e420fbd 100644
--- a/lualib/lua_squeeze_rules.lua
+++ b/lualib/lua_squeeze_rules.lua
@@ -32,51 +32,59 @@ local function gen_lua_squeeze_function(order)
local symbols_disabled = task:cache_get('squeezed_disable')
for _,data in ipairs(squeezed_rules[order]) do
if not symbols_disabled or not symbols_disabled[data[2]] then
- local ret = {data[1](task)}
-
- if #ret ~= 0 then
- local first = ret[1]
- local sym = data[2]
- -- Function has returned something, so it is rule, not a plugin
- if type(first) == 'boolean' then
- if first then
- table.remove(ret, 1)
+ local function real_call()
+ return {data[1](task)}
+ end
- local second = ret[1]
+ local status, ret = pcall(real_call)
- if type(second) == 'number' then
+ if not status then
+ logger.errx(task, 'error in squeezed rule %s: %s', data[2], ret)
+ else
+ if #ret ~= 0 then
+ local first = ret[1]
+ local sym = data[2]
+ -- Function has returned something, so it is rule, not a plugin
+ if type(first) == 'boolean' then
+ if first then
table.remove(ret, 1)
- if second ~= 0 then
+
+ local second = ret[1]
+
+ if type(second) == 'number' then
+ table.remove(ret, 1)
+ if second ~= 0 then
+ if type(ret[1]) == 'table' then
+ task:insert_result(sym, second, ret[1])
+ else
+ task:insert_result(sym, second, ret)
+ end
+ end
+ else
if type(ret[1]) == 'table' then
- task:insert_result(sym, second, ret[1])
+ task:insert_result(sym, 1.0, ret[1])
else
- task:insert_result(sym, second, ret)
+ task:insert_result(sym, 1.0, ret)
end
end
- else
+ end
+ elseif type(first) == 'number' then
+ table.remove(ret, 1)
+
+ if first ~= 0 then
if type(ret[1]) == 'table' then
- task:insert_result(sym, 1.0, ret[1])
+ task:insert_result(sym, first, ret[1])
else
- task:insert_result(sym, 1.0, ret)
+ task:insert_result(sym, first, ret)
end
end
- end
- elseif type(first) == 'number' then
- table.remove(ret, 1)
-
- if first ~= 0 then
+ else
if type(ret[1]) == 'table' then
- task:insert_result(sym, first, ret[1])
+ task:insert_result(sym, 1.0, ret[1])
else
- task:insert_result(sym, first, ret)
+ task:insert_result(sym, 1.0, ret)
end
end
- else
- if type(ret[1]) == 'table' then
- task:insert_result(sym, 1.0, ret[1])
- else
- task:insert_result(sym, 1.0, ret)
- end
end
end
else