commit 662145d: [Minor] Reformat all Lua code, no functional changes
Vsevolod Stakhov
vsevolod at rspamd.com
Mon Aug 7 10:42:06 UTC 2023
Author: Vsevolod Stakhov
Date: 2023-08-07 11:41:28 +0100
URL: https://github.com/rspamd/rspamd/commit/662145d0554de5e769b92dab2d41173a98adcee5 (HEAD -> master)
[Minor] Reformat all Lua code, no functional changes
---
.luacheckrc | 1 +
lualib/lua_auth_results.lua | 29 +-
lualib/lua_aws.lua | 35 +-
lualib/lua_bayes_learn.lua | 16 +-
lualib/lua_cfg_transform.lua | 144 +-
lualib/lua_clickhouse.lua | 68 +-
lualib/lua_content/ical.lua | 30 +-
lualib/lua_content/init.lua | 23 +-
lualib/lua_content/pdf.lua | 197 +--
lualib/lua_content/vcard.lua | 26 +-
lualib/lua_dkim_tools.lua | 108 +-
lualib/lua_ffi/common.lua | 2 +-
lualib/lua_ffi/dkim.lua | 36 +-
lualib/lua_ffi/init.lua | 4 +-
lualib/lua_ffi/linalg.lua | 12 +-
lualib/lua_ffi/spf.lua | 4 +-
lualib/lua_fuzzy.lua | 41 +-
lualib/lua_lexer.lua | 60 +-
lualib/lua_magic/heuristics.lua | 175 +--
lualib/lua_magic/init.lua | 83 +-
lualib/lua_magic/patterns.lua | 12 +-
lualib/lua_maps.lua | 105 +-
lualib/lua_maps_expressions.lua | 17 +-
lualib/lua_meta.lua | 72 +-
lualib/lua_mime.lua | 161 +--
lualib/lua_mime_types.lua | 1424 ++++++++++----------
lualib/lua_scanners/avast.lua | 3 +-
lualib/lua_scanners/clamav.lua | 4 +-
lualib/lua_scanners/cloudmark.lua | 24 +-
lualib/lua_scanners/common.lua | 59 +-
lualib/lua_scanners/dcc.lua | 107 +-
lualib/lua_scanners/fprot.lua | 4 +-
lualib/lua_scanners/icap.lua | 88 +-
lualib/lua_scanners/init.lua | 6 +-
lualib/lua_scanners/kaspersky_av.lua | 1 -
lualib/lua_scanners/kaspersky_se.lua | 12 +-
lualib/lua_scanners/oletools.lua | 22 +-
lualib/lua_scanners/p0f.lua | 36 +-
lualib/lua_scanners/pyzor.lua | 11 +-
lualib/lua_scanners/razor.lua | 13 +-
lualib/lua_scanners/savapi.lua | 14 +-
lualib/lua_scanners/spamassassin.lua | 20 +-
lualib/lua_scanners/vadesecure.lua | 16 +-
lualib/lua_scanners/virustotal.lua | 2 +-
lualib/lua_selectors/common.lua | 5 +-
lualib/lua_selectors/extractors.lua | 140 +-
lualib/lua_selectors/init.lua | 134 +-
lualib/lua_selectors/transforms.lua | 122 +-
lualib/lua_settings.lua | 46 +-
lualib/lua_smtp.lua | 14 +-
lualib/lua_stat.lua | 89 +-
lualib/lua_tcp_sync.lua | 8 +-
lualib/lua_urls_compose.lua | 42 +-
lualib/lua_verdict.lua | 16 +-
lualib/plugins/dmarc.lua | 47 +-
lualib/plugins/neural.lua | 264 ++--
lualib/plugins/rbl.lua | 62 +-
lualib/redis_scripts/neural_maybe_invalidate.lua | 2 +-
lualib/redis_scripts/neural_maybe_lock.lua | 2 +-
lualib/redis_scripts/neural_train_size.lua | 10 +-
lualib/redis_scripts/ratelimit_check.lua | 30 +-
lualib/redis_scripts/ratelimit_cleanup_pending.lua | 6 +-
lualib/redis_scripts/ratelimit_update.lua | 20 +-
lualib/rescore_utility.lua | 30 +-
lualib/rspamadm/clickhouse.lua | 108 +-
lualib/rspamadm/configgraph.lua | 12 +-
lualib/rspamadm/confighelp.lua | 12 +-
lualib/rspamadm/configwizard.lua | 135 +-
lualib/rspamadm/cookie.lua | 14 +-
lualib/rspamadm/corpus_test.lua | 3 +-
lualib/rspamadm/dkim_keygen.lua | 53 +-
lualib/rspamadm/dmarc_report.lua | 81 +-
lualib/rspamadm/dns_tool.lua | 32 +-
lualib/rspamadm/fuzzy_convert.lua | 14 +-
lualib/rspamadm/fuzzy_stat.lua | 60 +-
lualib/rspamadm/grep.lua | 4 +-
lualib/rspamadm/keypair.lua | 70 +-
lualib/rspamadm/mime.lua | 213 +--
lualib/rspamadm/neural_test.lua | 27 +-
lualib/rspamadm/publicsuffix.lua | 7 +-
lualib/rspamadm/stat_convert.lua | 6 +-
lualib/rspamadm/statistics_dump.lua | 116 +-
lualib/rspamadm/template.lua | 18 +-
lualib/rspamadm/vault.lua | 107 +-
rules/bitcoin.lua | 25 +-
rules/bounce.lua | 9 +-
rules/content.lua | 32 +-
rules/controller/fuzzy.lua | 6 +-
rules/controller/init.lua | 6 +-
rules/controller/maps.lua | 28 +-
rules/controller/neural.lua | 4 +-
rules/controller/selectors.lua | 4 +-
rules/forwarding.lua | 34 +-
rules/headers_checks.lua | 248 ++--
rules/html.lua | 101 +-
rules/mid.lua | 18 +-
rules/misc.lua | 199 +--
rules/regexp/compromised_hosts.lua | 50 +-
rules/regexp/headers.lua | 91 +-
rules/regexp/misc.lua | 10 +-
rules/regexp/upstream_spam_filters.lua | 4 +-
rules/rspamd.lua | 10 +-
rules/subject_checks.lua | 8 +-
src/plugins/lua/antivirus.lua | 102 +-
src/plugins/lua/arc.lua | 113 +-
src/plugins/lua/asn.lua | 10 +-
src/plugins/lua/aws_s3.lua | 14 +-
src/plugins/lua/bayes_expiry.lua | 55 +-
src/plugins/lua/bimi.lua | 54 +-
src/plugins/lua/clickhouse.lua | 249 ++--
src/plugins/lua/clustering.lua | 48 +-
src/plugins/lua/dcc.lua | 45 +-
src/plugins/lua/dkim_signing.lua | 12 +-
src/plugins/lua/dmarc.lua | 81 +-
src/plugins/lua/dynamic_conf.lua | 40 +-
src/plugins/lua/elastic.lua | 91 +-
src/plugins/lua/external_relay.lua | 64 +-
src/plugins/lua/external_services.lua | 171 +--
src/plugins/lua/force_actions.lua | 44 +-
src/plugins/lua/forged_recipients.lua | 22 +-
src/plugins/lua/fuzzy_collect.lua | 26 +-
src/plugins/lua/greylist.lua | 78 +-
src/plugins/lua/hfilter.lua | 48 +-
src/plugins/lua/history_redis.lua | 115 +-
src/plugins/lua/http_headers.lua | 18 +-
src/plugins/lua/maillist.lua | 13 +-
src/plugins/lua/maps_stats.lua | 18 +-
src/plugins/lua/metadata_exporter.lua | 50 +-
src/plugins/lua/metric_exporter.lua | 14 +-
src/plugins/lua/mid.lua | 8 +-
src/plugins/lua/milter_headers.lua | 123 +-
src/plugins/lua/mime_types.lua | 60 +-
src/plugins/lua/multimap.lua | 225 ++--
src/plugins/lua/mx_check.lua | 56 +-
src/plugins/lua/neural.lua | 141 +-
src/plugins/lua/once_received.lua | 30 +-
src/plugins/lua/p0f.lua | 60 +-
src/plugins/lua/phishing.lua | 109 +-
src/plugins/lua/ratelimit.lua | 178 ++-
src/plugins/lua/rbl.lua | 138 +-
src/plugins/lua/replies.lua | 32 +-
src/plugins/lua/rspamd_update.lua | 10 +-
src/plugins/lua/settings.lua | 186 ++-
src/plugins/lua/spamassassin.lua | 1162 ++++++++--------
src/plugins/lua/spamtrap.lua | 31 +-
src/plugins/lua/spf.lua | 28 +-
src/plugins/lua/trie.lua | 24 +-
src/plugins/lua/url_redirector.lua | 108 +-
src/plugins/lua/whitelist.lua | 79 +-
149 files changed, 5820 insertions(+), 4958 deletions(-)
diff --git a/.luacheckrc b/.luacheckrc
index c242bddd8..353bee41d 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -80,3 +80,4 @@ files['/**/test/functional/'].ignore = {'631'}
max_string_line_length = 500
max_comment_line_length = 500
+max_line_length = 140
diff --git a/lualib/lua_auth_results.lua b/lualib/lua_auth_results.lua
index d10e1081c..8c907d9b7 100644
--- a/lualib/lua_auth_results.lua
+++ b/lualib/lua_auth_results.lua
@@ -93,7 +93,7 @@ local function gen_auth_results(task, settings)
else
common.symbols[sym] = s
if not auth_results[auth_type] then
- auth_results[auth_type] = {key}
+ auth_results[auth_type] = { key }
else
table.insert(auth_results[auth_type], key)
end
@@ -111,7 +111,7 @@ local function gen_auth_results(task, settings)
-- dkim=neutral (body hash did not verify) header.d=example.com header.s=sel header.b=fA8VVvJ8;
-- dkim=neutral (body hash did not verify) header.d=example.com header.s=sel header.b=f8pM8o90;
- for _,dres in ipairs(dkim_results) do
+ for _, dres in ipairs(dkim_results) do
local ar_string = 'none'
if dres.result == 'reject' then
@@ -168,7 +168,7 @@ local function gen_auth_results(task, settings)
hdr = hdr .. ' (policy=' .. lua_util.maybe_smtp_quote_value(opts[2]) .. ')'
hdr = hdr .. ' header.from=' .. lua_util.maybe_smtp_quote_value(opts[1])
elseif key ~= 'none' then
- local t = {opts[1]:match('^([^%s]+) : (.*)$')}
+ local t = { opts[1]:match('^([^%s]+) : (.*)$') }
if #t > 0 then
local dom = t[1]
local rsn = t[2]
@@ -197,7 +197,7 @@ local function gen_auth_results(task, settings)
-- Main type
local sender
local sender_type
- local smtp_from = task:get_from({'smtp','orig'})
+ local smtp_from = task:get_from({ 'smtp', 'orig' })
if smtp_from and
smtp_from[1] and
@@ -241,26 +241,25 @@ local function gen_auth_results(task, settings)
hdr = string.format('%s=%s', auth_type, key)
end
-
table.insert(hdr_parts, hdr)
end
end
end
local u = task:get_user()
- local smtp_from = task:get_from({'smtp','orig'})
+ local smtp_from = task:get_from({ 'smtp', 'orig' })
if u and smtp_from then
- local hdr = {[1] = 'auth=pass'}
+ local hdr = { [1] = 'auth=pass' }
if settings['add_smtp_user'] then
- table.insert(hdr,'smtp.auth=' .. lua_util.maybe_smtp_quote_value(u))
+ table.insert(hdr, 'smtp.auth=' .. lua_util.maybe_smtp_quote_value(u))
end
if smtp_from[1]['addr'] then
- table.insert(hdr,'smtp.mailfrom=' .. lua_util.maybe_smtp_quote_value(smtp_from[1]['addr']))
+ table.insert(hdr, 'smtp.mailfrom=' .. lua_util.maybe_smtp_quote_value(smtp_from[1]['addr']))
end
- table.insert(hdr_parts, table.concat(hdr,' '))
+ table.insert(hdr_parts, table.concat(hdr, ' '))
end
if #hdr_parts > 0 then
@@ -287,12 +286,12 @@ local function parse_ar_element(elt)
local S = lpeg.S
local V = lpeg.V
local C = lpeg.C
- local space = S(" ")^0
- local doublequoted = space * P'"' * ((1 - S'"\r\n\f\\') + (P'\\' * 1))^0 * '"' * space
- local comment = space * P{ "(" * ((1 - S"()") + V(1))^0 * ")" } * space
- local name = C((1 - S('=(" '))^1) * space
+ local space = S(" ") ^ 0
+ local doublequoted = space * P '"' * ((1 - S '"\r\n\f\\') + (P '\\' * 1)) ^ 0 * '"' * space
+ local comment = space * P { "(" * ((1 - S "()") + V(1)) ^ 0 * ")" } * space
+ local name = C((1 - S('=(" ')) ^ 1) * space
local pair = lpeg.Cg(name * "=" * space * name) * space
- aar_elt_grammar = lpeg.Cf(lpeg.Ct("") * (pair + comment + doublequoted)^1, rawset)
+ aar_elt_grammar = lpeg.Cf(lpeg.Ct("") * (pair + comment + doublequoted) ^ 1, rawset)
end
return aar_elt_grammar:match(elt)
diff --git a/lualib/lua_aws.lua b/lualib/lua_aws.lua
index 5de61eb0c..e6c4b29a2 100644
--- a/lualib/lua_aws.lua
+++ b/lualib/lua_aws.lua
@@ -68,13 +68,12 @@ end
local function save_cached_key(date_str, secret_key, region, service, req_type, key)
local numdate = tonumber(date_str)
-- expire old buckets
- for k,_ in pairs(cached_keys) do
+ for k, _ in pairs(cached_keys) do
if k < numdate then
cached_keys[k] = nil
end
end
-
local bucket = cached_keys[tonumber(date_str)]
local idx = string.format('%s.%s.%s.%s', secret_key, region, service, req_type)
@@ -113,7 +112,7 @@ local function aws_signing_key(date_str, secret_key, region, service, req_type)
end
local hmac1 = rspamd_crypto_hash.create_specific_keyed("AWS4" .. secret_key, "sha256", date_str):bin()
- local hmac2 = rspamd_crypto_hash.create_specific_keyed(hmac1, "sha256",region):bin()
+ local hmac2 = rspamd_crypto_hash.create_specific_keyed(hmac1, "sha256", region):bin()
local hmac3 = rspamd_crypto_hash.create_specific_keyed(hmac2, "sha256", service):bin()
local final_key = rspamd_crypto_hash.create_specific_keyed(hmac3, "sha256", req_type):bin()
@@ -155,7 +154,7 @@ local function aws_canon_request_hash(method, uri, headers_to_sign, hex_hash)
end, headers_to_sign))
local header_names = lua_util.keys(hdr_canon)
table.sort(header_names)
- for _,hn in ipairs(header_names) do
+ for _, hn in ipairs(header_names) do
local v = hdr_canon[hn]
lua_util.debugm(N, 'update signature with the header %s, %s',
hn, v)
@@ -165,19 +164,25 @@ local function aws_canon_request_hash(method, uri, headers_to_sign, hex_hash)
lua_util.debugm(N, 'headers list to sign: %s', hdrs_list)
sha_ctx:update(string.format('\n%s\n%s', hdrs_list, hex_hash))
- return sha_ctx:hex(),hdrs_list
+ return sha_ctx:hex(), hdrs_list
end
exports.aws_canon_request_hash = aws_canon_request_hash
-local aws_authorization_hdr_args_schema = ts.shape{
+local aws_authorization_hdr_args_schema = ts.shape {
date = ts.string + ts['nil'] / today_canonical,
secret_key = ts.string,
- method = ts.string + ts['nil'] / function() return 'GET' end,
+ method = ts.string + ts['nil'] / function()
+ return 'GET'
+ end,
uri = ts.string,
region = ts.string,
- service = ts.string + ts['nil'] / function() return 's3' end,
- req_type = ts.string + ts['nil'] / function() return 'aws4_request' end,
+ service = ts.string + ts['nil'] / function()
+ return 's3'
+ end,
+ req_type = ts.string + ts['nil'] / function()
+ return 'aws4_request'
+ end,
headers = ts.map_of(ts.string, ts.string),
key_id = ts.string,
}
@@ -199,9 +204,9 @@ ts.shape{
--
--]]
local function aws_authorization_hdr(tbl, transformed)
- local res,err
+ local res, err
if not transformed then
- res,err = aws_authorization_hdr_args_schema:transform(tbl)
+ res, err = aws_authorization_hdr_args_schema:transform(tbl)
assert(res, err)
else
res = tbl
@@ -210,7 +215,7 @@ local function aws_authorization_hdr(tbl, transformed)
local signing_key = aws_signing_key(res.date, res.secret_key, res.region, res.service,
res.req_type)
assert(signing_key ~= nil)
- local signed_sha,signed_hdrs = aws_canon_request_hash(res.method, res.uri,
+ local signed_sha, signed_hdrs = aws_canon_request_hash(res.method, res.uri,
res.headers)
if not signed_sha then
@@ -224,7 +229,7 @@ local function aws_authorization_hdr(tbl, transformed)
lua_util.debugm(N, "string to sign: %s", string_to_sign)
local hmac = rspamd_crypto_hash.create_specific_keyed(signing_key, 'sha256', string_to_sign):hex()
lua_util.debugm(N, "hmac: %s", hmac)
- local auth_hdr = string.format('AWS4-HMAC-SHA256 Credential=%s/%s/%s/%s/%s,'..
+ local auth_hdr = string.format('AWS4-HMAC-SHA256 Credential=%s/%s/%s/%s/%s,' ..
'SignedHeaders=%s,Signature=%s',
res.key_id, res.date, res.region, res.service, res.req_type,
signed_hdrs, hmac)
@@ -255,7 +260,7 @@ This method returns new/modified in place table of the headers
--
--]]
local function aws_request_enrich(tbl, content)
- local res,err = aws_authorization_hdr_args_schema:transform(tbl)
+ local res, err = aws_authorization_hdr_args_schema:transform(tbl)
assert(res, err)
local content_sha256 = rspamd_crypto_hash.create_specific('sha256', content):hex()
local hdrs = res.headers
@@ -281,7 +286,7 @@ local test_request_hdrs = {
assert(aws_canon_request_hash('GET', '/test.txt', test_request_hdrs) ==
'7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972')
-assert(aws_authorization_hdr{
+assert(aws_authorization_hdr {
date = '20130524',
region = 'us-east-1',
headers = test_request_hdrs,
diff --git a/lualib/lua_bayes_learn.lua b/lualib/lua_bayes_learn.lua
index 7782d8196..ea97db6f8 100644
--- a/lualib/lua_bayes_learn.lua
+++ b/lualib/lua_bayes_learn.lua
@@ -40,7 +40,7 @@ exports.can_learn = function(task, is_spam, is_unlearn)
end
if in_class then
- return false,string.format(
+ return false, string.format(
'already in class %s; probability %.2f%%',
cl, math.abs((prob - 0.5) * 200.0))
end
@@ -56,7 +56,7 @@ exports.autolearn = function(task, conf)
local mime_rcpts = 'undef'
local mr = task:get_recipients('mime')
if mr then
- for _,r in ipairs(mr) do
+ for _, r in ipairs(mr) do
if mime_rcpts == 'undef' then
mime_rcpts = r.addr
else
@@ -76,8 +76,8 @@ exports.autolearn = function(task, conf)
end
-- We have autolearn config so let's figure out what is requested
- local verdict,score = lua_verdict.get_specific_verdict("bayes", task)
- local learn_spam,learn_ham = false, false
+ local verdict, score = lua_verdict.get_specific_verdict("bayes", task)
+ local learn_spam, learn_ham = false, false
if verdict == 'passthrough' then
-- No need to autolearn
@@ -117,12 +117,14 @@ exports.autolearn = function(task, conf)
local ham_learns = task:get_mempool():get_variable('ham_learns', 'int64') or 0
local min_balance = 0.9
- if conf.min_balance then min_balance = conf.min_balance end
+ if conf.min_balance then
+ min_balance = conf.min_balance
+ end
if spam_learns > 0 or ham_learns > 0 then
local max_ratio = 1.0 / min_balance
local spam_learns_ratio = spam_learns / (ham_learns + 1)
- if spam_learns_ratio > max_ratio and learn_spam then
+ if spam_learns_ratio > max_ratio and learn_spam then
lua_util.debugm(N, task,
'skip learning spam, balance is not satisfied: %s < %s; %s spam learns; %s ham learns',
spam_learns_ratio, min_balance, spam_learns, ham_learns)
@@ -130,7 +132,7 @@ exports.autolearn = function(task, conf)
end
local ham_learns_ratio = ham_learns / (spam_learns + 1)
- if ham_learns_ratio > max_ratio and learn_ham then
+ if ham_learns_ratio > max_ratio and learn_ham then
lua_util.debugm(N, task,
'skip learning ham, balance is not satisfied: %s < %s; %s spam learns; %s ham learns',
ham_learns_ratio, min_balance, spam_learns, ham_learns)
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 419ebf0f6..d6243ade1 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -32,24 +32,24 @@ local function metric_pairs(t)
local function gen_keys(tbl)
if implicit_array then
- for _,v in ipairs(tbl) do
+ for _, v in ipairs(tbl) do
if v.name then
- table.insert(keys, {v.name, v})
+ table.insert(keys, { v.name, v })
v.name = nil
else
-- Very tricky to distinguish:
-- group {name = "foo" ... } + group "blah" { ... }
- for gr_name,gr in pairs(v) do
+ for gr_name, gr in pairs(v) do
if type(gr_name) ~= 'number' then
-- We can also have implicit arrays here
local gr_implicit = is_implicit(gr)
if gr_implicit then
- for _,gr_elt in ipairs(gr) do
- table.insert(keys, {gr_name, gr_elt})
+ for _, gr_elt in ipairs(gr) do
+ table.insert(keys, { gr_name, gr_elt })
end
else
- table.insert(keys, {gr_name, gr})
+ table.insert(keys, { gr_name, gr })
end
end
end
@@ -57,20 +57,20 @@ local function metric_pairs(t)
end
else
if tbl.name then
- table.insert(keys, {tbl.name, tbl})
+ table.insert(keys, { tbl.name, tbl })
tbl.name = nil
else
- for k,v in pairs(tbl) do
+ for k, v in pairs(tbl) do
if type(k) ~= 'number' then
-- We can also have implicit arrays here
local sym_implicit = is_implicit(v)
if sym_implicit then
- for _,elt in ipairs(v) do
- table.insert(keys, {k, elt})
+ for _, elt in ipairs(v) do
+ table.insert(keys, { k, elt })
end
else
- table.insert(keys, {k, v})
+ table.insert(keys, { k, v })
end
end
end
@@ -91,18 +91,26 @@ local function metric_pairs(t)
end
local function group_transform(cfg, k, v)
- if v.name then k = v.name end
+ if v.name then
+ k = v.name
+ end
local new_group = {
symbols = {}
}
- if v.enabled then new_group.enabled = v.enabled end
- if v.disabled then new_group.disabled = v.disabled end
- if v.max_score then new_group.max_score = v.max_score end
+ if v.enabled then
+ new_group.enabled = v.enabled
+ end
+ if v.disabled then
+ new_group.disabled = v.disabled
+ end
+ if v.max_score then
+ new_group.max_score = v.max_score
+ end
if v.symbol then
- for sk,sv in metric_pairs(v.symbol) do
+ for sk, sv in metric_pairs(v.symbol) do
if sv.name then
sk = sv.name
sv.name = nil -- Remove field
@@ -112,7 +120,9 @@ local function group_transform(cfg, k, v)
end
end
- if not cfg.group then cfg.group = {} end
+ if not cfg.group then
+ cfg.group = {}
+ end
if cfg.group[k] then
cfg.group[k] = lua_util.override_defaults(cfg.group[k], new_group)
@@ -153,7 +163,9 @@ local function test_groups(groups)
for gr_name, gr in pairs(groups) do
if not gr.symbols then
local cnt = 0
- for _,_ in pairs(gr) do cnt = cnt + 1 end
+ for _, _ in pairs(gr) do
+ cnt = cnt + 1
+ end
if cnt == 0 then
logger.debugx('group %s is empty', gr_name)
@@ -205,9 +217,9 @@ end
-- merged group definition
local function merge_groups(groups)
local ret = {}
- for k,gr in pairs(groups) do
+ for k, gr in pairs(groups) do
if type(k) == 'number' then
- for key,sec in pairs(gr) do
+ for key, sec in pairs(gr) do
ret[key] = sec
end
else
@@ -228,7 +240,7 @@ local function check_statistics_sanity()
if rspamd_util.file_exists(local_stat) and
rspamd_util.file_exists(local_bayes) then
- logger.warnx(rspamd_config, 'conflicting files %s and %s are found: '..
+ logger.warnx(rspamd_config, 'conflicting files %s and %s are found: ' ..
'Rspamd classifier configuration might be broken!', local_stat, local_bayes)
end
end
@@ -237,7 +249,7 @@ end
local function surbl_section_convert(cfg, section)
local rbl_section = cfg.rbl.rbls
local wl = section.whitelist
- for name,value in pairs(section.rules or {}) do
+ for name, value in pairs(section.rules or {}) do
if rbl_section[name] then
logger.warnx(rspamd_config, 'conflicting names in surbl and rbl rules: %s, prefer surbl rule!',
name)
@@ -251,13 +263,21 @@ local function surbl_section_convert(cfg, section)
converted.whitelist = wl
end
- for k,v in pairs(value) do
+ for k, v in pairs(value) do
local skip = false
-- Rename
- if k == 'suffix' then k = 'rbl' end
- if k == 'ips' then k = 'returncodes' end
- if k == 'bits' then k = 'returnbits' end
- if k == 'noip' then k = 'no_ip' end
+ if k == 'suffix' then
+ k = 'rbl'
+ end
+ if k == 'ips' then
+ k = 'returncodes'
+ end
+ if k == 'bits' then
+ k = 'returnbits'
+ end
+ if k == 'noip' then
+ k = 'no_ip'
+ end
-- Crappy legacy
if k == 'options' then
if v == 'noip' or v == 'no_ip' then
@@ -292,7 +312,7 @@ end
local function emails_section_convert(cfg, section)
local rbl_section = cfg.rbl.rbls
local wl = section.whitelist
- for name,value in pairs(section.rules or {}) do
+ for name, value in pairs(section.rules or {}) do
if rbl_section[name] then
logger.warnx(rspamd_config, 'conflicting names in emails and rbl rules: %s, prefer emails rule!',
name)
@@ -306,15 +326,27 @@ local function emails_section_convert(cfg, section)
converted.whitelist = wl
end
- for k,v in pairs(value) do
+ for k, v in pairs(value) do
local skip = false
-- Rename
- if k == 'dnsbl' then k = 'rbl' end
- if k == 'check_replyto' then k = 'replyto' end
- if k == 'hashlen' then k = 'hash_len' end
- if k == 'encoding' then k = 'hash_format' end
- if k == 'domain_only' then k = 'emails_domainonly' end
- if k == 'delimiter' then k = 'emails_delimiter' end
+ if k == 'dnsbl' then
+ k = 'rbl'
+ end
+ if k == 'check_replyto' then
+ k = 'replyto'
+ end
+ if k == 'hashlen' then
+ k = 'hash_len'
+ end
+ if k == 'encoding' then
+ k = 'hash_format'
+ end
+ if k == 'domain_only' then
+ k = 'emails_domainonly'
+ end
+ if k == 'delimiter' then
+ k = 'emails_delimiter'
+ end
if k == 'skip_body' then
skip = true
if v then
@@ -365,14 +397,14 @@ return function(cfg)
logger.errx('no actions defined')
else
-- Perform sanity check for actions
- local actions_defs = {'no action', 'no_action', -- In case if that's added
- 'greylist', 'add header', 'add_header',
- 'rewrite subject', 'rewrite_subject', 'quarantine',
- 'reject', 'discard'}
+ local actions_defs = { 'no action', 'no_action', -- In case if that's added
+ 'greylist', 'add header', 'add_header',
+ 'rewrite subject', 'rewrite_subject', 'quarantine',
+ 'reject', 'discard' }
if not cfg.actions['no action'] and not cfg.actions['no_action'] and
- not cfg.actions['accept'] then
- for _,d in ipairs(actions_defs) do
+ not cfg.actions['accept'] then
+ for _, d in ipairs(actions_defs) do
if cfg.actions[d] then
local action_score = nil
@@ -387,7 +419,7 @@ return function(cfg)
elseif type(action_score) == 'number' and action_score < 0 then
cfg.actions['no_action'] = cfg.actions[d] - 0.001
logger.infox(rspamd_config, 'set no_action score to: %s, as action %s has negative score',
- cfg.actions['no_action'], d)
+ cfg.actions['no_action'], d)
break
end
end
@@ -401,7 +433,7 @@ return function(cfg)
actions_set['grow_factor'] = true
actions_set['subject'] = true
- for k,_ in pairs(cfg.actions) do
+ for k, _ in pairs(cfg.actions) do
if not actions_set[k] then
logger.warnx(rspamd_config, 'unknown element in actions section: %s', k)
end
@@ -417,18 +449,18 @@ return function(cfg)
'reject',
'discard'
}
- for i=1,(#actions_order - 1) do
+ for i = 1, (#actions_order - 1) do
local act = actions_order[i]
if cfg.actions[act] and type(cfg.actions[act]) == 'number' then
local score = cfg.actions[act]
- for j=i+1,#actions_order do
+ for j = i + 1, #actions_order do
*** OUTPUT TRUNCATED, 25014 LINES SKIPPED ***
More information about the Commits
mailing list