diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-12-24 07:23:46 -0800 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2013-12-24 07:23:46 -0800 |
commit | fabf4f1dfc5686fbf8cb6f9578ae55c2d86c0bf7 (patch) | |
tree | 36ba19bb280cccf5666a28dbe07d1b07ba1f71f4 | |
parent | 263a564e0b00510a9fc5962f1c9c310ab1816057 (diff) | |
parent | 35a4f68f3caeff979c1f7d167a0f8ab8aae33bab (diff) | |
download | rspamd-fabf4f1dfc5686fbf8cb6f9578ae55c2d86c0bf7.tar.gz rspamd-fabf4f1dfc5686fbf8cb6f9578ae55c2d86c0bf7.zip |
Merge pull request #14 from AlexeySa/master
Add rule for HELO host FQDN check
-rw-r--r-- | conf/lua/rspamd.lua | 18 | ||||
-rw-r--r-- | conf/metrics.conf | 5 |
2 files changed, 23 insertions, 0 deletions
diff --git a/conf/lua/rspamd.lua b/conf/lua/rspamd.lua index 822f6447f..16b99cb01 100644 --- a/conf/lua/rspamd.lua +++ b/conf/lua/rspamd.lua @@ -68,6 +68,24 @@ reconf['DATE_IN_PAST'] = function(task) return false end +reconf['HELO_NOT_FQDN'] = function(task) +local helo = task:get_helo() + +local function check_regexp(str, regexp_text) + local re = regexp.get_cached(regexp_text) + if not re then re = regexp.create(regexp_text, 'i') end + if re:match(str) then return true end + return false +end + +if helo then + if not check_regexp(helo, '(?=^.{4,255}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+[a-zA-Z]{2,63}$)') then + return true + end +end + +return false +end local function file_exists(filename) local file = io.open(filename) diff --git a/conf/metrics.conf b/conf/metrics.conf index 79ec73428..498defa40 100644 --- a/conf/metrics.conf +++ b/conf/metrics.conf @@ -702,4 +702,9 @@ metric { description = "Message date is in past"; name = "DATE_IN_PAST"; } + symbol { + weight = 1.5; + description = "Helo host FQDN check"; + name = "HELO_NOT_FQDN"; + } } |