]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Enable Mime part filters on antivirus module
authorjonmoesli <jonathan.moesli@yahoo.com>
Mon, 7 Nov 2022 17:20:35 +0000 (18:20 +0100)
committerjonmoesli <jonathan.moesli@yahoo.com>
Mon, 7 Nov 2022 17:20:35 +0000 (18:20 +0100)
src/plugins/lua/antivirus.lua

index 968b24adc83002c19ed7bde714c467f88056164b..39d11c8ec14126d574b83b87918da31c430b6b8c 100644 (file)
@@ -134,6 +134,21 @@ local function add_antivirus_rule(sym, opts)
         type = 'string',
       })
 
+  -- if any mime_part filter defined, do not scan all attachments
+  if opts.mime_parts_filter_regex ~= nil
+      or opts.mime_parts_filter_ext ~= nil then
+    rule.scan_all_mime_parts = false
+  else
+    rule.scan_all_mime_parts = true
+  end
+
+  rule.patterns = common.create_regex_table(opts.patterns or {})
+  rule.patterns_fail = common.create_regex_table(opts.patterns_fail or {})
+
+  rule.mime_parts_filter_regex = common.create_regex_table(opts.mime_parts_filter_regex or {})
+
+  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)
   end