]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] rbl: support globbed return codes
authorAndrew Lewis <nerf@judo.za.org>
Wed, 25 Oct 2023 13:00:08 +0000 (15:00 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 25 Oct 2023 13:00:08 +0000 (15:00 +0200)
lualib/plugins/rbl.lua
src/plugins/lua/rbl.lua
test/functional/configs/merged-override.conf

index 4eb7b987d81ed9824a8bd542af2067fd1b40ac91..89304baa0d935c6afb4dfaf46bf7406ebb4a1a9a 100644 (file)
@@ -107,7 +107,7 @@ local rule_schema_tbl = {
   ipv6 = ts.boolean:is_optional(),
   is_whitelist = ts.boolean:is_optional(),
   local_exclude_ip_map = ts.string:is_optional(),
-  matcher = ts.one_of { "equality", "luapattern", "radix", "regexp" }:is_optional(),
+  matcher = ts.one_of { "equality", "glob", "luapattern", "radix", "regexp" }:is_optional(),
   monitored_address = ts.string:is_optional(),
   no_ip = ts.boolean:is_optional(),
   process_script = ts.string:is_optional(),
index 4365d245f3ae4e725cb0d05c1d62ac6fa4f10355..d1f2df69ca82709e4cdd205999c97e5207ec195c 100644 (file)
@@ -247,6 +247,10 @@ matchers.regexp = function(_, to_match, _, map)
   return map and map:get_key(to_match) or false
 end
 
+matchers.glob = function(_, to_match, _, map)
+  return map and map:get_key(to_match) or false
+end
+
 local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_table_elt, match)
   local function make_option(ip, label)
     if ip then
@@ -1009,6 +1013,12 @@ local function gen_rbl_callback(rule)
   return callback_f, string.format('checks: %s', table.concat(description, ','))
 end
 
+local map_match_types = {
+  glob = true,
+  radix = true,
+  regexp = true,
+}
+
 local function add_rbl(key, rbl, global_opts)
   if not rbl.symbol then
     rbl.symbol = key:upper()
@@ -1087,7 +1097,7 @@ local function add_rbl(key, rbl, global_opts)
   end
 
   local match_type = rbl.matcher
-  if match_type and rbl.returncodes and (match_type == 'radix' or match_type == 'regexp') then
+  if match_type and rbl.returncodes and map_match_types[match_type] then
     if not rbl.returncodes_maps then
       rbl.returncodes_maps = {}
     end
index 9ba31b7a1f71ff52975565b6e03f2816bfce2cef..75271136913a7169dab84ea52585210c37eaac01 100644 (file)
@@ -310,10 +310,14 @@ rbl {
       images = true;
       rbl = "test9.uribl";
     }
-    URIBL_NUMERIC_CONTENT {
+    UNKNOWN_URIBL_NUMERIC_CONTENT {
       checks = ["numeric_urls"];
       content_urls = true;
       rbl = "test9.uribl";
+      matcher = "glob";
+      returncodes = {
+        URIBL_NUMERIC_CONTENT = "*.*.*.*";
+      }
     }
     URIBL_NUMERIC_EVERYTHING {
       checks = ["numeric_urls"];