diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
commit | 662145d0554de5e769b92dab2d41173a98adcee5 (patch) | |
tree | ec28311a0bce6181f248ba7b50304293ad764e44 /rules/controller | |
parent | bbd88232db43d18f5e0de5a6502848d4074621c5 (diff) | |
download | rspamd-662145d0554de5e769b92dab2d41173a98adcee5.tar.gz rspamd-662145d0554de5e769b92dab2d41173a98adcee5.zip |
[Minor] Reformat all Lua code, no functional changes
Diffstat (limited to 'rules/controller')
-rw-r--r-- | rules/controller/fuzzy.lua | 6 | ||||
-rw-r--r-- | rules/controller/init.lua | 6 | ||||
-rw-r--r-- | rules/controller/maps.lua | 28 | ||||
-rw-r--r-- | rules/controller/neural.lua | 4 | ||||
-rw-r--r-- | rules/controller/selectors.lua | 4 |
5 files changed, 24 insertions, 24 deletions
diff --git a/rules/controller/fuzzy.lua b/rules/controller/fuzzy.lua index 7e4c96fe1..193e6fd4c 100644 --- a/rules/controller/fuzzy.lua +++ b/rules/controller/fuzzy.lua @@ -19,16 +19,16 @@ local function handle_gen_fuzzy(task, conn, req_params) local ret, hashes task:process_message() if req_params.rule then - ret,hashes = pcall(rspamd_plugins.fuzzy_check.hex_hashes, task, req_params.rule) + ret, hashes = pcall(rspamd_plugins.fuzzy_check.hex_hashes, task, req_params.rule) elseif req_params.flag then - ret,hashes = pcall(rspamd_plugins.fuzzy_check.hex_hashes, task, tonumber(req_params.flag)) + ret, hashes = pcall(rspamd_plugins.fuzzy_check.hex_hashes, task, tonumber(req_params.flag)) else conn:send_error(404, 'missing rule or flag') return end if ret then - conn:send_ucl({success = true, hashes = hashes}) + conn:send_ucl({ success = true, hashes = hashes }) else conn:send_error(500, 'cannot generate hashes') end diff --git a/rules/controller/init.lua b/rules/controller/init.lua index 9d60200f8..17fbbfc43 100644 --- a/rules/controller/init.lua +++ b/rules/controller/init.lua @@ -39,7 +39,7 @@ if rspamd_util.file_exists(local_conf .. '/controller.lua') then end end -for plug,paths in pairs(controller_plugin_paths) do +for plug, paths in pairs(controller_plugin_paths) do if not rspamd_plugins[plug] then rspamd_plugins[plug] = {} end @@ -49,7 +49,7 @@ for plug,paths in pairs(controller_plugin_paths) do local webui = rspamd_plugins[plug].webui - for path,attrs in pairs(paths) do + for path, attrs in pairs(paths) do if type(attrs) == 'table' then if type(attrs.handler) ~= 'function' then rspamd_logger.infox(rspamd_config, 'controller plugin %s; webui path %s has invalid handler: %s; ignore it', @@ -61,7 +61,7 @@ for plug,paths in pairs(controller_plugin_paths) do end else rspamd_logger.infox(rspamd_config, 'controller plugin %s; webui path %s has invalid type: %s; ignore it', - plug, path, type(attrs)) + plug, path, type(attrs)) end end end diff --git a/rules/controller/maps.lua b/rules/controller/maps.lua index a45e3d306..718e292f6 100644 --- a/rules/controller/maps.lua +++ b/rules/controller/maps.lua @@ -26,7 +26,7 @@ local function maybe_fill_maps_cache() maps_cache = {} maps_aliases = {} local maps = rspamd_config:get_maps() - for _,m in ipairs(maps) do + for _, m in ipairs(maps) do -- We get the first url here and that's it local url = m:get_uri() if url ~= 'static' then @@ -81,12 +81,12 @@ local function handle_query_map(_, conn, req_params) end local results = {} - for _,key in ipairs(keys_to_check) do - for uri,m in pairs(maps_cache) do + for _, key in ipairs(keys_to_check) do + for uri, m in pairs(maps_cache) do check_specific_map(key, uri, m, results, req_params.report_misses) end end - conn:send_ucl{ + conn:send_ucl { success = (#results > 0), results = results } @@ -106,7 +106,7 @@ local function handle_query_specific_map(_, conn, req_params) if req_params.maps then local map_names = lua_util.str_split(req_params.maps, ',') maps_to_check = {} - for _,mn in ipairs(map_names) do + for _, mn in ipairs(map_names) do if maps_cache[mn] then maps_to_check[mn] = maps_cache[mn] else @@ -122,13 +122,13 @@ local function handle_query_specific_map(_, conn, req_params) end local results = {} - for _,key in ipairs(keys_to_check) do - for uri,m in pairs(maps_to_check) do + for _, key in ipairs(keys_to_check) do + for uri, m in pairs(maps_to_check) do check_specific_map(key, uri, m, results, req_params.report_misses) end end - conn:send_ucl{ + conn:send_ucl { success = (#results > 0), results = results } @@ -136,13 +136,13 @@ end local function handle_list_maps(_, conn, _) maybe_fill_maps_cache() - conn:send_ucl{ + conn:send_ucl { maps = lua_util.keys(maps_cache), aliases = maps_aliases } end -local query_json_schema = ts.shape{ +local query_json_schema = ts.shape { maps = ts.array_of(ts.string):is_optional(), report_misses = ts.boolean:is_optional(), values = ts.array_of(ts.string), @@ -170,7 +170,7 @@ local function handle_query_json(task, conn) local results = {} if obj.maps then - for _,mn in ipairs(obj.maps) do + for _, mn in ipairs(obj.maps) do if maps_cache[mn] then maps_to_check[mn] = maps_cache[mn] else @@ -188,12 +188,12 @@ local function handle_query_json(task, conn) maps_to_check = maps_cache end - for _,key in ipairs(obj.values) do - for uri,m in pairs(maps_to_check) do + for _, key in ipairs(obj.values) do + for uri, m in pairs(maps_to_check) do check_specific_map(key, uri, m, results, report_misses) end end - conn:send_ucl{ + conn:send_ucl { success = (#results > 0), results = results } diff --git a/rules/controller/neural.lua b/rules/controller/neural.lua index db95cb7e9..aef104247 100644 --- a/rules/controller/neural.lua +++ b/rules/controller/neural.lua @@ -22,7 +22,7 @@ local E = {} -- Controller neural plugin -local learn_request_schema = ts.shape{ +local learn_request_schema = ts.shape { ham_vec = ts.array_of(ts.array_of(ts.number)), rule = ts.string:is_optional(), spam_vec = ts.array_of(ts.array_of(ts.number)), @@ -48,7 +48,7 @@ local function handle_learn(task, conn) local set = neural_common.get_rule_settings(task, rule) local version = ((set.ann or E).version or 0) + 1 - neural_common.spawn_train{ + neural_common.spawn_train { ev_base = task:get_ev_base(), ann_key = neural_common.new_ann_key(rule, set, version), set = set, diff --git a/rules/controller/selectors.lua b/rules/controller/selectors.lua index 8f3dc0931..7fc2894d7 100644 --- a/rules/controller/selectors.lua +++ b/rules/controller/selectors.lua @@ -30,7 +30,7 @@ local function handle_check_selector(_, conn, req_params) if req_params.selector and req_params.selector ~= '' then local selector = lua_selectors.create_selector_closure(rspamd_config, req_params.selector, '', true) - conn:send_ucl({success = selector and true}) + conn:send_ucl({ success = selector and true }) else conn:send_error(404, 'missing selector') end @@ -45,7 +45,7 @@ local function handle_check_message(task, conn, req_params) else task:process_message() local elts = selector(task) - conn:send_ucl({success = true, data = elts}) + conn:send_ucl({ success = true, data = elts }) end else conn:send_error(404, 'missing selector') |