ret = try_load_redis_servers(opts, rspamd_config, result)
if ret then
- ret,schema_error = config_schema:transform(ret)
+ ret,schema_error = config_schema:transform(result)
if ret then return ret end
end
ret = try_load_redis_servers(opts[module_name], rspamd_config, result)
if ret then
- ret,schema_error = config_schema:transform(ret)
+ ret,schema_error = config_schema:transform(result)
if ret then return ret end
end
end
if ret then
- ret,schema_error = config_schema:transform(ret)
+ ret,schema_error = config_schema:transform(result)
if ret then return ret end
end
end
if result.read_servers then
- result,schema_error = config_schema:transform(ret)
+ result,schema_error = config_schema:transform(result)
if result then return result end
else
return false
end
- if not cfg.symbol then
- rspamd_logger.errx(rspamd_config, 'cannot configure generic rule: no symbol specified')
- return false
- end
-
local selector = lua_selectors.create_selector_closure(rspamd_config,
cfg.selector, cfg.delimiter)
end
local function generic_reputation_filter(task, rule)
- local selector_res = rule.selector(task)
+ local cfg = rule.selector.config
+ local selector_res = cfg.selector(task)
local function tokens_cb(err, token, values)
if values then
local need_set = false
local token = {}
- local selector_res = rule.selector(task)
+ local selector_res = cfg.selector(task)
if not selector_res then return end
local k = cfg.keys_map[action]
local generic_selector = {
schema = ts.shape{
keys_map = keymap_schema,
- symbol = ts.string,
lower_bound = ts.number + ts.string / tonumber,
max_score = ts.number:is_optional(),
min_score = ts.number:is_optional(),
['rewrite subject'] = 'p',
['no action'] = 'h'
},
- symbol = nil, -- symbol to be inserted (not defined)
lower_bound = 10, -- minimum number of messages to be scored
min_score = nil,
max_score = nil,
end
end
-local function override_defaults(def, override)
- for k,v in pairs(override) do
- if k ~= 'selector' and k ~= 'backend' then
- if def[k] then
- if type(v) == 'table' then
- override_defaults(def[k], v)
- else
- def[k] = v
- end
- else
- def[k] = v
- end
- end
- end
-end
-
local function callback_gen(cb, rule)
return function(task)
if rule.enabled then
}
-- Override default config params
- override_defaults(rule.backend.config, bk_conf)
+ rule.backend.config = lua_util.override_defaults(rule.backend.config, bk_conf)
if backend.schema then
local checked,schema_err = backend.schema:transform(rule.backend.config)
if not checked then
rule.backend.config = checked
end
- override_defaults(rule.selector.config, sel_conf)
+ rule.selector.config = lua_util.override_defaults(rule.selector.config, sel_conf)
if selector.schema then
local checked,schema_err = selector.schema:transform(rule.selector.config)
if not checked then
- rspamd_logger.errx(rspamd_config, "cannot parse selector config for %s: %s",
+ rspamd_logger.errx(rspamd_config, "cannot parse selector config for %s: %s (%s)",
sel_type,
- schema_err)
+ schema_err, sel_conf)
return
end
rule.selector.config = checked
end
-- Generic options
- override_defaults(rule.config, tbl)
+ tbl.selector = nil
+ tbl.backend = nil
+ rule.config = lua_util.override_defaults(rule.config, tbl)
if rule.config.whitelisted_ip then
rule.config.whitelisted_ip_map = lua_maps.rspamd_map_add_from_ucl(rule.whitelisted_ip,