diff options
author | Thomas Oettli <spacefreak@noop.ch> | 2019-05-03 11:37:16 +0200 |
---|---|---|
committer | Thomas Oettli <spacefreak@noop.ch> | 2019-05-03 11:37:16 +0200 |
commit | 3d0df547e0de6cbac769512551be9703a798a790 (patch) | |
tree | d545f6cdddd322c17e1306f13482e886d2a6a0cd /lualib/lua_scanners | |
parent | 0917da51251df2566c1ad722b2727dfaa2969711 (diff) | |
download | rspamd-3d0df547e0de6cbac769512551be9703a798a790.tar.gz rspamd-3d0df547e0de6cbac769512551be9703a798a790.zip |
[Major] lua_scanners - fix dynamic scan
Diffstat (limited to 'lualib/lua_scanners')
-rw-r--r-- | lualib/lua_scanners/common.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua index f35ee372d..65dd4aef8 100644 --- a/lualib/lua_scanners/common.lua +++ b/lualib/lua_scanners/common.lua @@ -339,6 +339,27 @@ local function check_parts_match(task, rule) return fun.filter(filter_func, task:get_parts()) end +local function check_metric_results(task, rule) + + if rule.action ~= 'reject' then + local metric_result = task:get_metric_score('default') + local metric_action = task:get_metric_action('default') + local has_pre_result = task:has_pre_result() + + if rule.symbol_type == 'postfilter' and metric_action == 'reject' then + return true, 'result is already reject' + elseif metric_result[1] > metric_result[2]*2 then + return true, 'score > 2 * reject_level: ' .. metric_result[1] + elseif has_pre_result and metric_action == 'reject' then + return true, 'pre_result reject is set' + else + return false, 'undecided' + end + else + return false, 'dynamic_scan is not possible with config `action=reject;`' + end +end + exports.log_clean = log_clean exports.yield_result = yield_result exports.match_patterns = match_patterns @@ -347,6 +368,7 @@ exports.check_av_cache = check_av_cache exports.save_av_cache = save_av_cache exports.create_regex_table = create_regex_table exports.check_parts_match = check_parts_match +exports.check_metric_results = check_metric_results setmetatable(exports, { __call = function(t, override) |