]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] correct logic error in milter_headers.lua: skip_wanted() 5496/head
authorClaudiu Dragalina-Paraipan <dr.clau@gmail.com>
Thu, 5 Jun 2025 18:40:07 +0000 (21:40 +0300)
committerClaudiu Dragalina-Paraipan <dr.clau@gmail.com>
Thu, 5 Jun 2025 18:40:07 +0000 (21:40 +0300)
- fix logic error in skip_wanted()
- add new functional test for this scenario
- add override settings in milter_headers.conf to support the testing
- add supporting functionality in rspamd.robot

src/plugins/lua/milter_headers.lua
test/functional/cases/550_milter_headers.robot
test/functional/configs/milter_headers.conf
test/functional/lib/rspamd.robot

index 2daeeed782cdb3add044c6f9342800e1710f31b3..17fc9056236401b7ab88c6a7244b326b389f6194 100644 (file)
@@ -138,7 +138,7 @@ local function milter_headers(task)
 
   local function skip_wanted(hdr)
     if settings_override then
-      return true
+      return false
     end
     -- Normal checks
     local function match_extended_headers_rcpt()
index 80471b83c44e9b9e5ea6140da994ccdbfcf486c9..c0965971477262cc90a809c8e2cd6b26cd2d41e4 100644 (file)
@@ -37,3 +37,14 @@ CHECK HEADERS WITHOUT TEST SYMBOL
   # Check X-Spam-Level header
   Do Not Expect Added Header  X-Spam-Level
   Expect Removed Header  X-Spam-Level
+
+CHECK HEADERS WITH OVERRIDE SETTINGS
+  # id_milter_headers_override setting enables only authentication-results and x-spam-level routines
+  Scan File  ${MESSAGE}  Settings-Id=id_milter_headers_override
+  # Test the milter_headers override behavior
+  # Check that Authentication-Results and X-Spam-Level headers are present (exact values are not important)
+  Expect Header Is Present  Authentication-Results
+  Expect Header Is Present  X-Spam-Level
+  # Verify other headers are not added since only authentication-results and x-spam-level routines run
+  Do Not Expect Added Header  X-Virus
+  Do Not Expect Added Header  My-Spamd-Bar
index 947bc28ddb844fa8d0d08973191f50ec99b7ce92..502747605861a6761617c6adaaca275c0c9cf917 100644 (file)
@@ -22,3 +22,15 @@ milter_headers {
   }
 
 }
+
+settings {
+  id_milter_headers_override {
+    apply {
+      plugins {
+        milter_headers {
+          routines = [ authentication-results, x-spam-level ];
+        }
+      }
+    }
+  }
+}
index 9c30a97dba0680318b5e7b6a932360c550db1e35..5d23e3cebbf928e47dba6e10226c5e67b52e08a7 100644 (file)
@@ -120,6 +120,15 @@ Expect Added Header
   Should Be Equal  ${SCAN_RESULT}[milter][add_headers][${header_name}][value]  ${header_value}
   Should Be Equal as Numbers  ${SCAN_RESULT}[milter][add_headers][${header_name}][order]  ${pos}
 
+Expect Header Is Present
+  [Arguments]  ${header_name}
+  Dictionary Should Contain Key  ${SCAN_RESULT}  milter
+  ...  msg=milter block was not present in protocol response
+  Dictionary Should Contain Key  ${SCAN_RESULT}[milter]  add_headers
+  ...  msg=add_headers block was not present in protocol response
+  Dictionary Should Contain Key  ${SCAN_RESULT}[milter][add_headers]  ${header_name}
+  ...  msg=${header_name} was not added
+
 Expect Email
   [Arguments]  ${email}
   List Should Contain Value  ${SCAN_RESULT}[emails]  ${email}