}
-- Date issues
-rspamd_config.MISSING_DATE = {
+local date_id = rspamd_config:register_symbol({
+ name = 'DATE_CB',
+ type = 'callback,mime',
callback = function(task)
- local date = task:get_header_raw('Date')
- if date == nil or date == '' then
- return true
+ local date_time = task:get_header('Date')
+ if date_time == nil or date_time == '' then
+ task:insert_result('MISSING_DATE', 1.0)
+ return
end
- return false
- end,
+
+ local dm = task:get_date({format = 'message', gmt = true})
+ local dt = task:get_date({format = 'connect', gmt = true})
+
+ 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
+ task:insert_result('DATE_IN_PAST', 1.0)
+ end
+ end
+})
+
+rspamd_config:register_symbol({
+ name = 'MISSING_DATE',
score = 1.0,
description = 'Message date is missing',
group = 'headers',
- type = 'mime',
-}
+ type = 'virtual',
+ parent = date_id,
+})
-rspamd_config.DATE_IN_FUTURE = {
- callback = function(task)
- local dm = task:get_date{format = 'message', gmt = true}
- local dt = task:get_date{format = 'connect', gmt = true}
- -- 2 hours
- if dm > 0 and dm - dt > 7200 then
- return true
- end
- return false
- end,
+rspamd_config:register_symbol({
+ name = 'DATE_IN_FUTURE',
score = 4.0,
description = 'Message date is in future',
group = 'headers',
- type = 'mime',
-}
+ type = 'virtual',
+ parent = date_id,
+})
-rspamd_config.DATE_IN_PAST = {
- callback = function(task)
- local dm = task:get_date{format = 'message', gmt = true}
- local dt = task:get_date{format = 'connect', gmt = true}
- -- A day
- if dm > 0 and dt - dm > 86400 then
- return true
- end
- return false
- end,
+rspamd_config:register_symbol({
+ name = 'DATE_IN_PAST',
score = 1.0,
description = 'Message date is in past',
group = 'headers',
- type = 'mime',
-}
+ type = 'virtual',
+ parent = date_id,
+})
local obscured_id = rspamd_config:register_symbol{
callback = function(task)