diff options
-rw-r--r-- | rules/html.lua | 6 | ||||
-rw-r--r-- | rules/http_headers.lua | 4 | ||||
-rw-r--r-- | rules/misc.lua | 12 | ||||
-rw-r--r-- | rules/regexp/headers.lua | 7 | ||||
-rw-r--r-- | rules/rspamd.classifiers.lua | 23 | ||||
-rw-r--r-- | rules/rspamd.lua | 3 |
6 files changed, 17 insertions, 38 deletions
diff --git a/rules/html.lua b/rules/html.lua index a5f861b2d..bedf0cc61 100644 --- a/rules/html.lua +++ b/rules/html.lua @@ -14,8 +14,6 @@ -- 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'] = { @@ -184,7 +182,7 @@ rspamd_config.R_WHITE_ON_WHITE = { 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 @@ -208,8 +206,6 @@ rspamd_config.R_WHITE_ON_WHITE = { color[1], color[2], color[3], bgcolor[1], bgcolor[2], bgcolor[3]) end - else - end end end diff --git a/rules/http_headers.lua b/rules/http_headers.lua index ceb1893df..04e9b5dd4 100644 --- a/rules/http_headers.lua +++ b/rules/http_headers.lua @@ -54,7 +54,7 @@ if opts and opts['symbols'] then 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 @@ -63,7 +63,7 @@ if opts 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 diff --git a/rules/misc.lua b/rules/misc.lua index 2fc93da32..53e8a66f8 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -18,9 +18,6 @@ limitations under the License. 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') @@ -54,7 +51,7 @@ end 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) @@ -66,7 +63,7 @@ rspamd_config.SUBJ_ALL_CAPS = { 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) @@ -161,7 +158,7 @@ rspamd_config.R_SUSPICIOUS_URL = { 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 @@ -272,7 +269,7 @@ rspamd_config.MULTIPLE_UNIQUE_HEADERS = { 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 @@ -372,7 +369,6 @@ rspamd_config.RCVD_TLS_ALL = { 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 diff --git a/rules/regexp/headers.lua b/rules/regexp/headers.lua index 56f710650..ef0adc6b1 100644 --- a/rules/regexp/headers.lua +++ b/rules/regexp/headers.lua @@ -529,7 +529,6 @@ reconf['FM_FAKE_HELO_VERIZON'] = { -- 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), @@ -537,8 +536,6 @@ reconf['FORGED_MSGID_YAHOO'] = { 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' @@ -564,8 +561,6 @@ reconf['RCVD_DOUBLE_IP_SPAM'] = { -- 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, @@ -577,8 +572,6 @@ reconf['REPTO_QUOTE_YAHOO'] = { 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' diff --git a/rules/rspamd.classifiers.lua b/rules/rspamd.classifiers.lua index 1b83b4eb4..ad8ca8d4b 100644 --- a/rules/rspamd.classifiers.lua +++ b/rules/rspamd.classifiers.lua @@ -16,6 +16,8 @@ limitations under the License. -- 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' @@ -24,18 +26,13 @@ local long_subject_label = 'long subject' -- 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 @@ -43,7 +40,7 @@ local function get_specific_statfiles(classifier, task) 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 @@ -51,7 +48,7 @@ local function get_specific_statfiles(classifier, task) 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 @@ -59,7 +56,7 @@ local function get_specific_statfiles(classifier, task) 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 @@ -70,9 +67,9 @@ local function get_specific_statfiles(classifier, task) 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() @@ -91,11 +88,11 @@ classifiers['bayes'] = function(classifier, task, is_learn, is_spam) 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 diff --git a/rules/rspamd.lua b/rules/rspamd.lua index 086f81497..f5a5ed14e 100644 --- a/rules/rspamd.lua +++ b/rules/rspamd.lua @@ -16,10 +16,7 @@ limitations under the License. -- 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'] |