summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-25 21:48:07 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-25 21:48:07 +0000
commit5aa8400c1fddc761a333b333c72ad00e108702c2 (patch)
tree8b237a1092f01572c1e60aee055981e923866251 /src/plugins
parent9ceb76c5b7de9113836fb62e6b6cbc4faa7e2c82 (diff)
downloadrspamd-5aa8400c1fddc761a333b333c72ad00e108702c2.tar.gz
rspamd-5aa8400c1fddc761a333b333c72ad00e108702c2.zip
Add support for 'full' and 'uri' rules.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/spamassassin.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index f9b39af29..8aad56618 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -182,7 +182,7 @@ local function process_sa_conf(f)
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
if cur_rule['re'] then valid_rule = true end
- elseif words[1] == "rawbody" and slash then
+ elseif words[1] == "rawbody" or words[1] == "full" and slash then
-- body SYMBOL /regexp/
if valid_rule then
insert_cur_rule()
@@ -192,6 +192,16 @@ local function process_sa_conf(f)
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
if cur_rule['re'] then valid_rule = true end
+ elseif words[1] == "uri" then
+ -- uri SYMBOL /regexp/
+ if valid_rule then
+ insert_cur_rule()
+ end
+ cur_rule['type'] = 'uri'
+ cur_rule['symbol'] = words[2]
+ cur_rule['re_expr'] = words_to_re(words, 2)
+ cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
+ if cur_rule['re'] then valid_rule = true end
elseif words[1] == "meta" then
-- meta SYMBOL expression
if valid_rule then
@@ -334,6 +344,27 @@ _.each(function(k, r)
return r['type'] == 'message'
end,
rules))
+-- URL rules
+_.each(function(k, r)
+ local f = function(task)
+ local urls = task:get_urls()
+ for _,u in ipairs(urls) do
+ if (r['re']:match(u:get_text())) then
+ return 1
+ end
+ end
+ return 0
+ end
+ if r['score'] then
+ rspamd_config:set_metric_symbol(k, r['score'], r['description'])
+ end
+ --rspamd_config:register_symbol(k, calculate_score(k), f)
+ atoms[k] = f
+ end,
+ _.filter(function(k, r)
+ return r['type'] == 'uri'
+ end,
+ rules))
local sa_mempool = rspamd_mempool.create()
@@ -354,7 +385,7 @@ local function process_atom(atom, task)
if atom_cb then
return atom_cb(task)
else
- --rspamd_logger.err('Cannot find atom ' .. atom)
+ rspamd_logger.err('Cannot find atom ' .. atom)
end
return 0
end