aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-24 07:23:46 -0800
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-24 07:23:46 -0800
commitfabf4f1dfc5686fbf8cb6f9578ae55c2d86c0bf7 (patch)
tree36ba19bb280cccf5666a28dbe07d1b07ba1f71f4
parent263a564e0b00510a9fc5962f1c9c310ab1816057 (diff)
parent35a4f68f3caeff979c1f7d167a0f8ab8aae33bab (diff)
downloadrspamd-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.lua18
-rw-r--r--conf/metrics.conf5
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";
+ }
}