From 6e86f3959dca8e633fad20844f38a86254f664c1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 15 Nov 2025 14:30:50 +0000 Subject: [PATCH] [Fix] Fix tests failures --- src/plugins/lua/url_suspect.lua | 27 ++++++++++++++++--- .../cases/001_merged/400_url_suspect.robot | 2 +- .../messages/url_suspect_long_user.eml | 2 +- .../messages/url_suspect_numeric_ip.eml | 2 +- .../messages/url_suspect_numeric_ip_user.eml | 2 +- .../messages/url_suspect_very_long_user.eml | 2 +- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/plugins/lua/url_suspect.lua b/src/plugins/lua/url_suspect.lua index 95bcda3594..49e4625193 100644 --- a/src/plugins/lua/url_suspect.lua +++ b/src/plugins/lua/url_suspect.lua @@ -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 diff --git a/test/functional/cases/001_merged/400_url_suspect.robot b/test/functional/cases/001_merged/400_url_suspect.robot index da469d94ac..bb218467ac 100644 --- a/test/functional/cases/001_merged/400_url_suspect.robot +++ b/test/functional/cases/001_merged/400_url_suspect.robot @@ -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 diff --git a/test/functional/messages/url_suspect_long_user.eml b/test/functional/messages/url_suspect_long_user.eml index cb8b523bd2..3b3c9191ac 100644 --- a/test/functional/messages/url_suspect_long_user.eml +++ b/test/functional/messages/url_suspect_long_user.eml @@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8

Click this link:

-Click Here +Click Here diff --git a/test/functional/messages/url_suspect_numeric_ip.eml b/test/functional/messages/url_suspect_numeric_ip.eml index 77de02102e..26b88bb4ca 100644 --- a/test/functional/messages/url_suspect_numeric_ip.eml +++ b/test/functional/messages/url_suspect_numeric_ip.eml @@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8

Click this link:

-Click Here +Click Here diff --git a/test/functional/messages/url_suspect_numeric_ip_user.eml b/test/functional/messages/url_suspect_numeric_ip_user.eml index 8718e8330d..bf25d2c974 100644 --- a/test/functional/messages/url_suspect_numeric_ip_user.eml +++ b/test/functional/messages/url_suspect_numeric_ip_user.eml @@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8

Click this link:

-Click Here +Click Here diff --git a/test/functional/messages/url_suspect_very_long_user.eml b/test/functional/messages/url_suspect_very_long_user.eml index 5791ddc155..795945941d 100644 --- a/test/functional/messages/url_suspect_very_long_user.eml +++ b/test/functional/messages/url_suspect_very_long_user.eml @@ -6,6 +6,6 @@ Content-Type: text/html; charset=utf-8

Click this link:

-Click Here +Click Here -- 2.47.3