]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix RBL plugin transform schemas
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Nov 2025 09:51:20 +0000 (09:51 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 19 Nov 2025 09:51:20 +0000 (09:51 +0000)
- Transform inner schema now validates the result, not input
- Updated return_codes_schema and return_bits_schema
- Transform functions now handle type conversion properly

lualib/plugins/rbl.lua

index 60c265d298e6c9f301a9cdf27a05fd427e74ce48..c53c103bf940385de18a0faacf2e02ba1e862776 100644 (file)
@@ -62,8 +62,12 @@ local return_codes_schema = T.table({}, {
   key = T.transform(T.string(), string.upper),
   extra = T.one_of({
     T.array(T.string()),
-    T.transform(T.string(), function(s)
-      return { s }
+    -- Transform string to array, inner schema validates the result
+    T.transform(T.array(T.string()), function(val)
+      if type(val) == "string" then
+        return { val }
+      end
+      return val
     end)
   })
 }):doc({ summary = "Map of symbol names to IP patterns" })
@@ -76,11 +80,14 @@ local return_bits_schema = T.table({}, {
       T.number(),
       T.transform(T.string(), tonumber)
     })),
-    T.transform(T.string(), function(s)
-      return { tonumber(s) }
-    end),
-    T.transform(T.number(), function(s)
-      return { s }
+    -- Transform string or number to array, inner schema validates the result
+    T.transform(T.array(T.number()), function(val)
+      if type(val) == "string" then
+        return { tonumber(val) }
+      elseif type(val) == "number" then
+        return { val }
+      end
+      return val
     end)
   })
 }):doc({ summary = "Map of symbol names to bit numbers" })