summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-22 21:06:14 +0000
committerGitHub <noreply@github.com>2017-03-22 21:06:14 +0000
commitbb68a7983c2b17b9acf7ff01e4ba21adbd600845 (patch)
tree75860fa49624dabe934b6057115cab4209c49970
parent9ecc8401b608b7ee577cccd48f353bb486a7f598 (diff)
parenta0a1ae6b50f073a1ec4757676a2d963776e9772d (diff)
downloadrspamd-bb68a7983c2b17b9acf7ff01e4ba21adbd600845.tar.gz
rspamd-bb68a7983c2b17b9acf7ff01e4ba21adbd600845.zip
Merge pull request #1548 from fatalbanana/srt
[Minor] Use SMTP recipients for SPOOF_REPLYTO rule
-rw-r--r--rules/misc.lua30
1 files changed, 17 insertions, 13 deletions
diff --git a/rules/misc.lua b/rules/misc.lua
index 6dded7ef0..78acdf910 100644
--- a/rules/misc.lua
+++ b/rules/misc.lua
@@ -16,6 +16,7 @@ limitations under the License.
-- This is main lua config file for rspamd
+local E = {}
local fun = require "fun"
local util = require "rspamd_util"
local rspamd_regexp = require "rspamd_regexp"
@@ -436,22 +437,25 @@ rspamd_config.SPOOF_REPLYTO = {
-- First check for a Reply-To header
local rt = task:get_header('Reply-To')
if not rt then return false end
- -- Get From header
- local from = task:get_from(2)
- if not (from and from[1] and from[1]['domain']) then return false end
- -- Get To header
- local to = task:get_recipients(2)
- if not (to and to[1] and to[1]['domain']) then return false end
- -- From and To domains must be matching
- if not util.strequal_caseless(from[1]['domain'], to[1]['domain']) then
- return false
+ -- Get From header domain
+ local fromdom = ((task:get_from(2) or E)[1] or E).domain
+ if not fromdom then return false end
+ -- SMTP recipients must contain From domain
+ local to = task:get_recipients(1)
+ local found_fromdom = false
+ for _, t in ipairs(to) do
+ if util.strequal_caseless(t.domain, fromdom) then
+ found_fromdom = true
+ break
+ end
end
+ if not found_fromdom then return false end
-- Parse Reply-To header
- local parsed = util.parse_mail_address(rt)
- if not (parsed and parsed[1] and parsed[1]['domain']) then return false end
+ local parsed = ((util.parse_mail_address(rt) or E)[1] or E).domain
+ if not parsed then return false end
-- Reply-To domain must be different to From domain
- if not util.strequal_caseless(parsed[1]['domain'], from[1]['domain']) then
- return true, from[1]['domain'], parsed[1]['domain']
+ if not util.strequal_caseless(parsed, fromdom) then
+ return true, fromdom, parsed
end
return false
end,