Selaa lähdekoodia

[Minor] Lua_magic: Improve hyperscan usage

tags/2.0
Vsevolod Stakhov 4 vuotta sitten
vanhempi
commit
b32d6cde09
2 muutettua tiedostoa jossa 11 lisäystä ja 5 poistoa
  1. 4
    1
      lualib/lua_magic/heuristics.lua
  2. 7
    4
      lualib/lua_magic/init.lua

+ 4
- 1
lualib/lua_magic/heuristics.lua Näytä tiedosto

@@ -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

+ 7
- 4
lualib/lua_magic/init.lua Näytä tiedosto

@@ -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,

Loading…
Peruuta
Tallenna