commit 1795539: rules/headers_checks.lua: add [ENV]FROM_INVALID

Jan Smutny js at excello.cz
Sun Apr 26 20:21:08 UTC 2020


Author: Jan Smutny
Date: 2020-04-19 00:20:32 +0200
URL: https://github.com/rspamd/rspamd/commit/17955398297ab00f27aaa4f9f5efba7be096dbb5 (refs/pull/3346/head)

rules/headers_checks.lua: add [ENV]FROM_INVALID

---
 rules/headers_checks.lua | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua
index 9ceb60188..6c5489822 100644
--- a/rules/headers_checks.lua
+++ b/rules/headers_checks.lua
@@ -626,7 +626,13 @@ local check_from_id = rspamd_config:register_symbol{
   callback = function(task)
     local envfrom = task:get_from(1)
     local from = task:get_from(2)
+    if (envfrom and envfrom[1] and not envfrom[1]["flags"]["valid"]) then
+      task:insert_result('ENVFROM_INVALID', 1.0)
+    end
     if (from and from[1]) then
+      if not (from[1]["flags"]["valid"]) then
+        task:insert_result('FROM_INVALID', 1.0)
+      end
       if (from[1].name == nil or from[1].name == '' ) then
         task:insert_result('FROM_NO_DN', 1.0)
       elseif (from[1].name and
@@ -672,6 +678,22 @@ local check_from_id = rspamd_config:register_symbol{
   end
 }
 
+rspamd_config:register_symbol{
+  name = 'ENVFROM_INVALID',
+  score = 2.0,
+  group = 'headers',
+  parent = check_from_id,
+  type = 'virtual',
+  description = 'Envelope from does not have a valid format',
+}
+rspamd_config:register_symbol{
+  name = 'FROM_INVALID',
+  score = 2.0,
+  group = 'headers',
+  parent = check_from_id,
+  type = 'virtual',
+  description = 'From header does not have a valid format',
+}
 rspamd_config:register_symbol{
   name = 'FROM_NO_DN',
   score = 0.0,


More information about the Commits mailing list