]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] lua_scanners - fix symbol registration
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Fri, 15 Jan 2021 16:49:25 +0000 (17:49 +0100)
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Thu, 18 Mar 2021 08:36:42 +0000 (09:36 +0100)
src/plugins/lua/antivirus.lua
src/plugins/lua/external_services.lua

index 5d7268b06ec3dfee742f1c91f8b940eeec997d26..0dad933b9491bb936e0f72ad6dada1ef426d8bb6 100644 (file)
@@ -231,6 +231,38 @@ if opts and type(opts) == 'table' then
             end
           end
         end
+        if type(m['patterns_fail']) == 'table' then
+          if m['patterns_fail'][1] then
+            for _, p in ipairs(m['patterns_fail']) do
+              if type(p) == 'table' then
+                for sym in pairs(p) do
+                  rspamd_logger.debugm(N, rspamd_config, 'registering: %1', {
+                    type = 'virtual',
+                    name = sym,
+                    parent = m['symbol'],
+                    parent_id = id,
+                    group = N
+                  })
+                  rspamd_config:register_symbol({
+                    type = 'virtual',
+                    name = sym,
+                    parent = id,
+                    group = N
+                  })
+                end
+              end
+            end
+          else
+            for sym in pairs(m['patterns_fail']) do
+              rspamd_config:register_symbol({
+                type = 'virtual',
+                name = sym,
+                parent = id,
+                group = N
+              })
+            end
+          end
+        end        
         if m['score'] then
           -- Register metric symbol
           local description = 'antivirus symbol'
index 37665378cd4e6376dfb2a366b26834e9cb9b3d1e..2dd55e3605eb85a980e8a8235aa798497880e865 100644 (file)
@@ -142,6 +142,12 @@ local function add_scanner_rule(sym, opts)
   if not rule.symbol_fail then
     rule.symbol_fail = rule.symbol .. '_FAIL'
   end
+  if not rule.symbol_encrypted then
+    rule.symbol_encrypted = rule.symbol .. '_ENCRYPTED'
+  end
+  if not rule.symbol_macro then
+    rule.symbol_macro = rule.symbol .. '_MACRO'
+  end
 
   rule.redis_params = redis_params
 
@@ -283,7 +289,37 @@ if opts and type(opts) == 'table' then
             end
           end
         end
-
+        if type(m['patterns_fail']) == 'table' then
+          if m['patterns_fail'][1] then
+            for _, p in ipairs(m['patterns_fail']) do
+              if type(p) == 'table' then
+                for sym in pairs(p) do
+                  rspamd_logger.debugm(N, rspamd_config, 'registering: %1', {
+                    type = 'virtual',
+                    name = sym,
+                    parent = m['symbol'],
+                    parent_id = id,
+                  })
+                  rspamd_config:register_symbol({
+                    type = 'virtual',
+                    name = sym,
+                    parent = id,
+                    group = N
+                  })
+                end
+              end
+            end
+          else
+            for sym in pairs(m['patterns_fail']) do
+              rspamd_config:register_symbol({
+                type = 'virtual',
+                name = sym,
+                parent = id,
+                group = N
+              })
+            end
+          end
+        end
         if m.symbols then
           local function reg_symbols(tbl)
             for _,sym in pairs(tbl) do