]> source.dussan.org Git - rspamd.git/commitdiff
[FIX] lua_scanners - duplicated fail symbol + luastyle
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Sun, 13 Jan 2019 16:55:24 +0000 (17:55 +0100)
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Sun, 13 Jan 2019 16:55:24 +0000 (17:55 +0100)
lualib/lua_scanners/oletools.lua
src/plugins/lua/antivirus.lua
src/plugins/lua/external_services.lua

index 814fe368e605a1a23b5ddc5b6a60da9b870e17e1..6e1a0fcc17829f38796ad18ee57cbcffc21121a4 100644 (file)
@@ -257,7 +257,7 @@ local function oletools_config(opts)
     oletools_conf.default_port)
 
   if oletools_conf.upstreams then
-    lua_util.add_debug_alias('antivirus', oletools_conf.module_name)
+    lua_util.add_debug_alias('external_services', oletools_conf.module_name)
     return oletools_conf
   end
 
index 5ce6dfe06fbbfabda79abecee385ccdb853b1cf1..0dde3e217b751372e874d852433f289765362fee 100644 (file)
@@ -70,29 +70,29 @@ end
 
 
 local function add_antivirus_rule(sym, opts)
-  if not opts['type'] then
+  if not opts.type then
     rspamd_logger.errx(rspamd_config, 'unknown type for AV rule %s', sym)
     return nil
   end
 
-  if not opts['symbol'] then opts['symbol'] = sym:upper() end
-  local cfg = lua_antivirus[opts['type']]
+  if not opts.symbol then opts.symbol = sym:upper() end
+  local cfg = lua_antivirus[opts.type]
 
   if not cfg then
     rspamd_logger.errx(rspamd_config, 'unknown antivirus type: %s',
-        opts['type'])
+        opts.type)
     return nil
   end
 
-  if not opts['symbol_fail'] then
-    opts['symbol_fail'] = string.upper(opts['type']) .. '_FAIL'
+  if not opts.symbol_fail then
+    opts.symbol_fail = opts.symbol .. '_FAIL'
   end
 
   -- WORKAROUND for deprecated attachments_only
-  if opts['attachments_only'] ~= nil then
-    opts['scan_mime_parts'] = opts['attachments_only']
+  if opts.attachments_only ~= nil then
+    opts.scan_mime_parts = opts.attachments_only
     rspamd_logger.warnx(rspamd_config, '%s [%s]: Using attachments_only is deprecated. '..
-     'Please use scan_mime_parts = %s instead', opts['symbol'], opts['type'], opts['attachments_only'])
+     'Please use scan_mime_parts = %s instead', opts.symbol, opts.type, opts.attachments_only)
   end
   -- WORKAROUND for deprecated attachments_only
 
@@ -103,14 +103,14 @@ local function add_antivirus_rule(sym, opts)
 
   if not rule then
     rspamd_logger.errx(rspamd_config, 'cannot configure %s for %s',
-      opts['type'], opts['symbol'])
+      opts.type, opts.symbol)
     return nil
   end
 
   rule.patterns = common.create_regex_table(opts.patterns or {})
 
-  if opts['whitelist'] then
-    rule['whitelist'] = rspamd_config:add_hash_map(opts['whitelist'])
+  if opts.whitelist then
+    rule.whitelist = rspamd_config:add_hash_map(opts.whitelist)
   end
 
   return function(task)
index fb7aef7094203ba7d3c275b84a59e1c6b0e1d37a..8e101ab9ad6c0073c3bb7162b63e85ffb52bdb59 100644 (file)
@@ -112,22 +112,22 @@ end
 
 
 local function add_scanner_rule(sym, opts)
-  if not opts['type'] then
+  if not opts.type then
     rspamd_logger.errx(rspamd_config, 'unknown type for external scanner rule %s', sym)
     return nil
   end
 
-  if not opts['symbol'] then opts['symbol'] = sym:upper() end
-  local cfg = lua_scanners[opts['type']]
+  if not opts.symbol then opts.symbol = sym:upper() end
+  local cfg = lua_scanners[opts.type]
 
   if not cfg then
     rspamd_logger.errx(rspamd_config, 'unknown external scanner type: %s',
-        opts['type'])
+        opts.type)
     return nil
   end
 
-  if not opts['symbol_fail'] then
-    opts['symbol_fail'] = string.upper(opts['type']) .. '_FAIL'
+  if not opts.symbol_fail then
+    opts.symbol_fail = opts.symbol .. '_FAIL'
   end
 
   local rule = cfg.configure(opts)
@@ -137,7 +137,7 @@ local function add_scanner_rule(sym, opts)
 
   if not rule then
     rspamd_logger.errx(rspamd_config, 'cannot configure %s for %s',
-      opts['type'], opts['symbol'])
+      opts.type, opts.symbol)
     return nil
   end
 
@@ -153,8 +153,8 @@ local function add_scanner_rule(sym, opts)
 
   rule.mime_parts_filter_ext = common.create_regex_table(opts.mime_parts_filter_ext or {})
 
-  if opts['whitelist'] then
-    rule['whitelist'] = rspamd_config:add_hash_map(opts['whitelist'])
+  if opts.whitelist then
+    rule.whitelist = rspamd_config:add_hash_map(opts.whitelist)
   end
 
   return function(task)