diff options
-rw-r--r-- | .luacheckrc | 4 | ||||
-rw-r--r-- | lualib/lua_selectors.lua | 3 | ||||
-rw-r--r-- | lualib/rspamadm/configwizard.lua | 4 | ||||
-rw-r--r-- | src/plugins/lua/arc.lua | 6 | ||||
-rw-r--r-- | src/plugins/lua/bayes_expiry.lua | 13 | ||||
-rw-r--r-- | src/plugins/lua/clickhouse.lua | 27 | ||||
-rw-r--r-- | src/plugins/lua/clustering.lua | 3 | ||||
-rw-r--r-- | src/plugins/lua/dmarc.lua | 21 | ||||
-rw-r--r-- | src/plugins/lua/elastic.lua | 3 | ||||
-rw-r--r-- | src/plugins/lua/force_actions.lua | 6 | ||||
-rw-r--r-- | src/plugins/lua/history_redis.lua | 3 | ||||
-rw-r--r-- | src/plugins/lua/ip_score.lua | 28 | ||||
-rw-r--r-- | src/plugins/lua/maillist.lua | 6 | ||||
-rw-r--r-- | src/plugins/lua/mime_types.lua | 26 | ||||
-rw-r--r-- | src/plugins/lua/multimap.lua | 7 |
15 files changed, 113 insertions, 47 deletions
diff --git a/.luacheckrc b/.luacheckrc index 7aa54dcf6..f9ec38d20 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -38,7 +38,6 @@ globals = { ignore = { '212', -- unused argument '612', -- trailing whitespace - '631', -- line is too long '311', -- value assigned to variable X is unused } @@ -68,3 +67,6 @@ files['/**/src/rspamadm/*'].globals = { files['test/functional/lua/test_coverage.lua'].globals = { '__GLOBAL_COVERAGE_WATCHDOG' } + +max_string_line_length = 500 +max_comment_line_length = 500
\ No newline at end of file diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 760a15e8c..0a02edca9 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -583,7 +583,8 @@ Empty string comes the first argument or 'true', non-empty string comes nil]], return ip:apply_mask(mask):to_string(),'string' end end, - ['description'] = 'Applies mask to IP address. The first argument is the mask for IPv4 addresses, the second is the mask for IPv6 addresses.', + ['description'] = 'Applies mask to IP address.' .. + ' The first argument is the mask for IPv4 addresses, the second is the mask for IPv6 addresses.', ['args_schema'] = {(ts.number + ts.string / tonumber), (ts.number + ts.string / tonumber):is_optional()} }, diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua index a4bccd7ab..75fdb96aa 100644 --- a/lualib/rspamadm/configwizard.lua +++ b/lualib/rspamadm/configwizard.lua @@ -480,7 +480,9 @@ return ttl symbol_spam, symbol_ham, ver) try_convert(false) else - printf("You have configured new schema for %s/%s and your DB already has new layout (v. %s). DB conversion is not needed.", + printf( + 'You have configured new schema for %s/%s and your DB already has new layout (v. %s).' .. + ' DB conversion is not needed.', symbol_spam, symbol_ham, ver) end end diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index e940db619..cec738df7 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -562,7 +562,8 @@ local function arc_signing_cb(task) rspamd_logger.infox(rspamd_config, "Using selector prefix %s for domain %s", settings.selector_prefix, p.domain); local function redis_selector_cb(err, data) if err or type(data) ~= 'string' then - rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM selector for domain %s: %s", p.domain, err) + rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM selector for domain %s: %s", + p.domain, err) else try_redis_key(data) end @@ -640,7 +641,8 @@ if settings.use_redis then redis_params = rspamd_parse_redis_server('arc') if not redis_params then - rspamd_logger.errx(rspamd_config, 'no servers are specified, but module is configured to load keys from redis, disable arc signing') + rspamd_logger.errx(rspamd_config, 'no servers are specified, '.. + 'but module is configured to load keys from redis, disable arc signing') return end end diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua index d15ed43ac..9f5d7a68f 100644 --- a/src/plugins/lua/bayes_expiry.lua +++ b/src/plugins/lua/bayes_expiry.lua @@ -247,7 +247,8 @@ local expiry_script = [[ local tokens = {} -- Expiry step statistics counters - local nelts, extended, discriminated, sum, sum_squares, common, significant, infrequent, infrequent_ttls_set, insignificant, insignificant_ttls_set = + local nelts, extended, discriminated, sum, sum_squares, common, significant, + infrequent, infrequent_ttls_set, insignificant, insignificant_ttls_set = 0,0,0,0,0,0,0,0,0,0,0 for _,key in ipairs(keys) do @@ -348,8 +349,10 @@ local expiry_script = [[ return { next, step, - {nelts, extended, discriminated, mean, stddev, common, significant, infrequent, infrequent_ttls_set, insignificant, insignificant_ttls_set}, - {c.nelts, c.extended, c.discriminated, c.sum, c.sum_squares, c.common, c.significant, c.infrequent, c.infrequent_ttls_set, c.insignificant, c.insignificant_ttls_set} + {nelts, extended, discriminated, mean, stddev, common, significant, infrequent, + infrequent_ttls_set, insignificant, insignificant_ttls_set}, + {c.nelts, c.extended, c.discriminated, c.sum, c.sum_squares, c.common, + c.significant, c.infrequent, c.infrequent_ttls_set, c.insignificant, c.insignificant_ttls_set} } ]] @@ -393,7 +396,9 @@ local function expire_step(cls, ev_base, worker) data[5] } logger.infox(rspamd_config, - [[finished expiry %s%s: %s items checked, %s significant (%s %s), %s insignificant (%s %s), %s common (%s discriminated), %s infrequent (%s %s), %s mean, %s std]], + 'finished expiry %s%s: %s items checked, %s significant (%s %s), ' .. + '%s insignificant (%s %s), %s common (%s discriminated), ' .. + '%s infrequent (%s %s), %s mean, %s std', lutil.unpack(d)) end log_stat(false) diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 5fc642760..1a1b436a7 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -668,7 +668,8 @@ local function clickhouse_remove_old_partitions(cfg, ev_base) end local upstream = settings.upstream:get_upstream_round_robin() - local partition_to_remove_sql = "SELECT distinct partition, table FROM system.parts WHERE table in ('${tables}') and max_date <= toDate(now() - interval ${month} month);" + local partition_to_remove_sql = "SELECT distinct partition, table FROM system.parts WHERE " .. + "table in ('${tables}') and max_date <= toDate(now() - interval ${month} month);" local table_names = {'rspamd'} local tables = table.concat(table_names, "', '") @@ -811,7 +812,8 @@ local function check_clickhouse_upstream(upstream, ev_base, cfg) local sql = rspamd_lua_utils.template(rule.schema, settings) local err, _ = lua_clickhouse.generic_sync(upstream, settings, ch_params, sql) if err then - rspamd_logger.errx(rspamd_config, "cannot send custom schema %s to clickhouse server %s: cannot make request (%s)", + rspamd_logger.errx(rspamd_config, 'cannot send custom schema %s to clickhouse server %s: ' .. + 'cannot make request (%s)', k, upstream:get_addr():to_string(true), err) end end @@ -919,14 +921,18 @@ if opts then check_clickhouse_upstream(up, ev_base, cfg) end - if settings.retention.enable and settings.retention.method ~= 'drop' and settings.retention.method ~= 'detach' then - rspamd_logger.errx(rspamd_config, "retention.method should be either 'drop' or 'detach' (now: %s). Disabling retention", - settings.retention.method) + if settings.retention.enable and settings.retention.method ~= 'drop' and + settings.retention.method ~= 'detach' then + rspamd_logger.errx(rspamd_config, + "retention.method should be either 'drop' or 'detach' (now: %s). Disabling retention", + settings.retention.method) settings.retention.enable = false end - if settings.retention.enable and settings.retention.period_months < 1 or settings.retention.period_months > 1000 then - rspamd_logger.errx(rspamd_config, "please, set retention.period_months between 1 and 1000 (now: %s). Disabling retention", - settings.retention.period_months) + if settings.retention.enable and settings.retention.period_months < 1 or + settings.retention.period_months > 1000 then + rspamd_logger.errx(rspamd_config, + "please, set retention.period_months between 1 and 1000 (now: %s). Disabling retention", + settings.retention.period_months) settings.retention.enable = false end local period = lua_util.parse_time_interval(settings.retention.run_every) @@ -938,8 +944,9 @@ if opts then if settings.retention.enable then settings.retention.period = period - rspamd_logger.infox(rspamd_config, "retention will be performed each %s seconds for %s month with method %s", - period, settings.retention.period_months, settings.retention.method) + rspamd_logger.infox(rspamd_config, + "retention will be performed each %s seconds for %s month with method %s", + period, settings.retention.period_months, settings.retention.method) rspamd_config:add_periodic(ev_base, 0, clickhouse_remove_old_partitions, false) end end diff --git a/src/plugins/lua/clustering.lua b/src/plugins/lua/clustering.lua index a5d72fc64..327790dda 100644 --- a/src/plugins/lua/clustering.lua +++ b/src/plugins/lua/clustering.lua @@ -152,7 +152,8 @@ local function clusterting_filter_cb(task, rule) -- We have seen this element in ham mostly, so subtract average it from the size score final_score = math.min(1.0, size_score - cluster_score / cur_elts) end - rspamd_logger.debugm(N, task, 'processed rule %s, selectors: source="%s", cluster="%s"; data: %s elts, %s score, %s elt score', + rspamd_logger.debugm(N, task, + 'processed rule %s, selectors: source="%s", cluster="%s"; data: %s elts, %s score, %s elt score', rule.name, source_selector, cluster_selector, cur_elts, total_score, element_score) if final_score > 0.1 then task:insert_result(rule.symbol, final_score, {source_selector, diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 1bac6fb29..4638ef0ac 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -401,7 +401,8 @@ local function dmarc_validate_policy(task, policy, hdrfromdom, dmarc_esld) table.insert(reason, "No valid DKIM") end - lua_util.debugm(N, task, "validated dmarc policy for %s: %s; dkim_ok=%s, dkim_tempfail=%s, spf_ok=%s, spf_tempfail=%s", + lua_util.debugm(N, task, + "validated dmarc policy for %s: %s; dkim_ok=%s, dkim_tempfail=%s, spf_ok=%s, spf_tempfail=%s", policy.domain, policy.dmarc_policy, dkim_ok, dkim_tmpfail, spf_ok, spf_tmpfail) @@ -1041,7 +1042,8 @@ if opts['reporting'] == true then if type(report_settings.additional_address) == 'string' then reporting_addr[report_settings.additional_address] = true end - rspamd_logger.infox(ev_base, 'sending report for %s <%s>', reporting_domain, table.concat(reporting_addr, ',')) + rspamd_logger.infox(ev_base, 'sending report for %s <%s>', + reporting_domain, table.concat(reporting_addr, ',')) local dmarc_xml = dmarc_report_xml() local dmarc_push_cb dmarc_push_cb = function(err, data) @@ -1197,7 +1199,8 @@ if opts['reporting'] == true then callback = check_addr_cb, }) else - rspamd_logger.errx(rspamd_config, "Couldn't get reporting address for %s: retries exceeded", reporting_domain) + rspamd_logger.errx(rspamd_config, "Couldn't get reporting address for %s: retries exceeded", + reporting_domain) delete_reports() end end @@ -1316,8 +1319,16 @@ if opts['reporting'] == true then pool:set_variable(VAR_NAME, time) local yesterday = os.date('!*t', rspamd_util.get_time() - INTERVAL) local today = os.date('!*t', rspamd_util.get_time()) - report_start = os.time({year = yesterday.year, month = yesterday.month, day = yesterday.day, hour = 0}) + tz_offset - report_end = os.time({year = today.year, month = today.month, day = today.day, hour = 0}) + tz_offset + report_start = os.time({ + year = yesterday.year, + month = yesterday.month, + day = yesterday.day, + hour = 0}) + tz_offset + report_end = os.time({ + year = today.year, + month = today.month, + day = today.day, + hour = 0}) + tz_offset want_period = table.concat({ yesterday.year, string.format('%02d', yesterday.month), diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua index aa3702112..d613d335f 100644 --- a/src/plugins/lua/elastic.lua +++ b/src/plugins/lua/elastic.lua @@ -99,7 +99,8 @@ local function elastic_send_data(task) push_url, err, failed_sends, settings.max_fail) else if response.code ~= 200 then - rspamd_logger.infox(task, "cannot push data to elastic backend (%s): wrong http code %s (%s); failed attempts: %s/%s", + rspamd_logger.infox(task, + "cannot push data to elastic backend (%s): wrong http code %s (%s); failed attempts: %s/%s", push_url, err, response.code, failed_sends, settings.max_fail) else lua_util.debugm(N, task, "successfully sent %s (%s bytes) rows to ES", diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index eddd09dea..4fa4fd7fb 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -123,7 +123,8 @@ local function configure_module() for _, a in ipairs(atoms) do rspamd_config:register_dependency(name, a) end - rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', name, expr, table.concat(atoms, ',')) + rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', + name, expr, table.concat(atoms, ',')) end end end @@ -157,7 +158,8 @@ local function configure_module() for _, a in ipairs(atoms) do rspamd_config:register_dependency(t.name, a) end - rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', name, expr, table.concat(atoms, ',')) + rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', + name, expr, table.concat(atoms, ',')) else rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> as postfilter', name, expr) end diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua index a6d039553..b7345f04e 100644 --- a/src/plugins/lua/history_redis.lua +++ b/src/plugins/lua/history_redis.lua @@ -213,7 +213,8 @@ local function handle_history_request(task, conn, from, to, reset) elseif settings.subject_privacy then local hash_alg = settings.subject_privacy_alg local subject_hash = hash.create_specific(hash_alg, e.subject) - e.subject = settings.subject_privacy_prefix .. ':' .. subject_hash:hex():sub(1,settings.subject_privacy_length) + e.subject = settings.subject_privacy_prefix .. ':' .. + subject_hash:hex():sub(1,settings.subject_privacy_length) end end, data) reply.rows = data diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index d3aec2264..9416f4e88 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -148,11 +148,13 @@ local ip_score_set = function(task) ipnet_score,total_ipnet, ip_score, total_ip = pool:get_variable('ip_score', 'double,double,double,double,double,double,double,double') - lua_util.debugm(M, task, "raw scores: asn: %s, total_asn: %s, country: %s, total_country: %s, ipnet: %s, total_ipnet: %s, ip:%s, total_ip: %s", - asn_score,total_asn, - country_score,total_country, - ipnet_score,total_ipnet, - ip_score, total_ip) + lua_util.debugm(M, task, + 'raw scores: asn: %s, total_asn: %s, country: %s, ' .. + 'total_country: %s, ipnet: %s, total_ipnet: %s, ip:%s, total_ip: %s', + asn_score, total_asn, + country_score, total_country, + ipnet_score, total_ipnet, + ip_score, total_ip) local score_mult = 0 if options['actions'][action] then @@ -171,7 +173,9 @@ local ip_score_set = function(task) country_score,total_country = new_score_set(score, country_score, total_country) ipnet_score,total_ipnet = new_score_set(score, ipnet_score, total_ipnet) ip_score,total_ip = new_score_set(score, ip_score, total_ip) - lua_util.debugm(M, task, "processed scores: asn: %s, total_asn: %s, country: %s, total_country: %s, ipnet: %s, total_ipnet: %s, ip:%s, total_ip: %s", + lua_util.debugm(M, task, + 'processed scores: asn: %s, total_asn: %s, country: %s, total_country: %s,' .. + ' ipnet: %s, total_ipnet: %s, ip:%s, total_ip: %s', asn_score,total_asn, country_score,total_country, ipnet_score,total_ipnet, @@ -208,19 +212,23 @@ local ip_score_set = function(task) if ip_score ~= 0 then total_score = total_score + ip_score - table.insert(description_t, 'ip: ' .. '(' .. string.format('%.2f', ip_score * 10) .. ')') + table.insert(description_t, + 'ip: ' .. '(' .. string.format('%.2f', ip_score * 10) .. ')') end if ipnet_score ~= 0 then total_score = total_score + ipnet_score - table.insert(description_t, 'ipnet: ' .. ipnet .. '(' .. string.format('%.2f', ipnet_score * 10) .. ')') + table.insert(description_t, + 'ipnet: ' .. ipnet .. '(' .. string.format('%.2f', ipnet_score * 10) .. ')') end if asn_score ~= 0 then total_score = total_score + asn_score - table.insert(description_t, 'asn: ' .. asn .. '(' .. string.format('%.2f', asn_score * 10) .. ')') + table.insert(description_t, + 'asn: ' .. asn .. '(' .. string.format('%.2f', asn_score * 10) .. ')') end if country_score ~= 0 then total_score = total_score + country_score - table.insert(description_t, 'country: ' .. country .. '(' .. string.format('%.2f', country_score * 10) .. ')') + table.insert(description_t, + 'country: ' .. country .. '(' .. string.format('%.2f', country_score * 10) .. ')') end if options['max_score'] and (total_score*10) > options['max_score'] then diff --git a/src/plugins/lua/maillist.lua b/src/plugins/lua/maillist.lua index 2ec0c4255..846e92991 100644 --- a/src/plugins/lua/maillist.lua +++ b/src/plugins/lua/maillist.lua @@ -85,7 +85,8 @@ local function check_ml_mailman(task) -- For reminders we have other headers than for normal messages header = task:get_header('x-list-administrivia') local subject = task:get_header('subject') - if (header and string.find(header, 'yes')) or (subject and string.find(subject, 'mailing list memberships reminder$')) then + if (header and string.find(header, 'yes')) or + (subject and string.find(subject, 'mailing list memberships reminder$')) then if not task:get_header('errors-to') or not task:get_header('x-beenthere') then return false end @@ -202,7 +203,8 @@ end -- And nothing more can be extracted :( local function check_ml_majordomo(task) local header = task:get_header('Sender') - if not header or (not string.find(header, '^owner-.*$') and not string.find(header, '^.*-owner@.*$')) then + if not header or + (not string.find(header, '^owner-.*$') and not string.find(header, '^.*-owner@.*$')) then return false end diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 36407dac0..a3228a29b 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -305,7 +305,12 @@ local full_extensions_map = { {"dlm", "text/dlm"}, {"doc", "application/msword"}, {"docm", "application/vnd.ms-word.document.macroEnabled.12"}, - {"docx", {"application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/msword", "application/vnd.ms-word.document.12", "application/octet-stream"}}, + {"docx", { + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "application/msword", + "application/vnd.ms-word.document.12", + "application/octet-stream", + }}, {"dot", "application/msword"}, {"dotm", "application/vnd.ms-word.template.macroEnabled.12"}, {"dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"}, @@ -770,10 +775,19 @@ local full_extensions_map = { {"xlk", "application/vnd.ms-excel"}, {"xll", "application/vnd.ms-excel"}, {"xlm", "application/vnd.ms-excel"}, - {"xls", {"application/vnd.ms-excel", "application/vnd.ms-office", "application/x-excel", "application/octet-stream"}}, + {"xls", { + "application/vnd.ms-excel", + "application/vnd.ms-office", + "application/x-excel", + "application/octet-stream" + }}, {"xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"}, {"xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"}, - {"xlsx", {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-excel.12", "application/octet-stream"}}, + {"xlsx", { + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "application/vnd.ms-excel.12", + "application/octet-stream" + }}, {"xlt", "application/vnd.ms-excel"}, {"xltm", "application/vnd.ms-excel.template.macroEnabled.12"}, {"xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"}, @@ -797,7 +811,11 @@ local full_extensions_map = { {"xtp", "application/octet-stream"}, {"xwd", "image/x-xwindowdump"}, {"z", "application/x-compress"}, - {"zip", {"application/zip", "application/x-zip-compressed", "application/octet-stream"}}, + {"zip", { + "application/zip", + "application/x-zip-compressed", + "application/octet-stream" + }}, {"zlib", "application/zlib"}, } diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 4cc9af48b..1a397f9e6 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -724,9 +724,12 @@ local function multimap_callback(task, rule) name = to_resolve, }) - lua_util.debugm(N, rspamd_config, 'resolve() finished: results=%1, is_ok=%2, to_resolve=%3', results, is_ok, to_resolve) + lua_util.debugm(N, rspamd_config, + 'resolve() finished: results=%1, is_ok=%2, to_resolve=%3', + results, is_ok, to_resolve) - if not is_ok and (results ~= 'requested record is not found' and results ~= 'no records with this name') then + if not is_ok and + (results ~= 'requested record is not found' and results ~= 'no records with this name') then rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, results) elseif is_ok then task:insert_result(rule['symbol'], 1, rule['map']) |