From: Vsevolod Stakhov Date: Mon, 16 Feb 2015 23:57:39 +0000 (+0000) Subject: Add other rules types. X-Git-Tag: 0.9.0~684 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=601bcf0e76ffd31291f21d99e7f8d4ca969b0791;p=thirdparty%2Frspamd.git Add other rules types. --- diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 2cc59ff6ef..03387255b8 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -153,6 +153,7 @@ _.each(function(k, r) -- Subject for optimization if (r['re']:match(rh['decoded'])) then task:insert_result(k, 1.0) + return end end end @@ -165,4 +166,46 @@ _.each(function(k, r) _.filter(function(k, r) return r['type'] == 'header' and r['header'] end, + rules)) + +-- Parts rules +_.each(function(k, r) + local f = function(task) + local parts = task:get_parts() + if parts then + for n, part in ipairs(parts) do + -- Subject for optimization + if (r['re']:match(part:get_content())) then + task:insert_result(k, 1.0) + return + end + end + end + end + rspamd_config:register_symbol(k, 1.0, f) + if r['score'] then + rspamd_config:set_metric_symbol(k, r['score'], r['description']) + end + end, + _.filter(function(k, r) + return r['type'] == 'part' + end, + rules)) + +-- Raw body rules +_.each(function(k, r) + local f = function(task) + if (r['re']:match(task:get_content())) then + task:insert_result(k, 1.0) + return + end + end + rspamd_config:register_symbol(k, 1.0, f) + if r['score'] then + rspamd_config:set_metric_symbol(k, r['score'], r['description']) + end + end, + _.filter(function(k, r) + return r['type'] == 'message' + end, rules)) \ No newline at end of file