summaryrefslogtreecommitdiffstats
path: root/rules
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-25 13:44:16 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-25 13:44:16 +0100
commit07f4054d92da116c8ac4ac8d7456706c319c5b38 (patch)
tree160fbfac454f45d2b2ba80e9bf422c2680d783bb /rules
parent0e0b964d002f8029aa274408ef12d5870b61339f (diff)
downloadrspamd-07f4054d92da116c8ac4ac8d7456706c319c5b38.tar.gz
rspamd-07f4054d92da116c8ac4ac8d7456706c319c5b38.zip
[Feature] Add rules to detect bad 8bit characters in From and To
Diffstat (limited to 'rules')
-rw-r--r--rules/headers_checks.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua
index 28409f276..ebe3e0aa0 100644
--- a/rules/headers_checks.lua
+++ b/rules/headers_checks.lua
@@ -918,3 +918,39 @@ rspamd_config.CTYPE_MIXED_BOGUS = {
score = 0.1,
group = 'headers'
}
+
+local function is_8bit_addr(addr)
+ if addr.flags and addr.flags['8bit'] then
+ return true
+ end
+
+ return false;
+end
+
+rspamd_config.INVALID_FROM_8BIT = {
+ callback = function(task)
+ local from = (task:get_from('mime') or {})[1] or {}
+ if is_8bit_addr(from) then
+ return true
+ end
+ return false
+ end,
+ description = 'Invalid 8bit character in From header',
+ score = 6.0,
+ group = 'headers'
+}
+
+rspamd_config.INVALID_RCPT_8BIT = {
+ callback = function(task)
+ local rcpts = task:get_recipients('mime') or {}
+ return fun.any(function(rcpt)
+ if is_8bit_addr(rcpt) then
+ return true
+ end
+ return false
+ end, rcpts)
+ end,
+ description = 'Invalid 8bit character in recipients headers',
+ score = 6.0,
+ group = 'headers'
+} \ No newline at end of file