std = 'min'
exclude_files = {
+ '/**/contrib/**',
+ '/**/test/lua/**',
}
globals = {
+ 'check_header_delimiter_empty',
+ 'check_header_delimiter_tab',
'classifiers',
'config',
+ 'kmail_msgid',
'rspamd_config',
'rspamd_count_metatokens',
'rspamd_gen_metatokens',
ignore = {
}
-files['/**/rules/regexp/headers.lua'].globals = {
- 'check_header_delimiter_empty',
- 'check_header_delimiter_tab',
- 'kmail_msgid',
-}
-
files['/**/src/plugins/lua/spamassassin.lua'].globals = {
'ffi',
'jit',
}
+
+files['/**/src/rspamadm/*'].globals = {
+ 'ansicolors',
+ 'getopt',
+}
-local util = require "rspamd_util"
local opts = {}
local known_attrs = {
data = 1,
end
end
-local function sort_values(tbl, opts)
+local function sort_values(tbl)
local res = {}
for k, v in pairs(tbl) do
table.insert(res, { key = k, value = v })
end
local sorted = sort_values(value)
- for i, v in ipairs(sorted) do
+ for _, v in ipairs(sorted) do
if not known_attrs[v['key']] then
-- We need to go deeper
print_help(v['key'], v['value'], tabs .. '\t')
local sorted = sort_values(res)
- for i,v in ipairs(sorted) do
+ for _,v in ipairs(sorted) do
print_help(v['key'], v['value'], '')
print('')
end
local function send_digests(digests, redis_host, redis_password, redis_db)
local conn, err = connect_redis(redis_host, redis_password, redis_db)
- if not conn then return false end
- local _, v
+ if err then
+ print(err)
+ return false
+ end
+ local ret
for _, v in ipairs(digests) do
- local ret, err = conn:add_cmd('HMSET', {
+ ret, err = conn:add_cmd('HMSET', {
'fuzzy' .. v[1],
'F', v[2],
'V', v[3],
local function send_shingles(shingles, redis_host, redis_password, redis_db)
local conn, err = connect_redis(redis_host, redis_password, redis_db)
- if not conn then return false end
- local _, v
+ if err then
+ print("Redis error: " .. err)
+ return false
+ end
+ local ret
for _, v in ipairs(shingles) do
- local ret, err = conn:add_cmd('SET', {
+ ret, err = conn:add_cmd('SET', {
'fuzzy_' .. v[2] .. '_' .. v[1],
v[4],
})
local function update_counters(total, redis_host, redis_password, redis_db)
local conn, err = connect_redis(redis_host, redis_password, redis_db)
- if not conn then return false end
- local ret, err = conn:add_cmd('SET', {
+ if err then
+ print(err)
+ return false
+ end
+ local ret
+ ret, err = conn:add_cmd('SET', {
'fuzzylocal',
total,
})
print('Cannot batch SET command: ' .. err)
return false
end
- local ret, err = conn:add_cmd('SET', {
+ ret, err = conn:add_cmd('SET', {
'fuzzy_count',
total,
})
return true
end
-return function (args, res)
+return function (_, res)
local db = sqlite3.open(res['source_db'])
local shingles = {}
local digests = {}
end
-- Sort by checked
-local function sort_ips(tbl, opts)
+local function sort_ips(tbl, _opts)
local res = {}
for k,v in pairs(tbl) do
table.insert(res, {ip = k, data = v})
local function sort_order(elt)
local key = 'checked'
- local res = 0
+ local _res = 0
- if opts['sort'] then
- if opts['sort'] == 'matched' then
+ if _opts['sort'] then
+ if _opts['sort'] == 'matched' then
key = 'matched'
- elseif opts['sort'] == 'errors' then
+ elseif _opts['sort'] == 'errors' then
key = 'errors'
- elseif opts['sort'] == 'ip' then
+ elseif _opts['sort'] == 'ip' then
return elt['ip']
end
end
if elt['data'][key] then
- res = elt['data'][key]
+ _res = elt['data'][key]
end
- return res
+ return _res
end
table.sort(res, function(a, b)
opts = getopt(args, '')
if wrk then
- for i,pr in pairs(wrk) do
+ for _,pr in pairs(wrk) do
-- processes cycle
if pr['data'] then
local id = pr['id']
local res_keys = st['keys']
if res_keys and not opts['no-keys'] and not opts['short'] then
print('Keys statistics:')
- for k,st in pairs(res_keys) do
+ for k,_st in pairs(res_keys) do
print(string.format('Key id: %s', k))
- print_stat(st, '\t')
+ print_stat(_st, '\t')
- if st['ips'] and not opts['no-ips'] then
+ if _st['ips'] and not opts['no-ips'] then
print('')
print('\tIPs stat:')
- local sorted_ips = sort_ips(st['ips'], opts)
+ local sorted_ips = sort_ips(_st['ips'], opts)
- for i,v in ipairs(sorted_ips) do
+ for _,v in ipairs(sorted_ips) do
print(string.format('\t%s', v['ip']))
print_stat(v['data'], '\t\t')
print('')
print('IPs statistics:')
local sorted_ips = sort_ips(res_ips, opts)
- for i, v in ipairs(sorted_ips) do
+ for _, v in ipairs(sorted_ips) do
print(string.format('%s', v['ip']))
print_stat(v['data'], '\t')
print('')
local converted = 0
local db = sqlite3.open(cache)
local ret = true
+ local err_str
if not db then
print('Cannot open cache database: ' .. cache)
end
db:sql('COMMIT;')
- local err_str
if ret then
ret,err_str = conn:exec()
end
return ret
end
-return function (args, res)
+return function (_, res)
local db = sqlite3.open(res['source_db'])
local tokens = {}
local num = 0
local learns = {}
local redis_password = res['redis_password']
local redis_db = nil
- local ret = false
local cmd = 'HINCRBY'
+ local ret, err_str
if res['redis_db'] then
redis_db = tostring(res['redis_db'])
num = num + 1
total = total + 1
if num > lim then
- local ret,err_str = send_redis(res['redis_host'], res['symbol'],
+ ret,err_str = send_redis(res['redis_host'], res['symbol'],
tokens, redis_password, redis_db, cmd)
if not ret then
print('Cannot send tokens to the redis server: ' .. err_str)
end
end
if #tokens > 0 then
- local ret, err_str = send_redis(res['redis_host'], res['symbol'], tokens,
+ ret, err_str = send_redis(res['redis_host'], res['symbol'], tokens,
redis_password, redis_db, cmd)
if not ret then
-local logger = require "rspamd_logger"
-
local cb = function(task)
task:insert_result('TOP', 1.0)
end
for i = 2,10 do
rspamd_config:register_symbol('DEP' .. tostring(i), 1.0, cb_gen(i - 1))
rspamd_config:register_dependency('DEP' .. tostring(i), 'DEP' .. tostring(i - 1))
-end
\ No newline at end of file
+end
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]--
-local logger = require "rspamd_logger"
-
rspamd_config:register_post_filter(function(task)
task:set_flag('no_stat')
task:set_flag('no_log', false)
rspamd_config:register_symbol({
name = 'MAP_SET_HIT_AND_MISS',
score = 1.0,
- callback = function(task)
+ callback = function()
if (test_map:get_key('example.com') and not test_map:get_key('rspamd.com')) then
return true, 'example.com'
elseif (test_map:get_key('rspamd.com') and not test_map:get_key('example.com')) then
rspamd_config:register_symbol({
name = 'SIMPLE_TEST',
score = 1.0,
- callback = function(task)
+ callback = function()
return true, 'Fires always'
end
})
rspamd_config:register_symbol({
name = 'TEST_TLD',
score = 1.0,
- callback = function(task)
+ callback = function()
local prefixes = {
'',
'example.'
return
end
local u = rspamd_url.create(pool, p .. d)
- local test = u:get_tld()
+ test = u:get_tld()
if (test ~= d) then
table.insert(worry, 'url.get_tld:' .. p .. d .. ':' .. test)
return