]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Fix for random monitored
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 16 Jan 2022 20:20:34 +0000 (20:20 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 16 Jan 2022 20:20:34 +0000 (20:20 +0000)
Reported by: @moisseev

lualib/plugins/rbl.lua
src/plugins/lua/rbl.lua

index 973ba33c7640b85bde310272df573aa0eb514568..2b0630164f789d77d8a18c054cd2c0e7bc987da8 100644 (file)
@@ -109,6 +109,7 @@ local rule_schema_tbl = {
   monitored_address = ts.string:is_optional(),
   no_ip = ts.boolean:is_optional(),
   process_script = ts.string:is_optional(),
+  random_monitored = ts.boolean:is_optional(),
   rbl = ts.string,
   rdns = ts.boolean:is_optional(),
   received = ts.boolean:is_optional(),
index 22305aa1f67a25318710b6cc5c84f440c5b969fa..49b67221f044a9648f1e9fb21dd0e67179fb2ede 100644 (file)
@@ -48,12 +48,18 @@ local url_flag_bits = rspamd_url.flags
 
 local function get_monitored(rbl)
   local function is_random_monitored()
-    return (rbl.dkim
-        or rbl.urls
-        or rbl.emails
-        or rbl.no_ip
-        or rbl.rdns
-        or rbl.helo)
+    -- Explicit definition
+    if type(rbl.random_monitored) == 'boolean' then
+      return rbl.random_monitored
+    end
+
+    -- We check 127.0.0.1 for merely RBLs with `from` or `received` and only if
+    -- they don't have `no_ip` attribute at the same time
+    --
+    -- Convert to a boolean variable using the common idiom
+    return (not (rbl.from or rbl.received)
+        or rbl.no_ip)
+        and true or false
   end
 
   local default_monitored = '1.0.0.127'