diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-16 23:50:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-02-16 23:50:34 +0000 |
commit | be7c52baebbc5134d57ec775ff789cb5fb8ab5b5 (patch) | |
tree | 5bd2f9f61ee3c395095548e193afcd20e8d30765 /src/plugins/lua/spamassassin.lua | |
parent | 9b7bb8768771b4074621a20e1e13dc9955257c5f (diff) | |
download | rspamd-be7c52baebbc5134d57ec775ff789cb5fb8ab5b5.tar.gz rspamd-be7c52baebbc5134d57ec775ff789cb5fb8ab5b5.zip |
Allow to use SA header rules.
Diffstat (limited to 'src/plugins/lua/spamassassin.lua')
-rw-r--r-- | src/plugins/lua/spamassassin.lua | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index d62675af4..2cc59ff6e 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -111,6 +111,8 @@ local function process_sa_conf(f) if cur_rule['meta'] then valid_rule = true end elseif words[1] == "describe" and valid_rule then cur_rule['description'] = words_to_re(words, 1) + elseif words[1] == "score" and valid_rule then + cur_rule['score'] = tonumber(words_to_re(words, 1)[1]) end end)() end @@ -126,4 +128,41 @@ if type(section) == "table" then process_sa_conf(f) end end -end
\ No newline at end of file +end + +-- Now check all valid rules and add the according rspamd rules + +-- Meta rules +_.each(function(k, r) + rspamd_config:add_composite(k, r['meta']) + if r['score'] then + rspamd_config:set_metric_symbol(k, r['score'], r['description']) + end + end, + _.filter(function(k, r) + return r['type'] == 'meta' + end, + rules)) + +-- Header rules +_.each(function(k, r) + local f = function(task) + local hdr = task:get_header_full(r['header']) + if hdr then + for n, rh in ipairs(hdr) do + -- Subject for optimization + if (r['re']:match(rh['decoded'])) then + task:insert_result(k, 1.0) + 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'] == 'header' and r['header'] + end, + rules))
\ No newline at end of file |