aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 17:07:37 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-11 17:07:37 +0100
commitf8e3626052253bb7520feda4f53c0f3c6f1141c9 (patch)
tree9faf040b3c0978b3e6501863e200452e20a850e0 /src/plugins
parent50c4744037b66bef99f7e3465718e40b17a6bc09 (diff)
downloadrspamd-f8e3626052253bb7520feda4f53c0f3c6f1141c9.tar.gz
rspamd-f8e3626052253bb7520feda4f53c0f3c6f1141c9.zip
[Feature] Use sabody rules in SA plugin
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/spamassassin.lua32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index a73b56d06..665fe6f17 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -806,15 +806,14 @@ local function process_sa_conf(f)
cur_rule['symbol'] = words[2]
if words[3] and (string.sub(words[3], 1, 1) == '/'
or string.sub(words[3], 1, 1) == 'm') then
- cur_rule['type'] = 'part'
+ cur_rule['type'] = 'sabody'
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create(cur_rule['re_expr'])
- cur_rule['raw'] = true
if cur_rule['re'] then
rspamd_config:register_regexp({
re = cur_rule['re'],
- type = 'rawmime',
+ type = 'sabody',
pcre_only = is_pcre_only(cur_rule['symbol']),
})
valid_rule = true
@@ -1323,7 +1322,34 @@ local function post_process()
return r['type'] == 'part'
end,
rules))
+ -- SA body rules
+ _.each(function(k, r)
+ local f = function(task)
+ if not r['re'] then
+ rspamd_logger.errx(task, 're is missing for rule %s', k)
+ return 0
+ end
+ local t = 'sabody'
+ local ret = task:process_regexp({
+ re = r['re'],
+ type = t,
+ })
+ return ret
+ end
+ if r['score'] then
+ local real_score = r['score'] * calculate_score(k, r)
+ if math.abs(real_score) > meta_score_alpha then
+ add_sole_meta(k, r)
+ end
+ end
+ --rspamd_config:register_symbol(k, calculate_score(k), f)
+ atoms[k] = f
+ end,
+ _.filter(function(k, r)
+ return r['type'] == 'sabody'
+ end,
+ rules))
-- Raw body rules
_.each(function(k, r)
local f = function(task)