]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_magic: Improve hyperscan usage
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Sep 2019 08:26:04 +0000 (09:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 24 Sep 2019 08:26:04 +0000 (09:26 +0100)
lualib/lua_magic/heuristics.lua
lualib/lua_magic/init.lua

index 04c89ba6996f6ba3061802ed13645e3c4f74ea22..8fb83bb0d619a6a986c262112bae0ec6e359092a 100644 (file)
@@ -95,7 +95,10 @@ local function compile_tries()
       end
     end
 
-    return rspamd_trie.create(strs, rspamd_trie.flags.re)
+    local compile_flags = bit.bor(rspamd_trie.flags.re, rspamd_trie.flags.dot_all)
+    compile_flags = bit.bor(compile_flags, rspamd_trie.flags.single_match)
+    compile_flags = bit.bor(compile_flags, rspamd_trie.flags.no_start)
+    return rspamd_trie.create(strs, compile_flags)
   end
 
   if not msoffice_trie then
index 2fb848707e9f02aa77d542406315655e4330cb60..d92980246d09a5ce5a8b39551cc791cd05a61353 100644 (file)
@@ -126,18 +126,21 @@ local function process_patterns(log_obj)
         end
       end
     end
-
+    local bit = require "bit"
+    local compile_flags = bit.bor(rspamd_trie.flags.re, rspamd_trie.flags.dot_all)
+    compile_flags = bit.bor(compile_flags, rspamd_trie.flags.single_match)
+    compile_flags = bit.bor(compile_flags, rspamd_trie.flags.no_start)
     compiled_patterns = rspamd_trie.create(fun.totable(
         fun.map(function(t) return t[1] end, processed_patterns)),
-        rspamd_trie.flags.re
+        compile_flags
     )
     compiled_short_patterns = rspamd_trie.create(fun.totable(
         fun.map(function(t) return t[1] end, short_patterns)),
-        rspamd_trie.flags.re
+        compile_flags
     )
     compiled_tail_patterns = rspamd_trie.create(fun.totable(
         fun.map(function(t) return t[1] end, tail_patterns)),
-        rspamd_trie.flags.re
+        compile_flags
     )
 
     lua_util.debugm(N, log_obj,