@@ -17,6 +17,7 @@ limitations under the License. | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_http = require "rspamd_http" | |||
local lua_util = require "lua_util" | |||
local exports = {} | |||
local N = 'clickhouse' | |||
@@ -73,7 +74,6 @@ end | |||
-- Parses JSONEachRow reply from CH | |||
local function parse_clickhouse_response(params, data) | |||
local lua_util = require "lua_util" | |||
local ucl = require "ucl" | |||
if data == nil then | |||
@@ -129,7 +129,7 @@ local function mk_http_select_cb(upstream, params, ok_cb, fail_cb) | |||
if ok_cb then | |||
ok_cb(params, rows) | |||
else | |||
rspamd_logger.debugm(N, params.log_obj, | |||
lua_util.debugm(N, params.log_obj, | |||
"http_select_cb ok: %s, %s, %s, %s", err_message, code, | |||
data:gsub('[\n%s]+', ' '), _) | |||
end | |||
@@ -170,7 +170,7 @@ local function mk_http_insert_cb(upstream, params, ok_cb, fail_cb) | |||
if ok_cb then | |||
ok_cb(params, data) | |||
else | |||
rspamd_logger.debugm(N, params.log_obj, | |||
lua_util.debugm(N, params.log_obj, | |||
"http_insert_cb ok: %s, %s, %s, %s", err_message, code, | |||
data:gsub('[\n%s]+', ' '), _) | |||
end | |||
@@ -214,7 +214,7 @@ exports.select = function (upstream, settings, params, query, ok_cb, fail_cb) | |||
http_params.body = query | |||
http_params.log_obj = params.task or params.config | |||
rspamd_logger.debugm(N, http_params.log_obj, "clickhouse select request: %s", http_params.body) | |||
lua_util.debugm(N, http_params.log_obj, "clickhouse select request: %s", http_params.body) | |||
if not http_params.url then | |||
local connect_prefix = "http://" |
@@ -18,7 +18,7 @@ limitations under the License. | |||
local exports = {} | |||
local E = {} | |||
local rspamd_logger = require "rspamd_logger" | |||
local lua_util = require "lua_util" | |||
local rspamd_util = require "rspamd_util" | |||
local function prepare_dkim_signing(N, task, settings) | |||
@@ -31,29 +31,29 @@ local function prepare_dkim_signing(N, task, settings) | |||
end | |||
if settings.auth_only and auser then | |||
rspamd_logger.debugm(N, task, 'user is authenticated') | |||
lua_util.debugm(N, task, 'user is authenticated') | |||
elseif (settings.sign_networks and settings.sign_networks:get_key(ip)) then | |||
is_sign_networks = true | |||
rspamd_logger.debugm(N, task, 'mail is from address in sign_networks') | |||
lua_util.debugm(N, task, 'mail is from address in sign_networks') | |||
elseif settings.sign_local and is_local then | |||
rspamd_logger.debugm(N, task, 'mail is from local address') | |||
lua_util.debugm(N, task, 'mail is from local address') | |||
elseif settings.sign_inbound and not is_local and not auser then | |||
rspamd_logger.debugm(N, task, 'mail was sent to us') | |||
lua_util.debugm(N, task, 'mail was sent to us') | |||
else | |||
rspamd_logger.debugm(N, task, 'ignoring unauthenticated mail') | |||
lua_util.debugm(N, task, 'ignoring unauthenticated mail') | |||
return false,{} | |||
end | |||
local efrom = task:get_from('smtp') | |||
if not settings.allow_envfrom_empty and | |||
#(((efrom or E)[1] or E).addr or '') == 0 then | |||
rspamd_logger.debugm(N, task, 'empty envelope from not allowed') | |||
lua_util.debugm(N, task, 'empty envelope from not allowed') | |||
return false,{} | |||
end | |||
local hfrom = task:get_from('mime') | |||
if not settings.allow_hdrfrom_multiple and (hfrom or E)[2] then | |||
rspamd_logger.debugm(N, task, 'multiple header from not allowed') | |||
lua_util.debugm(N, task, 'multiple header from not allowed') | |||
return false,{} | |||
end | |||
@@ -92,24 +92,24 @@ local function prepare_dkim_signing(N, task, settings) | |||
if settings.use_domain_sign_networks and is_sign_networks then | |||
dkim_domain = get_dkim_domain('use_domain_sign_networks') | |||
rspamd_logger.debugm(N, task, 'sign_networks: use domain(%s) for signature: %s', | |||
lua_util.debugm(N, task, 'sign_networks: use domain(%s) for signature: %s', | |||
settings.use_domain_sign_networks, dkim_domain) | |||
elseif settings.use_domain_sign_local and is_local then | |||
dkim_domain = get_dkim_domain('use_domain_sign_local') | |||
rspamd_logger.debugm(N, task, 'local: use domain(%s) for signature: %s', | |||
lua_util.debugm(N, task, 'local: use domain(%s) for signature: %s', | |||
settings.use_domain_sign_local, dkim_domain) | |||
elseif settings.use_domain_sign_inbound and not is_local and not auser then | |||
dkim_domain = get_dkim_domain('use_domain_sign_inbound') | |||
rspamd_logger.debugm(N, task, 'inbound: use domain(%s) for signature: %s', | |||
lua_util.debugm(N, task, 'inbound: use domain(%s) for signature: %s', | |||
settings.use_domain_sign_inbound, dkim_domain) | |||
else | |||
dkim_domain = get_dkim_domain('use_domain') | |||
rspamd_logger.debugm(N, task, 'use domain(%s) for signature: %s', | |||
lua_util.debugm(N, task, 'use domain(%s) for signature: %s', | |||
settings.use_domain, dkim_domain) | |||
end | |||
if not dkim_domain then | |||
rspamd_logger.debugm(N, task, 'could not extract dkim domain') | |||
lua_util.debugm(N, task, 'could not extract dkim domain') | |||
return false,{} | |||
end | |||
@@ -123,29 +123,29 @@ local function prepare_dkim_signing(N, task, settings) | |||
end | |||
end | |||
rspamd_logger.debugm(N, task, 'final DKIM domain: %s', dkim_domain) | |||
lua_util.debugm(N, task, 'final DKIM domain: %s', dkim_domain) | |||
if edom and hdom and not settings.allow_hdrfrom_mismatch and hdom ~= edom then | |||
if settings.allow_hdrfrom_mismatch_local and is_local then | |||
rspamd_logger.debugm(N, task, 'domain mismatch allowed for local IP: %1 != %2', hdom, edom) | |||
lua_util.debugm(N, task, 'domain mismatch allowed for local IP: %1 != %2', hdom, edom) | |||
elseif settings.allow_hdrfrom_mismatch_sign_networks and is_sign_networks then | |||
rspamd_logger.debugm(N, task, 'domain mismatch allowed for sign_networks: %1 != %2', hdom, edom) | |||
lua_util.debugm(N, task, 'domain mismatch allowed for sign_networks: %1 != %2', hdom, edom) | |||
else | |||
rspamd_logger.debugm(N, task, 'domain mismatch not allowed: %1 != %2', hdom, edom) | |||
lua_util.debugm(N, task, 'domain mismatch not allowed: %1 != %2', hdom, edom) | |||
return false,{} | |||
end | |||
end | |||
if auser and not settings.allow_username_mismatch then | |||
if not udom then | |||
rspamd_logger.debugm(N, task, 'couldnt find domain in username') | |||
lua_util.debugm(N, task, 'couldnt find domain in username') | |||
return false,{} | |||
end | |||
if settings.use_esld then | |||
udom = rspamd_util.get_tld(udom) | |||
end | |||
if udom ~= dkim_domain then | |||
rspamd_logger.debugm(N, task, 'user domain mismatch') | |||
lua_util.debugm(N, task, 'user domain mismatch') | |||
return false,{} | |||
end | |||
end | |||
@@ -175,7 +175,7 @@ local function prepare_dkim_signing(N, task, settings) | |||
if (not p.key or not p.selector) and (not (settings.try_fallback or | |||
settings.use_redis or settings.selector_map | |||
or settings.path_map)) then | |||
rspamd_logger.debugm(N, task, 'dkim unconfigured and fallback disabled') | |||
lua_util.debugm(N, task, 'dkim unconfigured and fallback disabled') | |||
return false,{} | |||
end | |||
end | |||
@@ -185,7 +185,7 @@ local function prepare_dkim_signing(N, task, settings) | |||
if data then | |||
p.selector = data | |||
elseif not settings.try_fallback then | |||
rspamd_logger.debugm(N, task, 'no selector for %s', dkim_domain) | |||
lua_util.debugm(N, task, 'no selector for %s', dkim_domain) | |||
return false,{} | |||
end | |||
end | |||
@@ -195,7 +195,7 @@ local function prepare_dkim_signing(N, task, settings) | |||
if data then | |||
p.key = data | |||
elseif not settings.try_fallback then | |||
rspamd_logger.debugm(N, task, 'no key for %s', dkim_domain) | |||
lua_util.debugm(N, task, 'no key for %s', dkim_domain) | |||
return false,{} | |||
end | |||
end |
@@ -357,7 +357,7 @@ local metafunctions = { | |||
} | |||
local function rspamd_gen_metatokens(task) | |||
local rspamd_logger = require "rspamd_logger" | |||
local lua_util = require "lua_util" | |||
local ipairs = ipairs | |||
local metatokens = {} | |||
local cached = task:cache_get('metatokens') | |||
@@ -368,7 +368,7 @@ local function rspamd_gen_metatokens(task) | |||
for _,mt in ipairs(metafunctions) do | |||
local ct = mt.cb(task) | |||
for i,tok in ipairs(ct) do | |||
rspamd_logger.debugm(N, task, "metatoken: %s = %s", mt.desc[i], tok) | |||
lua_util.debugm(N, task, "metatoken: %s = %s", mt.desc[i], tok) | |||
table.insert(metatokens, tok) | |||
end | |||
end |
@@ -299,11 +299,11 @@ local function check_av_cache(task, digest, rule, fn) | |||
if data and type(data) == 'string' then | |||
-- Cached | |||
if data ~= 'OK' then | |||
rspamd_logger.debugm(N, task, 'got cached result for %s: %s', key, data) | |||
lua_util.debugm(N, task, 'got cached result for %s: %s', key, data) | |||
data = rspamd_str_split(data, '\x30') | |||
yield_result(task, rule, data) | |||
else | |||
rspamd_logger.debugm(N, task, 'got cached result for %s: %s', key, data) | |||
lua_util.debugm(N, task, 'got cached result for %s: %s', key, data) | |||
end | |||
else | |||
if err then | |||
@@ -341,7 +341,7 @@ local function save_av_cache(task, digest, rule, to_save) | |||
rspamd_logger.errx(task, 'failed to save virus cache for %s -> "%s": %s', | |||
to_save, key, err) | |||
else | |||
rspamd_logger.debugm(N, task, 'saved cached result for %s: %s', key, to_save) | |||
lua_util.debugm(N, task, 'saved cached result for %s: %s', key, to_save) | |||
end | |||
end | |||
@@ -491,13 +491,13 @@ local function clamav_check(task, content, digest, rule) | |||
upstream:ok() | |||
data = tostring(data) | |||
local cached | |||
rspamd_logger.debugm(N, task, '%s [%s]: got reply: %s', rule['symbol'], rule['type'], data) | |||
lua_util.debugm(N, task, '%s [%s]: got reply: %s', rule['symbol'], rule['type'], data) | |||
if data == 'stream: OK' then | |||
cached = 'OK' | |||
if rule['log_clean'] then | |||
rspamd_logger.infox(task, '%s [%s]: message is clean', rule['symbol'], rule['type']) | |||
else | |||
rspamd_logger.debugm(N, task, '%s [%s]: message is clean', rule['symbol'], rule['type']) | |||
lua_util.debugm(N, task, '%s [%s]: message is clean', rule['symbol'], rule['type']) | |||
end | |||
else | |||
local vname = string.match(data, 'stream: (.+) FOUND') | |||
@@ -644,7 +644,7 @@ local function savapi_check(task, content, digest, rule) | |||
for virus,_ in pairs(vnames) do | |||
table.insert(vnames_reordered, virus) | |||
end | |||
rspamd_logger.debugm(N, task, "%s: number of virus names found %s", rule['type'], #vnames_reordered) | |||
lua_util.debugm(N, task, "%s: number of virus names found %s", rule['type'], #vnames_reordered) | |||
if #vnames_reordered > 0 then | |||
local vname = {} | |||
for _,virus in ipairs(vnames_reordered) do | |||
@@ -661,7 +661,7 @@ local function savapi_check(task, content, digest, rule) | |||
local function savapi_scan2_cb(err, data, conn) | |||
local result = tostring(data) | |||
rspamd_logger.debugm(N, task, "%s: got reply: %s", rule['type'], result) | |||
lua_util.debugm(N, task, "%s: got reply: %s", rule['type'], result) | |||
-- Terminal response - clean | |||
if string.find(result, '200') or string.find(result, '210') then | |||
@@ -701,7 +701,7 @@ local function savapi_check(task, content, digest, rule) | |||
local function savapi_greet2_cb(err, data, conn) | |||
local result = tostring(data) | |||
if string.find(result, '100 PRODUCT') then | |||
rspamd_logger.debugm(N, task, "%s: scanning file: %s", rule['type'], message_file) | |||
lua_util.debugm(N, task, "%s: scanning file: %s", rule['type'], message_file) | |||
conn:add_write(savapi_scan1_cb, {string.format('SCAN %s\n', message_file)}) | |||
else | |||
rspamd_logger.errx(task, '%s: invalid product id %s', rule['type'], rule['product_id']) |
@@ -197,7 +197,7 @@ local function arc_callback(task) | |||
return (e1.i or 0) < (e2.i or 0) | |||
end) | |||
rspamd_logger.debugm(N, task, 'got %s arc sections', #cbdata.seals) | |||
lua_util.debugm(N, task, 'got %s arc sections', #cbdata.seals) | |||
-- Now check sanity of what we have | |||
if not arc_validate_seals(task, cbdata.seals, cbdata.sigs, | |||
@@ -210,7 +210,7 @@ local function arc_callback(task) | |||
local function arc_seal_cb(_, res, err, domain) | |||
cbdata.checked = cbdata.checked + 1 | |||
rspamd_logger.debugm(N, task, 'checked arc seal: %s(%s), %s processed', | |||
lua_util.debugm(N, task, 'checked arc seal: %s(%s), %s processed', | |||
res, err, cbdata.checked) | |||
if not res then | |||
@@ -233,7 +233,7 @@ local function arc_callback(task) | |||
end | |||
local function arc_signature_cb(_, res, err, domain) | |||
rspamd_logger.debugm(N, task, 'checked arc signature %s: %s(%s), %s processed', | |||
lua_util.debugm(N, task, 'checked arc signature %s: %s(%s), %s processed', | |||
domain, res, err, cbdata.checked) | |||
if not res then | |||
@@ -252,7 +252,7 @@ local function arc_callback(task) | |||
cbdata.res = 'fail' | |||
table.insert(cbdata.errors, string.format('sig:%s:%s', sig.d or '', lerr)) | |||
cbdata.checked = cbdata.checked + 1 | |||
rspamd_logger.debugm(N, task, 'checked arc seal %s: %s(%s), %s processed', | |||
lua_util.debugm(N, task, 'checked arc seal %s: %s(%s), %s processed', | |||
sig.d, ret, lerr, cbdata.checked) | |||
end | |||
end, cbdata.seals) | |||
@@ -314,7 +314,7 @@ local function arc_callback(task) | |||
table.insert(cbdata.errors, string.format('sig:%s:%s', sig.d or '', err)) | |||
else | |||
processed = processed + 1 | |||
rspamd_logger.debugm(N, task, 'processed arc signature %s[%s]: %s(%s), %s processed', | |||
lua_util.debugm(N, task, 'processed arc signature %s[%s]: %s(%s), %s processed', | |||
sig.d, sig.i, ret, err, cbdata.checked) | |||
end | |||
@@ -414,18 +414,18 @@ local function arc_sign_seal(task, params, header) | |||
local s = dkim_canonicalize('ARC-Authentication-Results', | |||
arc_auth_results[i].value) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'update signature with header: %s', s) | |||
end | |||
if arc_sigs[i] then | |||
local s = dkim_canonicalize('ARC-Message-Signature', | |||
arc_sigs[i].raw_header) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'update signature with header: %s', s) | |||
end | |||
if arc_seals[i] then | |||
local s = dkim_canonicalize('ARC-Seal', arc_seals[i].raw_header) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'update signature with header: %s', s) | |||
end | |||
end | |||
end | |||
@@ -442,16 +442,16 @@ local function arc_sign_seal(task, params, header) | |||
local s = dkim_canonicalize('ARC-Authentication-Results', | |||
cur_auth_results) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'update signature with header: %s', s) | |||
s = dkim_canonicalize('ARC-Message-Signature', header) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'update signature with header: %s', s) | |||
local cur_arc_seal = string.format('i=%d; s=%s; d=%s; t=%d; a=rsa-sha256; cv=%s; b=', | |||
cur_idx, params.selector, params.domain, math.floor(rspamd_util.get_time()), params.arc_cv) | |||
s = string.format('%s:%s', 'arc-seal', cur_arc_seal) | |||
sha_ctx:update(s) | |||
rspamd_logger.debugm(N, task, 'initial update signature with header: %s', s) | |||
lua_util.debugm(N, task, 'initial update signature with header: %s', s) | |||
local sig = rspamd_rsa.sign_memory(privkey, sha_ctx:bin()) | |||
cur_arc_seal = string.format('%s%s', cur_arc_seal, | |||
@@ -554,7 +554,7 @@ local function arc_signing_cb(task) | |||
local exists,err = rspamd_util.file_exists(p.key) | |||
if not exists then | |||
if err and err == 'No such file or directory' then | |||
rspamd_logger.debugm(N, task, 'cannot read key from %s: %s', p.key, err) | |||
lua_util.debugm(N, task, 'cannot read key from %s: %s', p.key, err) | |||
else | |||
rspamd_logger.warnx(N, task, 'cannot read key from %s: %s', p.key, err) | |||
end |
@@ -289,7 +289,7 @@ local function clickhouse_collect(task) | |||
for _,sym in ipairs(settings.stop_symbols) do | |||
if task:has_symbol(sym) then | |||
rspamd_logger.debugm(N, task, 'skip collection as symbol %s has fired', sym) | |||
lua_util.debugm(N, task, 'skip collection as symbol %s has fired', sym) | |||
return | |||
end | |||
end | |||
@@ -568,7 +568,7 @@ local function clickhouse_collect(task) | |||
nrows = nrows + 1 | |||
table.insert(data_rows, row) | |||
rspamd_logger.debugm(N, task, "add clickhouse row %s / %s", nrows, settings.limit) | |||
lua_util.debugm(N, task, "add clickhouse row %s / %s", nrows, settings.limit) | |||
if nrows > settings['limit'] then | |||
clickhouse_send_data(task) | |||
@@ -579,7 +579,7 @@ local function clickhouse_collect(task) | |||
end | |||
local function do_remove_partition(ev_base, cfg, table_name, partition_id) | |||
rspamd_logger.debugm(N, rspamd_config, "removing partition %s.%s", table_name, partition_id) | |||
lua_util.debugm(N, rspamd_config, "removing partition %s.%s", table_name, partition_id) | |||
local upstream = settings.upstream:get_upstream_round_robin() | |||
local remove_partition_sql = "ALTER TABLE ${table_name} ${remove_method} PARTITION ${partition_id}" | |||
local remove_method = (settings.retention.method == 'drop') and 'DROP' or 'DETACH' | |||
@@ -630,7 +630,7 @@ local function get_last_removal_ago() | |||
local last_ts | |||
if err then | |||
rspamd_logger.debugm(N, rspamd_config, 'Failed to open %s: %s', ts_file, err) | |||
lua_util.debugm(N, rspamd_config, 'Failed to open %s: %s', ts_file, err) | |||
else | |||
last_ts = tonumber(f:read('*number')) | |||
f:close() |
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
]]-- | |||
local lutil = require "lua_util" | |||
local lua_util = require "lua_util" | |||
local rspamd_logger = require "rspamd_logger" | |||
local dkim_sign_tools = require "lua_dkim_tools" | |||
local rspamd_util = require "rspamd_util" | |||
@@ -103,7 +103,7 @@ local function dkim_signing_cb(task) | |||
rspamd_logger.infox(task, "cannot make request to load DKIM key for %s: %s", | |||
rk, err) | |||
elseif type(data) ~= 'string' then | |||
rspamd_logger.debugm(N, task, "missing DKIM key for %s", rk) | |||
lua_util.debugm(N, task, "missing DKIM key for %s", rk) | |||
else | |||
p.rawkey = data | |||
do_sign() | |||
@@ -150,11 +150,11 @@ local function dkim_signing_cb(task) | |||
end | |||
else | |||
if (p.key and p.selector) then | |||
p.key = lutil.template(p.key, {domain = p.domain, selector = p.selector}) | |||
p.key = lua_util.template(p.key, { domain = p.domain, selector = p.selector}) | |||
local exists,err = rspamd_util.file_exists(p.key) | |||
if not exists then | |||
if err and err == 'No such file or directory' then | |||
rspamd_logger.debugm(N, task, 'cannot read key from %s: %s', p.key, err) | |||
lua_util.debugm(N, task, 'cannot read key from %s: %s', p.key, err) | |||
else | |||
rspamd_logger.warnx(N, task, 'cannot read key from %s: %s', p.key, err) | |||
end | |||
@@ -184,7 +184,7 @@ for k,v in pairs(opts) do | |||
end | |||
if not (settings.use_redis or settings.path or settings.domain or settings.path_map or settings.selector_map) then | |||
rspamd_logger.infox(rspamd_config, 'mandatory parameters missing, disable dkim signing') | |||
lutil.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
return | |||
end | |||
if settings.use_redis then | |||
@@ -193,7 +193,7 @@ if settings.use_redis then | |||
if not redis_params then | |||
rspamd_logger.errx(rspamd_config, | |||
'no servers are specified, but module is configured to load keys from redis, disable dkim signing') | |||
lutil.disable_module(N, "redis") | |||
lua_util.disable_module(N, "redis") | |||
return | |||
end | |||
end |
@@ -24,6 +24,7 @@ local rspamd_tcp = require "rspamd_tcp" | |||
local rspamd_url = require "rspamd_url" | |||
local rspamd_util = require "rspamd_util" | |||
local rspamd_redis = require "lua_redis" | |||
local lua_util = require "lua_util" | |||
local check_local = false | |||
local check_authed = false | |||
@@ -665,7 +666,7 @@ if opts['reporting'] == true then | |||
local function dmarc_report_xml() | |||
local entries = {} | |||
report_id = string.format('%s.%d.%d', reporting_domain, report_start, report_end) | |||
rspamd_logger.debugm(N, rspamd_config, 'new report: %s', report_id) | |||
lua_util.debugm(N, rspamd_config, 'new report: %s', report_id) | |||
local actions = { | |||
push = function(t) | |||
local data = t[1] | |||
@@ -1183,19 +1184,19 @@ if opts['reporting'] == true then | |||
end | |||
local time = rspamd_util.get_time() | |||
if not stamp then | |||
rspamd_logger.debugm(N, rspamd_config, 'No state found - sending reports immediately') | |||
lua_util.debugm(N, rspamd_config, 'No state found - sending reports immediately') | |||
schedule_regular_send() | |||
send_reports(time) | |||
return | |||
end | |||
local delta = stamp - time + INTERVAL | |||
if delta <= 0 then | |||
rspamd_logger.debugm(N, rspamd_config, 'Last send is too old - sending reports immediately') | |||
lua_util.debugm(N, rspamd_config, 'Last send is too old - sending reports immediately') | |||
schedule_regular_send() | |||
send_reports(time) | |||
return | |||
end | |||
rspamd_logger.debugm(N, rspamd_config, 'Scheduling next send in %s seconds', delta) | |||
lua_util.debugm(N, rspamd_config, 'Scheduling next send in %s seconds', delta) | |||
schedule_intermediate_send(delta) | |||
end) | |||
end |
@@ -17,7 +17,7 @@ limitations under the License. | |||
local rspamd_logger = require 'rspamd_logger' | |||
local rspamd_http = require "rspamd_http" | |||
local rspamd_lua_utils = require "lua_util" | |||
local lua_util = require "lua_util" | |||
local util = require "rspamd_util" | |||
local ucl = require "ucl" | |||
local hash = require "rspamd_cryptobox_hash" | |||
@@ -80,7 +80,7 @@ local function elastic_send_data(task) | |||
local bulk_json = table.concat(tbl, "\n") | |||
local function http_index_data_callback(err, code, body, _) | |||
-- todo error handling we may store the rows it into redis and send it again late | |||
rspamd_logger.debugm(N, task, "After create data %1", body) | |||
lua_util.debugm(N, task, "After create data %1", body) | |||
if code ~= 200 then | |||
rspamd_logger.infox(task, "cannot push data to elastic backend (%s): %s (%s)", | |||
push_url, err, code) | |||
@@ -208,7 +208,7 @@ end | |||
local function elastic_collect(task) | |||
if not enabled then return end | |||
if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then return end | |||
if not settings.allow_local and lua_util.is_rspamc_or_controller(task) then return end | |||
local row = {['rspamd_meta'] = get_general_metadata(task), | |||
['@timestamp'] = tostring(util.get_time() * 1000)} | |||
table.insert(rows, row) | |||
@@ -309,7 +309,7 @@ local function initial_setup(cfg, ev_base, worker) | |||
err, code, body) | |||
enabled = false | |||
else | |||
rspamd_logger.debugm(N, 'pushed kibana template: %s', body) | |||
lua_util.debugm(N, 'pushed kibana template: %s', body) | |||
end | |||
end | |||
@@ -380,7 +380,7 @@ local function initial_setup(cfg, ev_base, worker) | |||
template_url, err, code, body) | |||
enabled = false | |||
else | |||
rspamd_logger.debugm(N, 'pushed rspamd template: %s', body) | |||
lua_util.debugm(N, 'pushed rspamd template: %s', body) | |||
push_kibana_template() | |||
end | |||
end | |||
@@ -431,7 +431,7 @@ if redis_params and opts then | |||
if not settings['server'] and not settings['servers'] then | |||
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') | |||
rspamd_lua_utils.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
else | |||
if settings.use_https then | |||
connect_prefix = 'https://' | |||
@@ -443,12 +443,12 @@ if redis_params and opts then | |||
if not settings.upstream then | |||
rspamd_logger.errx('cannot parse elastic address: %s', | |||
settings['server'] or settings['servers']) | |||
rspamd_lua_utils.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
return | |||
end | |||
if not settings['template_file'] then | |||
rspamd_logger.infox(rspamd_config, 'elastic template_file is required, disabling module') | |||
rspamd_lua_utils.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
return | |||
end | |||
@@ -456,7 +456,7 @@ if redis_params and opts then | |||
if not elastic_template then | |||
rspamd_logger.infox(rspamd_config, 'elastic unable to read %s, disabling module', | |||
settings['template_file']) | |||
rspamd_lua_utils.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
return | |||
end | |||
@@ -23,7 +23,6 @@ if confighelp then | |||
return | |||
end | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_regexp = require "rspamd_regexp" | |||
local lua_util = require "lua_util" | |||
local rspamc_local_helo = "rspamc.local" | |||
@@ -230,7 +229,7 @@ local function check_host(task, host, symbol_suffix, eq_ip, eq_host) | |||
local function check_host_cb_mx(_, to_resolve, results, err) | |||
task:inc_dns_req() | |||
if err and (err ~= 'requested record is not found' and err ~= 'no records with this name') then | |||
rspamd_logger.debugm(N, task, 'error looking up %s: %s', to_resolve, err) | |||
lua_util.debugm(N, task, 'error looking up %s: %s', to_resolve, err) | |||
end | |||
if not results then | |||
task:insert_result('HFILTER_' .. symbol_suffix .. '_NORES_A_OR_MX', 1.0, |
@@ -179,7 +179,7 @@ local function handle_history_request(task, conn, from, to, reset) | |||
end | |||
return nil | |||
end, data))) | |||
rspamd_logger.debugm(N, task, 'decompress took %s ms', | |||
lua_util.debugm(N, task, 'decompress took %s ms', | |||
(rspamd_util:get_ticks() - t1) * 1000.0) | |||
collectgarbage() | |||
end | |||
@@ -203,7 +203,7 @@ local function handle_history_request(task, conn, from, to, reset) | |||
return false, nil | |||
end | |||
end, data)))) | |||
rspamd_logger.debugm(N, task, 'parse took %s ms', | |||
lua_util.debugm(N, task, 'parse took %s ms', | |||
(rspamd_util:get_ticks() - t1) * 1000.0) | |||
collectgarbage() | |||
t1 = rspamd_util:get_ticks() | |||
@@ -218,7 +218,7 @@ local function handle_history_request(task, conn, from, to, reset) | |||
end, data) | |||
reply.rows = data | |||
conn:send_ucl(reply) | |||
rspamd_logger.debugm(N, task, 'process + sending took %s ms', | |||
lua_util.debugm(N, task, 'process + sending took %s ms', | |||
(rspamd_util:get_ticks() - t1) * 1000.0) | |||
collectgarbage() | |||
else |
@@ -21,7 +21,7 @@ end | |||
-- IP score is a module that set ip score of specific ip, asn, country | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_util = require "rspamd_util" | |||
local rspamd_lua_utils = require "lua_util" | |||
local lua_util = require "lua_util" | |||
-- Default settings | |||
local redis_params = nil | |||
@@ -102,7 +102,7 @@ end | |||
-- Set score based on metric's action | |||
local ip_score_set = function(task) | |||
if rspamd_lua_utils.is_rspamc_or_controller(task) then return end | |||
if lua_util.is_rspamc_or_controller(task) then return end | |||
local function new_score_set(score, old_score, old_total) | |||
local new_total | |||
if old_total == -1 or old_total ~= old_total then | |||
@@ -148,7 +148,7 @@ 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') | |||
rspamd_logger.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", | |||
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, | |||
@@ -171,7 +171,7 @@ 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) | |||
rspamd_logger.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, | |||
@@ -246,7 +246,7 @@ local ip_score_check = function(task) | |||
-- XXX: upstreams | |||
end | |||
local function calculate_score(score) | |||
local parts = rspamd_lua_utils.rspamd_str_split(score, '|') | |||
local parts = lua_util.rspamd_str_split(score, '|') | |||
local rep = tonumber(parts[1]) | |||
local total = tonumber(parts[2]) | |||
@@ -400,5 +400,5 @@ if redis_params then | |||
flags = 'empty', | |||
}) | |||
else | |||
rspamd_lua_utils.disable_module(N, "redis") | |||
lua_util.disable_module(N, "redis") | |||
end |
@@ -22,7 +22,7 @@ end | |||
-- A plugin that pushes metadata (or whole messages) to external services | |||
local redis_params | |||
local lutil = require "lua_util" | |||
local lua_util = require "lua_util" | |||
local rspamd_http = require "rspamd_http" | |||
local rspamd_tcp = require "rspamd_tcp" | |||
local rspamd_util = require "rspamd_util" | |||
@@ -187,7 +187,7 @@ local formatters = { | |||
meta.mail_to = table.concat(display_emails, ', ') | |||
meta.our_message_id = rspamd_util.random_hex(12) .. '@rspamd' | |||
meta.date = rspamd_util.time_to_string(rspamd_util.get_time()) | |||
return lutil.template(rule.email_template or settings.email_template, meta), {mail_targets = mail_targets} | |||
return lua_util.template(rule.email_template or settings.email_template, meta), { mail_targets = mail_targets} | |||
end, | |||
json = function(task) | |||
return ucl.to_format(get_general_metadata(task), 'json-compact') | |||
@@ -593,7 +593,7 @@ if type(settings.rules) ~= 'table' then | |||
return | |||
end | |||
elseif not next(settings.rules) then | |||
rspamd_logger.debugm(N, rspamd_config, 'No rules enabled') | |||
lua_util.debugm(N, rspamd_config, 'No rules enabled') | |||
return | |||
end | |||
if not settings.rules or not next(settings.rules) then | |||
@@ -691,23 +691,23 @@ local function gen_exporter(rule) | |||
local selector = rule.selector or 'default' | |||
local selected = selectors[selector](task) | |||
if selected then | |||
rspamd_logger.debugm(N, task, 'Message selected for processing') | |||
lua_util.debugm(N, task, 'Message selected for processing') | |||
local formatter = rule.formatter or 'default' | |||
local formatted, extra = formatters[formatter](task, rule) | |||
if formatted then | |||
pushers[rule.backend](task, formatted, rule, extra) | |||
else | |||
rspamd_logger.debugm(N, task, 'Formatter [%s] returned non-truthy value [%s]', formatter, formatted) | |||
lua_util.debugm(N, task, 'Formatter [%s] returned non-truthy value [%s]', formatter, formatted) | |||
end | |||
else | |||
rspamd_logger.debugm(N, task, 'Selector [%s] returned non-truthy value [%s]', selector, selected) | |||
lua_util.debugm(N, task, 'Selector [%s] returned non-truthy value [%s]', selector, selected) | |||
end | |||
end | |||
end | |||
if not next(settings.rules) then | |||
rspamd_logger.errx(rspamd_config, 'No rules enabled') | |||
lutil.disable_module(N, "config") | |||
lua_util.disable_module(N, "config") | |||
end | |||
for k, r in pairs(settings.rules) do | |||
rspamd_config:register_symbol({ |
@@ -685,10 +685,10 @@ local function multimap_callback(task, rule) | |||
local res,trace = rule['expression']:process_traced(task) | |||
if not res or res == 0 then | |||
rspamd_logger.debugm(N, task, 'condition is false for %s', rule['symbol']) | |||
lua_util.debugm(N, task, 'condition is false for %s', rule['symbol']) | |||
return | |||
else | |||
rspamd_logger.debugm(N, task, 'condition is true for %s: %s', rule['symbol'], | |||
lua_util.debugm(N, task, 'condition is true for %s: %s', rule['symbol'], | |||
trace) | |||
end | |||
end | |||
@@ -1060,7 +1060,7 @@ local function add_multimap_rule(key, newrule) | |||
local function process_atom(atom, task) | |||
local f_ret = task:has_symbol(atom) | |||
rspamd_logger.debugm(N, rspamd_config, 'check for symbol %s: %s', atom, f_ret) | |||
lua_util.debugm(N, rspamd_config, 'check for symbol %s: %s', atom, f_ret) | |||
if f_ret then | |||
return 1 | |||
@@ -1075,7 +1075,7 @@ local function add_multimap_rule(key, newrule) | |||
newrule['expression'] = expression | |||
fun.each(function(v) | |||
rspamd_logger.debugm(N, rspamd_config, 'add dependency %s -> %s', | |||
lua_util.debugm(N, rspamd_config, 'add dependency %s -> %s', | |||
newrule['symbol'], v) | |||
rspamd_config:register_dependency(newrule['symbol'], v) | |||
end, atoms) |
@@ -18,6 +18,10 @@ if confighelp then | |||
return | |||
end | |||
local rspamd_logger = require "rspamd_logger" | |||
local util = require "rspamd_util" | |||
local lua_util = require "lua_util" | |||
-- Phishing detection interface for selecting phished urls and inserting corresponding symbol | |||
-- | |||
-- | |||
@@ -40,8 +44,8 @@ local generic_service_hash | |||
local openphish_hash | |||
local generic_service_data = {} | |||
local openphish_data = {} | |||
local rspamd_logger = require "rspamd_logger" | |||
local util = require "rspamd_util" | |||
local opts = rspamd_config:get_all_opt(N) | |||
if not (opts and type(opts) == 'table') then | |||
rspamd_logger.infox(rspamd_config, 'Module is unconfigured') | |||
@@ -206,7 +210,7 @@ local function phishing_cb(task) | |||
local weight = 1.0 | |||
local spoofed,why = util.is_utf_spoofed(tld, ptld) | |||
if spoofed then | |||
rspamd_logger.debugm(N, task, "confusable: %1 -> %2: %3", tld, ptld, why) | |||
lua_util.debugm(N, task, "confusable: %1 -> %2: %3", tld, ptld, why) | |||
weight = 1.0 | |||
else | |||
local dist = util.levenshtein_distance(tld, ptld, 2) | |||
@@ -224,7 +228,7 @@ local function phishing_cb(task) | |||
if a1 ~= a2 then | |||
weight = 1 | |||
rspamd_logger.debugm(N, task, "confusable: %1 -> %2: different characters", | |||
lua_util.debugm(N, task, "confusable: %1 -> %2: different characters", | |||
tld, ptld, why) | |||
else | |||
-- We have totally different strings in tld, so penalize it significantly | |||
@@ -233,7 +237,7 @@ local function phishing_cb(task) | |||
end | |||
end | |||
rspamd_logger.debugm(N, task, "distance: %1 -> %2: %3", tld, ptld, dist) | |||
lua_util.debugm(N, task, "distance: %1 -> %2: %3", tld, ptld, dist) | |||
end | |||
local function found_in_map(map, furl, sweight) |
@@ -19,6 +19,15 @@ if confighelp then | |||
return | |||
end | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_util = require "rspamd_util" | |||
local rspamd_lua_utils = require "lua_util" | |||
local lua_redis = require "lua_redis" | |||
local fun = require "fun" | |||
local lua_maps = require "lua_maps" | |||
local lua_util = require "lua_util" | |||
local rspamd_hash = require "rspamd_cryptobox_hash" | |||
-- A plugin that implements ratelimits using redis | |||
local E = {} | |||
@@ -148,15 +157,6 @@ local message_func = function(_, limit_type, _, _) | |||
return string.format('Ratelimit "%s" exceeded', limit_type) | |||
end | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_util = require "rspamd_util" | |||
local rspamd_lua_utils = require "lua_util" | |||
local lua_redis = require "lua_redis" | |||
local fun = require "fun" | |||
local lua_maps = require "lua_maps" | |||
local lua_util = require "lua_util" | |||
local rspamd_hash = require "rspamd_cryptobox_hash" | |||
local function load_scripts(cfg, ev_base) | |||
bucket_check_id = lua_redis.add_redis_script(bucket_check_script, redis_params) | |||
@@ -500,7 +500,7 @@ local function ratelimit_cb(task) | |||
for pr,value in pairs(prefixes) do | |||
local bucket = value.bucket | |||
local rate = (bucket.rate) / 1000.0 -- Leak rate in messages/ms | |||
rspamd_logger.debugm(N, task, "check limit %s:%s -> %s (%s/%s)", | |||
lua_util.debugm(N, task, "check limit %s:%s -> %s (%s/%s)", | |||
value.name, pr, value.hash, bucket.burst, bucket.rate) | |||
lua_redis.exec_redis_script(bucket_check_id, | |||
{key = value.hash, task = task, is_write = true}, | |||
@@ -517,7 +517,7 @@ local function ratelimit_update_cb(task) | |||
if prefixes then | |||
if task:has_pre_result() then | |||
-- Already rate limited/greylisted, do nothing | |||
rspamd_logger.debugm(N, task, 'pre-action has been set, do not update') | |||
lua_util.debugm(N, task, 'pre-action has been set, do not update') | |||
return | |||
end | |||
@@ -531,7 +531,7 @@ local function ratelimit_update_cb(task) | |||
rspamd_logger.errx(task, 'cannot update rate bucket %s: %s', | |||
k, err) | |||
else | |||
rspamd_logger.debugm(N, task, | |||
lua_util.debugm(N, task, | |||
"updated limit %s:%s -> %s (%s/%s), burst: %s, dyn_rate: %s, dyn_burst: %s", | |||
v.name, k, v.hash, | |||
bucket.burst, bucket.rate, |
@@ -19,6 +19,12 @@ if confighelp then | |||
return | |||
end | |||
local hash = require 'rspamd_cryptobox_hash' | |||
local rspamd_logger = require 'rspamd_logger' | |||
local rspamd_util = require 'rspamd_util' | |||
local fun = require 'fun' | |||
local lua_util = require 'lua_util' | |||
-- This plugin implements various types of RBL checks | |||
-- Documentation can be found here: | |||
-- https://rspamd.com/doc/modules/rbl.html | |||
@@ -29,11 +35,6 @@ local N = 'rbl' | |||
local rbls = {} | |||
local local_exclusions = nil | |||
local hash = require 'rspamd_cryptobox_hash' | |||
local rspamd_logger = require 'rspamd_logger' | |||
local rspamd_util = require 'rspamd_util' | |||
local fun = require 'fun' | |||
local lua_util = require 'lua_util' | |||
local default_monitored = '1.0.0.127' | |||
local symbols = { | |||
@@ -161,10 +162,10 @@ local function rbl_cb (task) | |||
rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, err) | |||
end | |||
if not results then | |||
rspamd_logger.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 rbl=%4', to_resolve, false, err, rule['rbls'][1]['symbol']) | |||
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 rbl=%4', to_resolve, false, err, rule['rbls'][1]['symbol']) | |||
return | |||
else | |||
rspamd_logger.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 rbl=%4', to_resolve, true, err, rule['rbls'][1]['symbol']) | |||
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 rbl=%4', to_resolve, true, err, rule['rbls'][1]['symbol']) | |||
end | |||
for _,rbl in ipairs(rule.rbls) do | |||
@@ -175,7 +176,7 @@ local function rbl_cb (task) | |||
for _,result in pairs(results) do | |||
local ipstr = result:to_string() | |||
local foundrc | |||
rspamd_logger.debugm(N, task, '%s DNS result %s', to_resolve, ipstr) | |||
lua_util.debugm(N, task, '%s DNS result %s', to_resolve, ipstr) | |||
for s,i in pairs(rbl['returncodes']) do | |||
if type(i) == 'string' then | |||
if string.find(ipstr, '^' .. i .. '$') then | |||
@@ -211,7 +212,7 @@ local function rbl_cb (task) | |||
local params = {} -- indexed by rbl name | |||
local function gen_rbl_rule(to_resolve, rbl) | |||
rspamd_logger.debugm(N, task, 'DNS REQUEST: label=%1 rbl=%2', to_resolve, rbl['symbol']) | |||
lua_util.debugm(N, task, 'DNS REQUEST: label=%1 rbl=%2', to_resolve, rbl['symbol']) | |||
if not params[to_resolve] then | |||
local nrule = { | |||
to_resolve = to_resolve, |
@@ -19,6 +19,11 @@ if confighelp then | |||
return | |||
end | |||
local rspamd_logger = require 'rspamd_logger' | |||
local hash = require 'rspamd_cryptobox_hash' | |||
local lua_util = require 'lua_util' | |||
local lua_redis = require 'lua_redis' | |||
-- A plugin that implements replies check using redis | |||
-- Default port for redis upstreams | |||
@@ -34,10 +39,6 @@ local settings = { | |||
use_local = true, | |||
} | |||
local rspamd_logger = require 'rspamd_logger' | |||
local hash = require 'rspamd_cryptobox_hash' | |||
local lua_util = require 'lua_util' | |||
local lua_redis = require 'lua_redis' | |||
local N = "replies" | |||
local function make_key(goop) | |||
@@ -100,9 +101,9 @@ local function replies_set(task) | |||
-- If sender is unauthenticated return | |||
local ip = task:get_ip() | |||
if settings.use_auth and task:get_user() then | |||
rspamd_logger.debugm(N, task, 'sender is authenticated') | |||
lua_util.debugm(N, task, 'sender is authenticated') | |||
elseif settings.use_local and (ip and ip:is_local()) then | |||
rspamd_logger.debugm(N, task, 'sender is from local network') | |||
lua_util.debugm(N, task, 'sender is from local network') | |||
else | |||
return | |||
end | |||
@@ -113,7 +114,7 @@ local function replies_set(task) | |||
end | |||
-- Create hash of message-id and store to redis | |||
local key = make_key(msg_id) | |||
rspamd_logger.debugm(N, task, 'storing message-id for replies check') | |||
lua_util.debugm(N, task, 'storing message-id for replies check') | |||
local ret = lua_redis.redis_make_request(task, | |||
redis_params, -- connect params | |||
key, -- hash key |
@@ -30,6 +30,7 @@ local lua_maps = require "lua_maps" | |||
local hash = require 'rspamd_cryptobox_hash' | |||
local lua_redis = require "lua_redis" | |||
local fun = require "fun" | |||
local redis_params = nil | |||
local default_expiry = 864000 -- 10 day by default | |||
@@ -113,7 +114,7 @@ local function dkim_reputation_filter(task, rule) | |||
local rep_accepted = 0.0 | |||
local rep_rejected = 0.0 | |||
rspamd_logger.debugm(N, task, 'dkim reputation tokens: %s', requests) | |||
lua_util.debugm(N, task, 'dkim reputation tokens: %s', requests) | |||
local function tokens_cb(err, token, values) | |||
nchecked = nchecked + 1 | |||
@@ -575,7 +576,7 @@ local function spf_reputation_filter(task, rule) | |||
local cr = require "rspamd_cryptobox_hash" | |||
local hkey = cr.create(spf_record):base32():sub(1, 32) | |||
rspamd_logger.debugm(N, task, 'check spf record %s -> %s', spf_record, hkey) | |||
lua_util.debugm(N, task, 'check spf record %s -> %s', spf_record, hkey) | |||
local function tokens_cb(err, token, values) | |||
if values then | |||
@@ -614,7 +615,7 @@ local function spf_reputation_idempotent(task, rule) | |||
local cr = require "rspamd_cryptobox_hash" | |||
local hkey = cr.create(spf_record):base32():sub(1, 32) | |||
rspamd_logger.debugm(N, task, 'set spf record %s -> %s = %s', | |||
lua_util.debugm(N, task, 'set spf record %s -> %s = %s', | |||
spf_record, hkey, token) | |||
rule.backend.set_token(task, rule, hkey, token) | |||
end | |||
@@ -724,10 +725,10 @@ local function reputation_dns_get_token(task, rule, token, continuation_cb) | |||
rspamd_logger.errx(task, 'error looking up %s: %s', to_resolve, err) | |||
end | |||
if not results then | |||
rspamd_logger.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', | |||
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', | |||
to_resolve, false, err, rule.backend.config.list) | |||
else | |||
rspamd_logger.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', | |||
lua_util.debugm(N, task, 'DNS RESPONSE: label=%1 results=%2 error=%3 list=%4', | |||
to_resolve, true, err, rule.backend.config.list) | |||
end | |||
@@ -855,7 +856,7 @@ local function reputation_redis_get_token(task, rule, token, continuation_cb) | |||
values[data[i]] = ndata | |||
end | |||
end | |||
rspamd_logger.debugm(N, task, 'got values for key %s -> %s', | |||
lua_util.debugm(N, task, 'got values for key %s -> %s', | |||
key, values) | |||
continuation_cb(nil, key, values) | |||
else | |||
@@ -907,7 +908,7 @@ local function reputation_redis_set_token(task, rule, token, values, continuatio | |||
table.insert(args, k) | |||
table.insert(args, v) | |||
end | |||
rspamd_logger.debugm(N, task, 'set values for key %s -> %s', | |||
lua_util.debugm(N, task, 'set values for key %s -> %s', | |||
key, values) | |||
local ret = lua_redis.exec_redis_script(rule.backend.script_set, | |||
{task = task, is_write = true}, |
@@ -25,6 +25,12 @@ end | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_maps = require "lua_maps" | |||
local lua_squeeze = require "lua_squeeze_rules" | |||
local lua_util = require "lua_util" | |||
local rspamd_ip = require "rspamd_ip" | |||
local rspamd_regexp = require "rspamd_regexp" | |||
local ucl = require "ucl" | |||
local fun = require "fun" | |||
local redis_params | |||
local settings = {} | |||
@@ -32,10 +38,6 @@ local N = "settings" | |||
local settings_ids = {} | |||
local settings_initialized = false | |||
local max_pri = 0 | |||
local rspamd_ip = require "rspamd_ip" | |||
local rspamd_regexp = require "rspamd_regexp" | |||
local ucl = require "ucl" | |||
local fun = require "fun" | |||
local function apply_settings(task, to_apply) | |||
task:set_settings(to_apply) | |||
@@ -684,7 +686,7 @@ local function gen_redis_callback(handler, id) | |||
end | |||
if not key then | |||
rspamd_logger.debugm(N, task, 'handler number %s returned nil', id) | |||
lua_util.debugm(N, task, 'handler number %s returned nil', id) | |||
return | |||
end | |||
@@ -306,7 +306,7 @@ end | |||
local function freemail_search(input) | |||
local res = 0 | |||
local function trie_callback(number, pos) | |||
rspamd_logger.debugm(N, rspamd_config, 'Matched pattern %1 at pos %2', freemail_domains[number], pos) | |||
lua_util.debugm(N, rspamd_config, 'Matched pattern %1 at pos %2', freemail_domains[number], pos) | |||
res = res + 1 | |||
end | |||
@@ -562,7 +562,7 @@ local function maybe_parse_sa_function(line) | |||
local elts = split(line, '[^:]+') | |||
arg = elts[2] | |||
rspamd_logger.debugm(N, rspamd_config, 'trying to parse SA function %1 with args %2', | |||
lua_util.debugm(N, rspamd_config, 'trying to parse SA function %1 with args %2', | |||
elts[1], elts[2]) | |||
local substitutions = { | |||
{'^exists:', | |||
@@ -680,12 +680,12 @@ local function process_sa_conf(f) | |||
local function parse_score(words) | |||
if #words == 3 then | |||
-- score rule <x> | |||
rspamd_logger.debugm(N, rspamd_config, 'found score for %1: %2', words[2], words[3]) | |||
lua_util.debugm(N, rspamd_config, 'found score for %1: %2', words[2], words[3]) | |||
return tonumber(words[3]) | |||
elseif #words == 6 then | |||
-- score rule <x1> <x2> <x3> <x4> | |||
-- we assume here that bayes and network are enabled and select <x4> | |||
rspamd_logger.debugm(N, rspamd_config, 'found score for %1: %2', words[2], words[6]) | |||
lua_util.debugm(N, rspamd_config, 'found score for %1: %2', words[2], words[6]) | |||
return tonumber(words[6]) | |||
else | |||
rspamd_logger.errx(rspamd_config, 'invalid score for %1', words[2]) | |||
@@ -1173,9 +1173,9 @@ local function process_atom(atom, task) | |||
local res = atom_cb(task) | |||
if not res then | |||
rspamd_logger.debugm(N, task, 'atom: %1, NULL result', atom) | |||
lua_util.debugm(N, task, 'atom: %1, NULL result', atom) | |||
elseif res > 0 then | |||
rspamd_logger.debugm(N, task, 'atom: %1, result: %2', atom, res) | |||
lua_util.debugm(N, task, 'atom: %1, result: %2', atom, res) | |||
end | |||
return res | |||
else | |||
@@ -1185,10 +1185,10 @@ local function process_atom(atom, task) | |||
real_sym = symbols_replacements[atom] | |||
end | |||
if task:has_symbol(real_sym) then | |||
rspamd_logger.debugm(N, task, 'external atom: %1, result: 1', real_sym) | |||
lua_util.debugm(N, task, 'external atom: %1, result: 1', real_sym) | |||
return 1 | |||
end | |||
rspamd_logger.debugm(N, task, 'external atom: %1, result: 0', real_sym) | |||
lua_util.debugm(N, task, 'external atom: %1, result: 0', real_sym) | |||
end | |||
return 0 | |||
end | |||
@@ -1230,7 +1230,7 @@ local function post_process() | |||
--rule['re'] = nil | |||
else | |||
local old_max_hits = rule['re']:get_max_hits() | |||
rspamd_logger.debugm(N, rspamd_config, 'replace %1 -> %2', r, nexpr) | |||
lua_util.debugm(N, rspamd_config, 'replace %1 -> %2', r, nexpr) | |||
rspamd_config:replace_regexp({ | |||
old_re = rule['re'], | |||
new_re = nre | |||
@@ -1526,7 +1526,7 @@ local function post_process() | |||
if not external_deps[k][rspamd_symbol] then | |||
rspamd_config:register_dependency(k, rspamd_symbol) | |||
external_deps[k][rspamd_symbol] = true | |||
rspamd_logger.debugm(N, rspamd_config, | |||
lua_util.debugm(N, rspamd_config, | |||
'atom %1 is a direct foreign dependency, ' .. | |||
'register dependency for %2 on %3', | |||
a, k, rspamd_symbol) | |||
@@ -1556,7 +1556,7 @@ local function post_process() | |||
if not external_deps[k][dep] then | |||
rspamd_config:register_dependency(k, dep) | |||
external_deps[k][dep] = true | |||
rspamd_logger.debugm(N, rspamd_config, | |||
lua_util.debugm(N, rspamd_config, | |||
'atom %1 is an indirect foreign dependency, ' .. | |||
'register dependency for %2 on %3', | |||
a, k, dep) |
@@ -21,7 +21,7 @@ local rspamd_logger = require "rspamd_logger" | |||
local redis_params | |||
local use_redis = false; | |||
local M = 'spamtrap' | |||
local lutil = require "lua_util" | |||
local lua_util = require "lua_util" | |||
local settings = { | |||
symbol = 'SPAMTRAP', | |||
@@ -65,7 +65,7 @@ local function spamtrap_cb(task) | |||
rspamd_logger.infox(task, 'spamtrap found: <%s>', rcpt) | |||
if settings.smtp_message then | |||
task:set_pre_result(settings['action'], | |||
lutil.template(settings.smtp_message, {rcpt = rcpt})) | |||
lua_util.template(settings.smtp_message, { rcpt = rcpt})) | |||
else | |||
local smtp_message = 'unknown error' | |||
if settings.action == 'no action' then | |||
@@ -104,7 +104,7 @@ local function spamtrap_cb(task) | |||
end | |||
called_for_domain = true | |||
else | |||
rspamd_logger.debugm(M, task, 'skip spamtrap for %s', target) | |||
lua_util.debugm(M, task, 'skip spamtrap for %s', target) | |||
end | |||
end | |||
end | |||
@@ -129,7 +129,7 @@ local function spamtrap_cb(task) | |||
if settings['map']:get_key(target) then | |||
do_action(target) | |||
else | |||
rspamd_logger.debugm(M, task, 'skip spamtrap for %s', target) | |||
lua_util.debugm(M, task, 'skip spamtrap for %s', target) | |||
end | |||
end | |||
end |
@@ -62,7 +62,7 @@ local function tries_callback(task) | |||
local pattern_idx = pattern .. tostring(idx) .. type | |||
if param['multi'] or not matched[pattern_idx] then | |||
rspamd_logger.debugm(N, task, "<%1> matched pattern %2 at pos %3", | |||
lua_util.debugm(N, task, "<%1> matched pattern %2 at pos %3", | |||
task:get_message_id(), pattern, pos) | |||
task:insert_result(param['symbol'], 1.0, type) | |||
if not param['multi'] then |
@@ -18,6 +18,11 @@ if confighelp then | |||
return | |||
end | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_http = require "rspamd_http" | |||
local hash = require "rspamd_cryptobox_hash" | |||
local lua_util = require "lua_util" | |||
-- Some popular UA | |||
local default_ua = { | |||
'Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)', | |||
@@ -46,11 +51,6 @@ local settings = { | |||
top_urls_count = 200, -- how many top urls to save | |||
} | |||
local rspamd_logger = require "rspamd_logger" | |||
local rspamd_http = require "rspamd_http" | |||
local hash = require "rspamd_cryptobox_hash" | |||
local lua_util = require "lua_util" | |||
local function cache_url(task, orig_url, url, key, param) | |||
local function redis_trim_cb(err, data) | |||
if err then | |||
@@ -166,7 +166,7 @@ local function resolve_cached(task, orig_url, url, key, param, ntries) | |||
if rspamd_plugins.surbl.is_redirector(task, loc) then | |||
resolve_cached(task, orig_url, loc, key, param, ntries + 1) | |||
else | |||
rspamd_logger.debugm(N, task, | |||
lua_util.debugm(N, task, | |||
"stop resolving redirects as %s is not a redirector", loc) | |||
cache_url(task, orig_url, loc, key, param) | |||
end |