浏览代码

[Rules] Improve MULTIPLE_UNIQUE_HEADERS rule

tags/1.7.9
Vsevolod Stakhov 6 年前
父节点
当前提交
18af41ce00
共有 1 个文件被更改,包括 24 次插入20 次删除
  1. 24
    20
      rules/headers_checks.lua

+ 24
- 20
rules/headers_checks.lua 查看文件

elseif from[1].domain and rt[1].domain then elseif from[1].domain and rt[1].domain then
if (util.strequal_caseless(from[1].domain, 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) task:insert_result('REPLYTO_DOM_EQ_FROM_DOM', 1.0)
else
else
-- See if Reply-To matches the To address -- See if Reply-To matches the To address
local to = task:get_recipients(2) local to = task:get_recipients(2)
if (to and to[1] and to[1].addr:lower() == rt[1].addr:lower()) then if (to and to[1] and to[1].addr:lower() == rt[1].addr:lower()) then
if (not (task:get_header('List-Unsubscribe') or if (not (task:get_header('List-Unsubscribe') or
task:get_header('X-To-Get-Off-This-List') or task:get_header('X-To-Get-Off-This-List') or
task:get_header('X-List') or task:get_header('X-List') or
task:get_header('Auto-Submitted')))
task:get_header('Auto-Submitted')))
then then
task:insert_result('REPLYTO_EQ_TO_ADDR', 1.0) task:insert_result('REPLYTO_EQ_TO_ADDR', 1.0)
end end
} }


local headers_unique = { 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 -- 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 = { rspamd_config.MULTIPLE_UNIQUE_HEADERS = {
callback = function(task) callback = function(task)
local res = 0 local res = 0
local max_mult = 0.0
local res_tbl = {} 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 res = res + 1
table.insert(res_tbl, hdr) table.insert(res_tbl, hdr)
if max_mult < mult then
max_mult = mult
end
end end
end end


if res > 0 then if res > 0 then
return true,res,table.concat(res_tbl, ',')
return true,max_mult,table.concat(res_tbl, ',')
end end


return false return false
end, end,


score = 5.0,
score = 7.0,
group = 'headers', group = 'headers',
one_shot = true, one_shot = true,
description = 'Repeated unique headers' description = 'Repeated unique headers'

正在加载...
取消
保存