diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-17 14:34:45 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-17 14:34:45 +0100 |
commit | 18af41ce00a593cb177b2401e573e4d0ef2747f2 (patch) | |
tree | 9ab032c097fa4e71835e98ef18ce4ca327010823 /rules/headers_checks.lua | |
parent | 811f87cfb831002144704a3091b683fbeb25d5ec (diff) | |
download | rspamd-18af41ce00a593cb177b2401e573e4d0ef2747f2.tar.gz rspamd-18af41ce00a593cb177b2401e573e4d0ef2747f2.zip |
[Rules] Improve MULTIPLE_UNIQUE_HEADERS rule
Diffstat (limited to 'rules/headers_checks.lua')
-rw-r--r-- | rules/headers_checks.lua | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua index e593d2097..0f578a448 100644 --- a/rules/headers_checks.lua +++ b/rules/headers_checks.lua @@ -217,7 +217,7 @@ local check_replyto_id = rspamd_config:register_callback_symbol('CHECK_REPLYTO', elseif from[1].domain and rt[1].domain then if (util.strequal_caseless(from[1].domain, rt[1].domain)) then task:insert_result('REPLYTO_DOM_EQ_FROM_DOM', 1.0) - else + else -- See if Reply-To matches the To address local to = task:get_recipients(2) if (to and to[1] and to[1].addr:lower() == rt[1].addr:lower()) then @@ -225,7 +225,7 @@ local check_replyto_id = rspamd_config:register_callback_symbol('CHECK_REPLYTO', if (not (task:get_header('List-Unsubscribe') or task:get_header('X-To-Get-Off-This-List') or task:get_header('X-List') or - task:get_header('Auto-Submitted'))) + task:get_header('Auto-Submitted'))) then task:insert_result('REPLYTO_EQ_TO_ADDR', 1.0) end @@ -504,44 +504,48 @@ rspamd_config.HEADER_FORGED_MDN = { } local headers_unique = { - 'Content-Type', - 'Content-Transfer-Encoding', + ['Content-Type'] = 1.0, + ['Content-Transfer-Encoding'] = 1.0, -- https://tools.ietf.org/html/rfc5322#section-3.6 - 'Date', - 'From', - 'Sender', - 'Reply-To', - 'To', - 'Cc', - 'Bcc', - 'Message-ID', - 'In-Reply-To', - 'References', - 'Subject' + ['Date'] = 1.0, + ['From'] = 1.0, + ['Sender'] = 1.0, + ['Reply-To'] = 1.0, + ['To'] = 0.2, + ['Cc'] = 0.1, + ['Bcc'] = 0.1, + ['Message-ID'] = 0.7, + ['In-Reply-To'] = 0.7, + ['References'] = 0.3, + ['Subject'] = 0.7 } rspamd_config.MULTIPLE_UNIQUE_HEADERS = { callback = function(task) local res = 0 + local max_mult = 0.0 local res_tbl = {} - for _,hdr in ipairs(headers_unique) do - local h = task:get_header_full(hdr) + for hdr,mult in pairs(headers_unique) do + local hc = task:get_header_count(hdr) - if h and #h > 1 then + if hc > 1 then res = res + 1 table.insert(res_tbl, hdr) + if max_mult < mult then + max_mult = mult + end end end if res > 0 then - return true,res,table.concat(res_tbl, ',') + return true,max_mult,table.concat(res_tbl, ',') end return false end, - score = 5.0, + score = 7.0, group = 'headers', one_shot = true, description = 'Repeated unique headers' |