-- limitations under the License.
local reconf = config['regexp']
-local rspamd_regexp = require "rspamd_regexp"
-local rspamd_logger = require "rspamd_logger"
-- Messages that have only HTML part
reconf['MIME_HTML_ONLY'] = {
normal_len = p:get_length()
local hc = p:get_html() -- we get HTML context
- hc:foreach_tag({'font', 'span', 'div', 'p'}, function(tag, len)
+ hc:foreach_tag({'font', 'span', 'div', 'p'}, function(tag, _)
local bl = tag:get_extra()
if bl then
if bl['bgcolor'] and bl['color'] and bl['visible'] then
color[1], color[2], color[3],
bgcolor[1], bgcolor[2], bgcolor[3])
end
- else
-
end
end
end
end
end
-local opts = rspamd_config:get_all_opt('dkim')
+opts = rspamd_config:get_all_opt('dkim')
if opts then
for k,_ in pairs(dkim_symbols) do
if opts[k] then
end
end
-local opts = rspamd_config:get_all_opt('spf')
+opts = rspamd_config:get_all_opt('spf')
if opts then
for k,_ in pairs(spf_symbols) do
if opts[k] then
local util = require "rspamd_util"
local rspamd_regexp = require "rspamd_regexp"
-local rspamd_logger = require "rspamd_logger"
-
-local reconf = config['regexp']
-- Uncategorized rules
local subject_re = rspamd_regexp.create('/^(?:(?:Re|Fwd|Fw|Aw|Antwort|Sv):\\s*)+(.+)$/i')
rspamd_config.SUBJ_ALL_CAPS = {
callback = function(task)
- local caps_test = function(sbj, len)
+ local caps_test = function(sbj, _)
return util.is_uppercase(sbj)
end
return test_subject(task, caps_test, 1.0/40.0)
rspamd_config.LONG_SUBJ = {
callback = function(task)
- local length_test = function(sbj, len)
+ local length_test = function(_, len)
return len > 200
end
return test_subject(task, length_test, 1.0/400.0)
local urls = task:get_urls()
if urls then
- for i,u in ipairs(urls) do
+ for _,u in ipairs(urls) do
if u:is_obscured() then
task:insert_result('R_SUSPICIOUS_URL', 1.0, u:get_host())
end
local res = 0
local res_tbl = {}
- for i,hdr in ipairs(headers_unique) do
+ for _,hdr in ipairs(headers_unique) do
local h = task:get_header_full(hdr)
if h and #h > 1 then
for _, rcvd in ipairs(rcvds) do
count = count + 1
local r = rcvd['decoded']:lower()
- local by = r:match('^by%s+([^%s]+)') or r:match('%sby%s+([^%s]+)')
local with = r:match('%swith%s+(e?smtps?a?)')
if with and with:match('esmtps') then
encrypted = encrypted + 1
-- Forged yahoo msgid
local at_yahoo_msgid = 'Message-Id=/\\@yahoo\\.com\\b/iH'
-local at_yahoogroups_msgid = 'Message-Id=/\\@yahoogroups\\.com\\b/iH'
local from_yahoo_com = 'From=/\\@yahoo\\.com\\b/iH'
reconf['FORGED_MSGID_YAHOO'] = {
re = string.format('(%s) & !(%s)', at_yahoo_msgid, from_yahoo_com),
description = 'Forged yahoo msgid',
group = 'header'
}
-local r_from_yahoo_groups = 'From=/rambler.ru\\@returns\\.groups\\.yahoo\\.com\\b/iH'
-local r_from_yahoo_groups_ro = 'From=/ro.ru\\@returns\\.groups\\.yahoo\\.com\\b/iH'
-- Forged The Bat! MUA headers
local thebat_mua_v1 = 'X-Mailer=/^The Bat! \\(v1\\./H'
-- Quoted reply-to from yahoo (seems to be forged)
local repto_quote = 'Reply-To=/\\".*\\"\\s*\\</H'
-local from_yahoo_com = 'From=/\\@yahoo\\.com\\b/iH'
-local at_yahoo_msgid = 'Message-Id=/\\@yahoo\\.com\\b/iH'
reconf['REPTO_QUOTE_YAHOO'] = {
re = string.format('(%s) & ((%s) | (%s))', repto_quote, from_yahoo_com, at_yahoo_msgid),
score = 2.0,
local xm_gnus = 'X-Mailer=/^Gnus v/H'
local xm_msoe5 = 'X-Mailer=/^Microsoft Outlook Express 5/H'
local xm_msoe6 = 'X-Mailer=/^Microsoft Outlook Express 6/H'
-local xm_mso12 = 'X-Mailer=/^Microsoft(?: Office Outlook 12\\.0| Outlook 14\\.0)/H'
-local xm_cgpmapi = 'X-Mailer=/^CommuniGate Pro MAPI Connector/H'
local xm_moz4 = 'X-Mailer=/^Mozilla 4/H'
local xm_skyri = 'X-Mailer=/^SKYRiXgreen/H'
local xm_wwwmail = 'X-Mailer=/^WWW-Mail \\d/H'
-- Detect language of message and selects appropriate statfiles for it
+local fun = require "fun"
+
-- Common labels for specific statfiles
local many_recipients_label = 'many recipients'
local undisclosed_recipients_label = 'undisclosed recipients'
-- Get specific statfiles set based on message rules
local function get_specific_statfiles(classifier, task)
- if not table.foreach then
- table.foreach = function(t, f)
- for k, v in pairs(t) do f(k, v) end
- end
- end
local spec_st = {}
-- More 5 recipients
local st_many = classifier:get_statfile_by_label(many_recipients_label)
if st_many then
local rcpt = task:get_recipients(2)
if rcpt and #rcpt > 5 then
- table.foreach(st_many, function(i,v) table.insert(spec_st,v) end)
+ fun.each(function(_,v) table.insert(spec_st,v) end, st_many)
end
end
-- Undisclosed
if st_undisc then
local rcpt = task:get_recipients(2)
if rcpt and #rcpt == 0 then
- table.foreach(st_undisc, function(i,v) table.insert(spec_st,v) end)
+ fun.each(function(_,v) table.insert(spec_st,v) end, st_undisc)
end
end
-- Maillist
if st_maillist then
local unsub_header = task:get_header_raw('List-Unsubscribe')
if unsub_header then
- table.foreach(st_maillist, function(i,v) table.insert(spec_st,v) end)
+ fun.each(function(_,v) table.insert(spec_st,v) end, st_maillist)
end
end
-- Long subject
if st_longsubj then
local subj = task:get_header_raw('Subject')
if subj and string.len(subj) > 150 then
- table.foreach(st_longsubj, function(i,v) table.insert(spec_st,v) end)
+ fun.each(function(_,v) table.insert(spec_st,v) end, st_longsubj)
end
end
end
end
-classifiers['bayes'] = function(classifier, task, is_learn, is_spam)
+classifiers['bayes'] = function(classifier, task, is_learn, _)
-- Subfunction for detection of message's language
- local detect_language = function(task)
+ local detect_language = function()
local parts = task:get_text_parts()
for _,p in ipairs(parts) do
local l = p:get_language()
return spec_st
else
-- Merge tables
- table.foreach(spec_st, function(i,v) table.insert(selected,v) end)
+ fun.each(function(_,v) table.insert(selected,v) end, spec_st)
end
end
-- Detect statfile by language
- local language = detect_language(task)
+ local language = detect_language()
if language then
-- Find statfiles with specified language
for _,st in ipairs(classifier:get_statfiles()) do
-- This is main lua config file for rspamd
-local util = require "rspamd_util"
-
config['regexp'] = {}
-local reconf = config['regexp']
local local_conf = rspamd_paths['CONFDIR']
local local_rules = rspamd_paths['RULESDIR']