浏览代码

[Feature] Add INVALID_DATE rule

The symbol indicates that a date in Date: header has invalid format and
cannot be parsed by Rspamd.
tags/2.7
Anton Yuzhaninov 3 年前
父节点
当前提交
ee429ed737
共有 1 个文件被更改,包括 21 次插入7 次删除
  1. 21
    7
      rules/misc.lua

+ 21
- 7
rules/misc.lua 查看文件

@@ -65,16 +65,21 @@ local date_id = rspamd_config:register_symbol({
return
end

local dm = task:get_date({format = 'message', gmt = true})
local dm, err = util.parse_smtp_date(date_time)
if err then
task:insert_result('INVALID_DATE', 1.0)
return
end

local dt = task:get_date({format = 'connect', gmt = true})
local date_diff = dt - dm

if dm > 0 and dm - dt > 7200 then
-- 2 hours
task:insert_result('DATE_IN_FUTURE', 1.0)
return
elseif dm > 0 and dt - dm > 86400 then
-- A day
if date_diff > 86400 then
-- Older than a day
task:insert_result('DATE_IN_PAST', 1.0)
elseif -date_diff > 7200 then
-- More than 2 hours in the future
task:insert_result('DATE_IN_FUTURE', 1.0)
end
end
})
@@ -88,6 +93,15 @@ rspamd_config:register_symbol({
parent = date_id,
})

rspamd_config:register_symbol({
name = 'INVALID_DATE',
score = 1.5,
description = 'Malformed date header',
group = 'headers',
type = 'virtual',
parent = date_id,
})

rspamd_config:register_symbol({
name = 'DATE_IN_FUTURE',
score = 4.0,

正在加载...
取消
保存