commit d9f3f32: [Minor] Add some mime only rules

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jan 7 16:14:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-01-07 15:41:23 +0000
URL: https://github.com/rspamd/rspamd/commit/d9f3f32336c7b8b063359c6d54a99e07dbead766

[Minor] Add some mime only rules

---
 rules/headers_checks.lua | 30 ++++++++++++++++++++----------
 rules/mid.lua            |  2 +-
 rules/misc.lua           | 31 +++++++++++++++++++++----------
 rules/subject_checks.lua |  2 ++
 4 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua
index 5dc78063a..353690b56 100644
--- a/rules/headers_checks.lua
+++ b/rules/headers_checks.lua
@@ -25,7 +25,7 @@ local E = {}
 
 local rcvd_cb_id = rspamd_config:register_symbol{
   name = 'CHECK_RECEIVED',
-  type = 'callback',
+  type = 'callback,mime',
   score = 0.0,
   group = 'headers',
   callback = function(task)
@@ -114,7 +114,7 @@ rspamd_config:register_symbol{
 
 local prio_cb_id = rspamd_config:register_symbol {
   name = 'HAS_X_PRIO',
-  type = 'callback',
+  type = 'callback,mime',
   score = 0.0,
   group = 'headers',
   callback = function (task)
@@ -185,7 +185,7 @@ local function get_raw_header(task, name)
 end
 
 local check_replyto_id = rspamd_config:register_symbol({
-  type = 'callback',
+  type = 'callback,mime',
   name = 'CHECK_REPLYTO',
   score = 0.0,
   group = 'headers',
@@ -333,7 +333,7 @@ rspamd_config:register_dependency('CHECK_REPLYTO', 'CHECK_FROM')
 
 local check_mime_id = rspamd_config:register_symbol{
   name = 'CHECK_MIME',
-  type = 'callback',
+  type = 'callback,mime',
   group = 'headers',
   score = 0.0,
   callback = function(task)
@@ -575,6 +575,7 @@ rspamd_config.MISSING_FROM = {
     return false
   end,
   score = 2.0,
+  type = 'mime',
   group = 'headers',
   description = 'Missing From: header'
 }
@@ -596,6 +597,7 @@ rspamd_config.MULTIPLE_FROM = {
   end,
   score = 9.0,
   group = 'headers',
+  type = 'mime',
   description = 'Multiple addresses in From'
 }
 
@@ -607,6 +609,7 @@ rspamd_config.MV_CASE = {
   description = 'Mime-Version .vs. MIME-Version',
   score = 0.5,
   group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.FAKE_REPLY = {
@@ -621,12 +624,13 @@ rspamd_config.FAKE_REPLY = {
   end,
   description = 'Fake reply',
   score = 1.0,
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 local check_from_id = rspamd_config:register_symbol{
   name = 'CHECK_FROM',
-  type = 'callback',
+  type = 'callback,mime',
   score = 0.0,
   group = 'headers',
   callback = function(task)
@@ -753,7 +757,7 @@ local check_to_cc_id = rspamd_config:register_symbol{
   name = 'CHECK_TO_CC',
   type = 'callback',
   score = 0.0,
-  group = 'headers',
+  group = 'headers,mime',
   callback = function(task)
     local rcpts = task:get_recipients(1)
     local to = task:get_recipients(2)
@@ -976,6 +980,7 @@ rspamd_config.CTYPE_MISSING_DISPOSITION = {
   end,
   description = 'Binary content-type not specified as an attachment',
   score = 4.0,
+  type = 'mime',
   group = 'headers'
 }
 
@@ -1004,6 +1009,7 @@ rspamd_config.CTYPE_MIXED_BOGUS = {
   end,
   description = 'multipart/mixed without non-textual part',
   score = 1.0,
+  type = 'mime',
   group = 'headers'
 }
 
@@ -1040,7 +1046,8 @@ rspamd_config.MIME_BASE64_TEXT = {
   end,
   description = 'Has text part encoded in base64',
   score = 0.1,
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 local function is_8bit_addr(addr)
@@ -1061,7 +1068,8 @@ rspamd_config.INVALID_FROM_8BIT = {
   end,
   description = 'Invalid 8bit character in From header',
   score = 6.0,
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.INVALID_RCPT_8BIT = {
@@ -1076,7 +1084,8 @@ rspamd_config.INVALID_RCPT_8BIT = {
   end,
   description = 'Invalid 8bit character in recipients headers',
   score = 6.0,
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.XM_CASE = {
@@ -1087,4 +1096,5 @@ rspamd_config.XM_CASE = {
   description = 'X-mailer .vs. X-Mailer',
   score = 0.5,
   group = 'headers',
+  type = 'mime',
 }
diff --git a/rules/mid.lua b/rules/mid.lua
index b04a8bb46..b74ff13df 100644
--- a/rules/mid.lua
+++ b/rules/mid.lua
@@ -71,7 +71,7 @@ local check_mid_id = rspamd_config:register_symbol({
   name = 'CHECK_MID',
   score = 0.0,
   group = 'mid',
-  type = 'callback',
+  type = 'callback,mime',
   callback = mid_check_func
 })
 rspamd_config:register_virtual_symbol('MID_BARE_IP', 1.0, check_mid_id)
diff --git a/rules/misc.lua b/rules/misc.lua
index 3494d26ca..f6d1c81b9 100644
--- a/rules/misc.lua
+++ b/rules/misc.lua
@@ -65,7 +65,8 @@ rspamd_config.MISSING_DATE = {
   end,
   score = 1.0,
   description = 'Message date is missing',
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.DATE_IN_FUTURE = {
@@ -80,7 +81,8 @@ rspamd_config.DATE_IN_FUTURE = {
   end,
   score = 4.0,
   description = 'Message date is in future',
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.DATE_IN_PAST = {
@@ -95,7 +97,8 @@ rspamd_config.DATE_IN_PAST = {
   end,
   score = 1.0,
   description = 'Message date is in past',
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.R_SUSPICIOUS_URL = {
@@ -157,7 +160,8 @@ rspamd_config.ENVFROM_PRVS = {
   end,
   score = 0.0,
   description = "Envelope From is a PRVS address that matches the From address",
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 rspamd_config.ENVFROM_VERP = {
@@ -185,7 +189,8 @@ rspamd_config.ENVFROM_VERP = {
   end,
   score = 0.0,
   description = "Envelope From is a VERP address",
-  group = "headers"
+  group = "headers",
+  type = 'mime',
 }
 
 local check_rcvd = rspamd_config:register_symbol{
@@ -224,7 +229,8 @@ local check_rcvd = rspamd_config:register_symbol{
     if auth then
       task:insert_result('RCVD_VIA_SMTP_AUTH', 1.0)
     end
-  end
+  end,
+  type = 'callback,mime',
 }
 
 rspamd_config:register_symbol{
@@ -282,6 +288,7 @@ rspamd_config.RCVD_HELO_USER = {
   end,
   description = 'HELO User spam pattern',
   group = 'headers',
+  type = 'mime',
   score = 3.0
 }
 
@@ -415,6 +422,7 @@ rspamd_config.URL_IN_SUBJECT = {
   end,
   score = 4.0,
   group = 'subject',
+  type = 'mime',
   description = 'URL found in Subject'
 
 }
@@ -486,7 +494,7 @@ rspamd_config:register_symbol{
 }
 
 local check_from_display_name = rspamd_config:register_symbol{
-  type = 'callback',
+  type = 'callback,mime',
   name = 'FROM_DISPLAY_CALLBACK',
   callback = function (task)
     local from = task:get_from(2)
@@ -582,6 +590,7 @@ rspamd_config.SPOOF_REPLYTO = {
     return false
   end,
   group = 'headers',
+  type = 'mime',
   description = 'Reply-To is being used to spoof and trick the recipient to send an off-domain reply',
   score = 6.0
 }
@@ -607,7 +616,8 @@ rspamd_config.INFO_TO_INFO_LU = {
   end,
   description = 'info@ From/To address with List-Unsubscribe headers',
   group = 'headers',
-  score = 2.0
+  score = 2.0,
+  type = 'mime',
 }
 
 -- Detects bad content-transfer-encoding for text parts
@@ -639,7 +649,8 @@ rspamd_config.R_BAD_CTE_7BIT = {
   end,
   score = 3.5,
   description = 'Detects bad content-transfer-encoding for text parts',
-  group = 'headers'
+  group = 'headers',
+  type = 'mime',
 }
 
 
@@ -696,7 +707,7 @@ local check_encrypted_name = rspamd_config:register_symbol{
   end,
   score = 10.0,
   description = 'Bogus mix of encrypted and text/html payloads',
-  group = 'mime_types'
+  group = 'mime_types',
 }
 
 rspamd_config:register_symbol{
diff --git a/rules/subject_checks.lua b/rules/subject_checks.lua
index d5760ed25..c1492815f 100644
--- a/rules/subject_checks.lua
+++ b/rules/subject_checks.lua
@@ -52,6 +52,7 @@ rspamd_config.SUBJ_ALL_CAPS = {
   end,
   score = 3.0,
   group = 'subject',
+  type = 'mime',
   description = 'All capital letters in subject'
 }
 
@@ -64,5 +65,6 @@ rspamd_config.LONG_SUBJ = {
   end,
   score = 3.0,
   group = 'subject',
+  type = 'mime',
   description = 'Subject is too long'
 }
\ No newline at end of file


More information about the Commits mailing list