commit 8a54488: [Rules] Add raw addresses to MULTIPLE_FROM options

Anton Yuzhaninov citrin+git at citrin.ru
Wed Apr 28 11:35:05 UTC 2021


Author: Anton Yuzhaninov
Date: 2021-04-27 16:50:04 +0100
URL: https://github.com/rspamd/rspamd/commit/8a5448883ef9eb62ce169acdd2729f5b4ff6ad2d (refs/pull/3733/head)

[Rules] Add raw addresses to MULTIPLE_FROM options
It is confusing to have MULTIPLE_FROM with a single address in options,
which happens if one of addresses is empty - usually because of
misplaces <>.  While here simplify condition.

---
 rules/headers_checks.lua              | 11 ++---------
 test/functional/cases/280_rules.robot |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua
index 79b8e5c2f..f0f64daff 100644
--- a/rules/headers_checks.lua
+++ b/rules/headers_checks.lua
@@ -576,15 +576,8 @@ rspamd_config.MISSING_FROM = {
 rspamd_config.MULTIPLE_FROM = {
   callback = function(task)
     local from = task:get_from('mime')
-    if from and from[1] then
-      if #from > 1 then
-        return true,1.0,table.concat(
-            fun.totable(
-                fun.map(function(a) return a.addr end,
-                    fun.filter(function(a) return a.addr and a.addr ~= '' end,
-                        from))),
-            ',')
-      end
+    if from and from[2] then
+      return true, 1.0, fun.totable(fun.map(function(a) return a.raw end, from))
     end
     return false
   end,
diff --git a/test/functional/cases/280_rules.robot b/test/functional/cases/280_rules.robot
index 3d99db84d..5bab11016 100644
--- a/test/functional/cases/280_rules.robot
+++ b/test/functional/cases/280_rules.robot
@@ -86,7 +86,7 @@ FROM_NEQ_ENVFROM
 
 PHISH_SENDER_A
   Scan File  ${TESTDIR}/messages/phish_sender.eml
-  Expect Symbol With Score And Exact Options  MULTIPLE_FROM  9.0  any at attack.com,admin at legitimate.com
+  Expect Symbol With Score And Exact Options  MULTIPLE_FROM  9.0  <any at attack.com>  <admin at legitimate.com>
   Expect Symbol With Score And Exact Options  MULTIPLE_UNIQUE_HEADERS  7.0  From
 
 PHISH_SENDER_B


More information about the Commits mailing list