]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Use sabody rules in SA plugin
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 16:07:37 +0000 (17:07 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Apr 2016 16:07:37 +0000 (17:07 +0100)
src/plugins/lua/spamassassin.lua

index a73b56d062b00f4b005441268098cf2c7b1225b5..665fe6f178d8bb175ced9fd9fe92af26bc932444 100644 (file)
@@ -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)