summaryrefslogtreecommitdiffstats
path: root/lualib/lua_scanners
diff options
context:
space:
mode:
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>2021-01-07 18:45:45 +0100
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>2021-01-07 18:46:43 +0100
commit1f806591d6c9a40fa03bc436bb5472230b4731c9 (patch)
tree69578ef6064fb1a976a074da7ac1fe18ab52fdd9 /lualib/lua_scanners
parent13d60df725ae1943d2085fb2c66ca24154352b6d (diff)
downloadrspamd-1f806591d6c9a40fa03bc436bb5472230b4731c9.tar.gz
rspamd-1f806591d6c9a40fa03bc436bb5472230b4731c9.zip
[Minor] external_services - spamassassin - result matching
thx to Marc Dierksen
Diffstat (limited to 'lualib/lua_scanners')
-rw-r--r--lualib/lua_scanners/spamassassin.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/lualib/lua_scanners/spamassassin.lua b/lualib/lua_scanners/spamassassin.lua
index 715a5e322..d50b37483 100644
--- a/lualib/lua_scanners/spamassassin.lua
+++ b/lualib/lua_scanners/spamassassin.lua
@@ -161,16 +161,13 @@ local function spamassassin_check(task, content, digest, rule)
local symbols
local spam_score
for s in header:gmatch("[^\r\n]+") do
- if string.find(s, 'Spam: .* / 5.0') then
- local pattern_symbols = "(Spam:.*; )(%-?%d?%d%.%d)( / 5%.0)"
- spam_score = string.gsub(s, pattern_symbols, "%2")
- lua_util.debugm(rule.N, task, '%s: spamd Spam line: %s', rule.log_prefix, spam_score)
- end
- if string.find(s, 'X%-Spam%-Status') then
- local pattern_symbols = "(.*X%-Spam%-Status.*tests%=)(.*)(autolearn%=.*version%=%d%.%d%.%d.*)"
- symbols = string.gsub(s, pattern_symbols, "%2")
- symbols = string.gsub(symbols, "%s", "")
- end
+ if string.find(s, 'X%-Spam%-Status: %S+, score') then
+ local pattern_symbols = "X%-Spam%-Status: %S+, score%=(%d+%.%d+) .* tests=(.*,)( +%S+).*"
+ spam_score = string.gsub(s, pattern_symbols, "%1")
+ lua_util.debugm(rule.N, task, '%s: spamd Spam line: %s', rule.log_prefix, spam_score)
+ symbols = string.gsub(s, pattern_symbols, "%2%3")
+ symbols = string.gsub(symbols, "%s", "")
+ end
end
if tonumber(spam_score) > 0 and #symbols > 0 and symbols ~= "none" then
@@ -187,6 +184,7 @@ local function spamassassin_check(task, content, digest, rule)
common.save_cache(task, digest, rule, symbols_table, spam_score)
end
else
+ common.save_cache(task, digest, rule, 'OK')
common.log_clean(task, rule, 'no spam detected - spam score: ' .. spam_score .. ', symbols: ' .. symbols)
end
end