From f8e3626052253bb7520feda4f53c0f3c6f1141c9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Apr 2016 17:07:37 +0100 Subject: [PATCH] [Feature] Use sabody rules in SA plugin --- src/plugins/lua/spamassassin.lua | 32 +++++++++++++++++++++++++++++--- 1 file 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) -- 2.39.5