From: Vsevolod Stakhov Date: Wed, 19 Nov 2025 10:41:10 +0000 (+0000) Subject: [Fix] Fix schema usage in reputation and ratelimit plugins X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25dd7f072bea9c0f8410bac1017e944f1f3c45fc;p=thirdparty%2Frspamd.git [Fix] Fix schema usage in reputation and ratelimit plugins - reputation: use :check() method instead of calling schema as function - ratelimit: fix burst and rate transform schemas (inner describes result) --- diff --git a/lualib/plugins/ratelimit.lua b/lualib/plugins/ratelimit.lua index 0b674f9c1e..265b5fce2c 100644 --- a/lualib/plugins/ratelimit.lua +++ b/lualib/plugins/ratelimit.lua @@ -100,11 +100,21 @@ end local bucket_schema = T.table({ burst = T.one_of({ T.number(), - T.transform(T.string(), lua_util.dehumanize_number) + T.transform(T.number(), function(val) + if type(val) == "string" then + return lua_util.dehumanize_number(val) + end + return val + end) }):doc({ summary = "Burst size (number of messages)" }), rate = T.one_of({ T.number(), - T.transform(T.string(), str_to_rate) + T.transform(T.number(), function(val) + if type(val) == "string" then + return str_to_rate(val) + end + return val + end) }):doc({ summary = "Rate limit (messages per time unit)" }), skip_recipients = T.boolean():optional():doc({ summary = "Skip per-recipient limits" }), symbol = T.string():optional():doc({ summary = "Custom symbol name" }), diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua index e43edc3478..fde9a4ad9d 100644 --- a/src/plugins/lua/reputation.lua +++ b/src/plugins/lua/reputation.lua @@ -1316,10 +1316,10 @@ local function parse_rule(name, tbl) rule.config = lua_util.override_defaults(rule.config, tbl) if rule.config.whitelist then - if lua_maps_exprs.schema(rule.config.whitelist) then + if lua_maps_exprs.schema:check(rule.config.whitelist) then rule.config.whitelist_map = lua_maps_exprs.create(rspamd_config, rule.config.whitelist, N) - elseif lua_maps.map_schema(rule.config.whitelist) then + elseif lua_maps.map_schema:check(rule.config.whitelist) then local map = lua_maps.map_add_from_ucl(rule.config.whitelist, 'radix', sel_type .. ' reputation whitelist')