]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add SUBJ_ALL_CAPS rule
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 26 Nov 2015 15:30:23 +0000 (15:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 26 Nov 2015 15:30:23 +0000 (15:30 +0000)
rules/misc.lua

index f423d014e970ec91593d7077f3d0c003f6d72990..256255145a7d69534f37f7e507b919a0222a0105 100644 (file)
@@ -27,11 +27,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -- This is main lua config file for rspamd
 
 local util = require "rspamd_util"
+local rspamd_regexp = require "rspamd_regexp"
+local rspamd_logger = require "rspamd_logger"
 
 local reconf = config['regexp']
 
-
 -- Uncategorized rules
+local subject_re = rspamd_regexp.create('/^(?:(?:Re|Fwd|Fw|Aw|Antwort|Sv):\\s*)+(.+)$/i')
 
 -- Local rules
 local r_bgcolor = '/BGCOLOR=/iP'
@@ -109,3 +111,25 @@ rspamd_config.R_SUSPICIOUS_URL = {
   one_shot = true,
   description = 'Obfusicated or suspicious URL has been found in a message'
 }
+
+rspamd_config.SUBJ_ALL_CAPS = {
+  callback = function(task)
+    local sbj = task:get_header('Subject')
+
+    if sbj then
+      local stripped_subject = subject_re:search(sbj, false, true)
+      if stripped_subject and stripped_subject[1] and stripped_subject[1][2] then
+        sbj = stripped_subject[1][2]
+      end
+
+      if util.is_uppercase(sbj) then
+        return true
+      end
+    end
+
+    return false
+  end,
+  score = 3.0,
+  group = 'headers',
+  description = 'All capital letters in subject'
+}