diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-15 00:22:19 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-15 00:22:19 +0100 |
commit | c9ed268e926a7d88aa3a7713909ece88e3137d38 (patch) | |
tree | 359cd5754bc14c79f632db9ef507035a934d3128 /conf | |
parent | f999cd8e8b6689ea73ba1b6d9a54ae63dde1aa86 (diff) | |
download | rspamd-c9ed268e926a7d88aa3a7713909ece88e3137d38.tar.gz rspamd-c9ed268e926a7d88aa3a7713909ece88e3137d38.zip |
Rework R_PARTS_DIFFER rule.
Diffstat (limited to 'conf')
-rw-r--r-- | conf/lua/rspamd.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/conf/lua/rspamd.lua b/conf/lua/rspamd.lua index 245f6ce6a..b4de3835d 100644 --- a/conf/lua/rspamd.lua +++ b/conf/lua/rspamd.lua @@ -34,6 +34,7 @@ dofile('regexp/fraud.lua') dofile('regexp/drugs.lua') local reconf = config['regexp'] +local util = require "rspamd_util" -- Uncategorized rules @@ -48,7 +49,22 @@ reconf['R_WHITE_ON_WHITE'] = string.format('(!(%s) & (%s))', r_bgcolor, r_font_c reconf['R_FLASH_REDIR_IMGSHACK'] = '/^(?:http:\\/\\/)?img\\d{1,5}\\.imageshack\\.us\\/\\S+\\.swf/U' -- Different text parts -reconf['R_PARTS_DIFFER'] = 'compare_parts_distance(50)'; +reconf['R_PARTS_DIFFER'] = function(task) + local distance = task:get_mempool():get_variable('parts_distance', 'int') + + if distance then + print(distance) + local nd = tonumber(distance) + + if nd < 50 then + local score = 1 - util.tanh(nd / 100.0) + + task:insert_result('R_PARTS_DIFFER', score, tostring(nd) .. '%') + end + end + + return false +end rspamd_config.R_EMPTY_IMAGE = function (task) parts = task:get_text_parts() |