]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] rbl: support checking numeric URLs in isolation 4596/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 11 Sep 2023 09:13:47 +0000 (11:13 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 11 Sep 2023 09:13:47 +0000 (11:13 +0200)
lualib/plugins/rbl.lua
src/plugins/lua/rbl.lua
test/functional/cases/001_merged/300_rbl.robot
test/functional/configs/merged-local.conf
test/functional/configs/merged-override.conf
test/functional/messages/numeric_urls.eml [new file with mode: 0644]

index bff53f9bacd432d88e7834b13307f40ac7edc2b7..02d0d3338ee4fc320c6bbd39f16b451715d8c809 100644 (file)
@@ -30,6 +30,7 @@ local check_types = {
   },
   urls = {},
   content_urls = {},
+  numeric_urls = {},
   emails = {},
   replyto = {},
   dkim = {},
@@ -212,4 +213,4 @@ return {
   rule_schema = ts.shape(rule_schema_tbl),
   default_options = default_options,
   convert_checks = convert_checks,
-}
\ No newline at end of file
+}
index 6dce0e0f13356b39b25b823cfa98519bf625d6f1..c5cdbef1cda0b496040052df6aee0dca96e70551 100644 (file)
@@ -572,6 +572,9 @@ local function gen_rbl_callback(rule)
       if rule.images then
         table.insert(ex_params.flags, 'image')
       end
+      if rule.numeric_urls then
+        table.insert(ex_params.flags, 'numeric')
+      end
     end
 
     local urls = lua_util.extract_specific_urls(ex_params)
@@ -805,7 +808,7 @@ local function gen_rbl_callback(rule)
     description[#description + 1] = 'replyto'
   end
 
-  if rule.urls or rule.content_urls or rule.images then
+  if rule.urls or rule.content_urls or rule.images or rule.numeric_urls then
     pipeline[#pipeline + 1] = check_urls
     description[#description + 1] = 'urls'
   end
index 094eec40904c9b4d7514f89fd3a791c87ce138e8..c0e7fde95488d30443cde22d242b265dd924e985 100644 (file)
@@ -75,3 +75,8 @@ SELECTORS COMBINED
   ...  Settings={symbols_enabled = [RBL_SELECTOR_MULTIPLE]}
   Expect Symbol With Option  RBL_SELECTOR_MULTIPLE  example.org:sel_from
   Expect Symbol With Option  RBL_SELECTOR_MULTIPLE  example.org:sel_helo
+
+NUMERIC URLS
+  Scan File  ${RSPAMD_TESTDIR}/messages/numeric_urls.eml
+  ...  Settings={symbols_enabled = [URIBL_NUMERIC]}
+  Expect Symbol With Exact Options  URIBL_NUMERIC  4.3.2.1:url
index 27738dd5ee9c7bbc5c36d4d2e447cfee38ff81c9..82d6097306bb41701a5487e4393b0ecd422d2342 100644 (file)
@@ -875,6 +875,11 @@ options = {
           type = a;
           replies = ["127.0.0.2"];
         },
+        {
+          name = "4.3.2.1.test9.uribl";
+          type = a;
+          replies = ["127.0.0.2"];
+        },
         {
           name = "8.8.8.8.test9.uribl";
           type = a;
index 74d9b441fa1658b8fecfd6027f0529e7a4c023c5..04b879db608efacde5fa816a2e955a8ffc886af3 100644 (file)
@@ -298,6 +298,10 @@ rbl {
         RSPAMD_EMAILBL = "127.0.0.2";
       }
     }
+    URIBL_NUMERIC {
+      checks = ["numeric_urls"];
+      rbl = "test9.uribl";
+    }
     URIBL_NOCONTENT {
       rbl = "test9.uribl";
       ignore_defaults = true;
diff --git a/test/functional/messages/numeric_urls.eml b/test/functional/messages/numeric_urls.eml
new file mode 100644 (file)
index 0000000..139a52c
--- /dev/null
@@ -0,0 +1,3 @@
+Content-type: text/plain\r
+\r
+numeric http://1.2.3.4 and not http://example.org ok\r