summaryrefslogtreecommitdiffstats
path: root/lualib/lua_scanners/common.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-01-18 15:10:12 +0000
committerGitHub <noreply@github.com>2019-01-18 15:10:12 +0000
commit3203d0f4422fdab18a03abf7fc713c562f15f70e (patch)
tree514c692f2195bdc9fc23ff5aa0795a133312bd29 /lualib/lua_scanners/common.lua
parentc361d5a35f5e64d3ea429f6358cdc078c29a15c8 (diff)
parent4d152f93625f6a9249bb2f9a4e1c5e19227f7029 (diff)
downloadrspamd-3203d0f4422fdab18a03abf7fc713c562f15f70e.tar.gz
rspamd-3203d0f4422fdab18a03abf7fc713c562f15f70e.zip
Merge pull request #2718 from HeinleinSupport/symbol_fail
[Minor] lua_scanners - use pattern for FAIL symbol
Diffstat (limited to 'lualib/lua_scanners/common.lua')
-rw-r--r--lualib/lua_scanners/common.lua24
1 files changed, 19 insertions, 5 deletions
diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua
index cda656849..de5f77db9 100644
--- a/lualib/lua_scanners/common.lua
+++ b/lualib/lua_scanners/common.lua
@@ -61,13 +61,27 @@ local function match_patterns(default_sym, found, patterns, dyn_weight)
end
end
-local function yield_result(task, rule, vname, dyn_weight)
+local function yield_result(task, rule, vname, dyn_weight, is_fail)
local all_whitelisted = true
- if not dyn_weight then dyn_weight = 1.0 end
+ local patterns
+ local symbol
+
+ if not is_fail then
+ patterns = rule.patterns
+ symbol = rule.symbol
+ if not dyn_weight then dyn_weight = 1.0 end
+ lua_util.debugm(rule.name, task, '%s: no fail: %s',rule.log_prefix, symbol)
+ elseif is_fail == 'fail' then
+ patterns = rule.patterns_fail
+ symbol = rule.symbol_fail
+ dyn_weight = 0.0
+ lua_util.debugm(rule.name, task, '%s: FAIL: %s',rule.log_prefix, symbol)
+ end
+
if type(vname) == 'string' then
- local symname, symscore = match_patterns(rule.symbol,
+ local symname, symscore = match_patterns(symbol,
vname,
- rule.patterns,
+ patterns,
dyn_weight)
if rule.whitelist and rule.whitelist:get_key(vname) then
rspamd_logger.infox(task, '%s: "%s" is in whitelist', rule.log_prefix, vname)
@@ -78,7 +92,7 @@ local function yield_result(task, rule, vname, dyn_weight)
rule.log_prefix, rule.detection_category, vname, symscore)
elseif type(vname) == 'table' then
for _, vn in ipairs(vname) do
- local symname, symscore = match_patterns(rule.symbol, vn, rule.patterns, dyn_weight)
+ local symname, symscore = match_patterns(symbol, vn, patterns, dyn_weight)
if rule.whitelist and rule.whitelist:get_key(vn) then
rspamd_logger.infox(task, '%s: "%s" is in whitelist', rule.log_prefix, vn)
else