]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix tests failures
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 15 Nov 2025 14:30:50 +0000 (14:30 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 15 Nov 2025 14:30:50 +0000 (14:30 +0000)
src/plugins/lua/url_suspect.lua
test/functional/cases/001_merged/400_url_suspect.robot
test/functional/messages/url_suspect_long_user.eml
test/functional/messages/url_suspect_numeric_ip.eml
test/functional/messages/url_suspect_numeric_ip_user.eml
test/functional/messages/url_suspect_very_long_user.eml

index 95bcda35949ce8c6091dda951cd1026b4b9671ae..49e4625193a5db53e39d4d15cdbd912ad7d1e41c 100644 (file)
@@ -478,15 +478,34 @@ end
 
 -- Main callback
 local function url_suspect_callback(task)
-  -- Get URLs with suspicious flags (using existing flags)
-  local suspect_urls = task:get_urls_filtered(settings.process_flags)
+  local suspect_urls
+
+  -- Determine if we need to check all URLs or just flagged ones
+  -- TLD and structure checks don't have corresponding URL flags, so need all URLs
+  local need_all_urls = (
+      (settings.checks.tld and settings.checks.tld.enabled) or
+      (settings.checks.structure and settings.checks.structure.enabled and
+          (settings.checks.structure.check_multiple_at or
+              settings.checks.structure.check_excessive_dots or
+              settings.checks.structure.check_length))
+  )
+
+  if need_all_urls then
+    -- Get all URLs (more expensive, but necessary for TLD/structure checks)
+    suspect_urls = task:get_urls(true) -- true = include emails
+    lua_util.debugm(N, task, "Processing all %s URLs (TLD/structure checks enabled)",
+        suspect_urls and #suspect_urls or 0)
+  else
+    -- Get only URLs with suspicious flags (faster)
+    suspect_urls = task:get_urls_filtered(settings.process_flags)
+    lua_util.debugm(N, task, "Processing %s flagged URLs",
+        suspect_urls and #suspect_urls or 0)
+  end
 
   if not suspect_urls or #suspect_urls == 0 then
     return false
   end
 
-  lua_util.debugm(N, task, "Processing %s URLs with suspicious flags", #suspect_urls)
-
   local total_findings = 0
 
   for _, url in ipairs(suspect_urls) do
index da469d94acb023a948b838a493bb1520c6401b9f..bb218467ac6ddf84b31e041e41844e6991cbc49f 100644 (file)
@@ -8,7 +8,7 @@ Variables       ${RSPAMD_TESTDIR}/lib/vars.py
 URL Suspect - Issue 5731 - Long User Field
   # Test that URLs with oversized user fields are parsed and scored
   Scan File  ${RSPAMD_TESTDIR}/messages/url_suspect_long_user.eml
-  Expect Symbol With Exact Options  URL_USER_LONG  80
+  Expect Symbol With Exact Options  URL_USER_LONG  129
   Do Not Expect Symbol  URL_USER_VERY_LONG
   # Should also generate R_SUSPICIOUS_URL for backward compatibility
   Expect Symbol  R_SUSPICIOUS_URL
index cb8b523bd225a234cd637ec3307b7fd9e3fca379..3b3c9191ac82d3ff418573cbcb43ea34778a2aff 100644 (file)
@@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8
 <html>
 <body>
 <p>Click this link:</p>
-<a href="https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@phishing.com/page">Click Here</a>
+<a href="https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@phishing.com/page">Click Here</a>
 </body>
 </html>
index 77de02102eabf446cae1b5533303e594ffb8b97e..26b88bb4ca9b822b0a08c62ca1d091f118568508 100644 (file)
@@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8
 <html>
 <body>
 <p>Click this link:</p>
-<a href="http://192.168.1.100/phishing">Click Here</a>
+<a href="http://203.0.113.42/phishing">Click Here</a>
 </body>
 </html>
index 8718e8330d8b66a6ee6c9fcde1af68ae12a50e50..bf25d2c974c70c44103bccca00ab61a16b5bb47d 100644 (file)
@@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8
 <html>
 <body>
 <p>Click this link:</p>
-<a href="http://admin@192.168.1.100/phishing">Click Here</a>
+<a href="http://admin@203.0.113.42/phishing">Click Here</a>
 </body>
 </html>
index 5791ddc155c8dfbba6c9d64f17c38c50114d0179..795945941de10dc90a9cde6b90f85f0192240794 100644 (file)
@@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8
 <html>
 <body>
 <p>Click this link:</p>
-<a href="https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@phishing.com/page">Click Here</a>
+<a href="https://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX@phishing.com/page">Click Here</a>
 </body>
 </html>