diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
commit | 662145d0554de5e769b92dab2d41173a98adcee5 (patch) | |
tree | ec28311a0bce6181f248ba7b50304293ad764e44 /src/plugins/lua/external_services.lua | |
parent | bbd88232db43d18f5e0de5a6502848d4074621c5 (diff) | |
download | rspamd-662145d0554de5e769b92dab2d41173a98adcee5.tar.gz rspamd-662145d0554de5e769b92dab2d41173a98adcee5.zip |
[Minor] Reformat all Lua code, no functional changes
Diffstat (limited to 'src/plugins/lua/external_services.lua')
-rw-r--r-- | src/plugins/lua/external_services.lua | 171 |
1 files changed, 87 insertions, 84 deletions
diff --git a/src/plugins/lua/external_services.lua b/src/plugins/lua/external_services.lua index d6fedeece..a68517c08 100644 --- a/src/plugins/lua/external_services.lua +++ b/src/plugins/lua/external_services.lua @@ -27,91 +27,90 @@ local N = "external_services" if confighelp then rspamd_config:add_example(nil, 'external_services', - "Check messages using external services (e.g. OEM AS engines, DCC, Pyzor etc)", - [[ -external_services { - # multiple scanners could be checked, for each we create a configuration block with an arbitrary name - - oletools { - # If set force this action if any virus is found (default unset: no action is forced) - # action = "reject"; - # If set, then rejection message is set to this value (mention single quotes) - # If `max_size` is set, messages > n bytes in size are not scanned - # max_size = 20000000; - # log_clean = true; - # servers = "127.0.0.1:10050"; - # cache_expire = 86400; - # scan_mime_parts = true; - # extended = false; - # if `patterns` is specified virus name will be matched against provided regexes and the related - # symbol will be yielded if a match is found. If no match is found, default symbol is yielded. - patterns { - # symbol_name = "pattern"; - JUST_EICAR = "^Eicar-Test-Signature$"; + "Check messages using external services (e.g. OEM AS engines, DCC, Pyzor etc)", + [[ + external_services { + # multiple scanners could be checked, for each we create a configuration block with an arbitrary name + + oletools { + # If set force this action if any virus is found (default unset: no action is forced) + # action = "reject"; + # If set, then rejection message is set to this value (mention single quotes) + # If `max_size` is set, messages > n bytes in size are not scanned + # max_size = 20000000; + # log_clean = true; + # servers = "127.0.0.1:10050"; + # cache_expire = 86400; + # scan_mime_parts = true; + # extended = false; + # if `patterns` is specified virus name will be matched against provided regexes and the related + # symbol will be yielded if a match is found. If no match is found, default symbol is yielded. + patterns { + # symbol_name = "pattern"; + JUST_EICAR = "^Eicar-Test-Signature$"; + } + # mime-part regex matching in content-type or filename + mime_parts_filter_regex { + #GEN1 = "application\/octet-stream"; + DOC2 = "application\/msword"; + DOC3 = "application\/vnd\.ms-word.*"; + XLS = "application\/vnd\.ms-excel.*"; + PPT = "application\/vnd\.ms-powerpoint.*"; + GEN2 = "application\/vnd\.openxmlformats-officedocument.*"; + } + # Mime-Part filename extension matching (no regex) + mime_parts_filter_ext { + doc = "doc"; + dot = "dot"; + docx = "docx"; + dotx = "dotx"; + docm = "docm"; + dotm = "dotm"; + xls = "xls"; + xlt = "xlt"; + xla = "xla"; + xlsx = "xlsx"; + xltx = "xltx"; + xlsm = "xlsm"; + xltm = "xltm"; + xlam = "xlam"; + xlsb = "xlsb"; + ppt = "ppt"; + pot = "pot"; + pps = "pps"; + ppa = "ppa"; + pptx = "pptx"; + potx = "potx"; + ppsx = "ppsx"; + ppam = "ppam"; + pptm = "pptm"; + potm = "potm"; + ppsm = "ppsm"; + } + # `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned. + whitelist = "/etc/rspamd/antivirus.wl"; } - # mime-part regex matching in content-type or filename - mime_parts_filter_regex { - #GEN1 = "application\/octet-stream"; - DOC2 = "application\/msword"; - DOC3 = "application\/vnd\.ms-word.*"; - XLS = "application\/vnd\.ms-excel.*"; - PPT = "application\/vnd\.ms-powerpoint.*"; - GEN2 = "application\/vnd\.openxmlformats-officedocument.*"; + dcc { + # If set force this action if any virus is found (default unset: no action is forced) + # action = "reject"; + # If set, then rejection message is set to this value (mention single quotes) + # If `max_size` is set, messages > n bytes in size are not scanned + max_size = 20000000; + #servers = "127.0.0.1:10045; + # if `patterns` is specified virus name will be matched against provided regexes and the related + # symbol will be yielded if a match is found. If no match is found, default symbol is yielded. + patterns { + # symbol_name = "pattern"; + JUST_EICAR = "^Eicar-Test-Signature$"; + } + # `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned. + whitelist = "/etc/rspamd/antivirus.wl"; } - # Mime-Part filename extension matching (no regex) - mime_parts_filter_ext { - doc = "doc"; - dot = "dot"; - docx = "docx"; - dotx = "dotx"; - docm = "docm"; - dotm = "dotm"; - xls = "xls"; - xlt = "xlt"; - xla = "xla"; - xlsx = "xlsx"; - xltx = "xltx"; - xlsm = "xlsm"; - xltm = "xltm"; - xlam = "xlam"; - xlsb = "xlsb"; - ppt = "ppt"; - pot = "pot"; - pps = "pps"; - ppa = "ppa"; - pptx = "pptx"; - potx = "potx"; - ppsx = "ppsx"; - ppam = "ppam"; - pptm = "pptm"; - potm = "potm"; - ppsm = "ppsm"; - } - # `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned. - whitelist = "/etc/rspamd/antivirus.wl"; - } - dcc { - # If set force this action if any virus is found (default unset: no action is forced) - # action = "reject"; - # If set, then rejection message is set to this value (mention single quotes) - # If `max_size` is set, messages > n bytes in size are not scanned - max_size = 20000000; - #servers = "127.0.0.1:10045; - # if `patterns` is specified virus name will be matched against provided regexes and the related - # symbol will be yielded if a match is found. If no match is found, default symbol is yielded. - patterns { - # symbol_name = "pattern"; - JUST_EICAR = "^Eicar-Test-Signature$"; - } - # `whitelist` points to a map of IP addresses. Mail from these addresses is not scanned. - whitelist = "/etc/rspamd/antivirus.wl"; } -} -]]) + ]]) return end - local function add_scanner_rule(sym, opts) if not opts.type then rspamd_logger.errx(rspamd_config, 'unknown type for external scanner rule %s', sym) @@ -130,7 +129,7 @@ local function add_scanner_rule(sym, opts) if not rule then rspamd_logger.errx(rspamd_config, 'cannot configure %s for %s', - opts.type, rule.symbol or sym:upper()) + opts.type, rule.symbol or sym:upper()) return nil end @@ -204,8 +203,12 @@ if opts and type(opts) == 'table' then local has_valid = false for k, m in pairs(opts) do if type(m) == 'table' and m.servers then - if not m.type then m.type = k end - if not m.name then m.name = k end + if not m.type then + m.type = k + end + if not m.name then + m.name = k + end local cb, nrule = add_scanner_rule(k, m) if not cb then @@ -334,7 +337,7 @@ if opts and type(opts) == 'table' then end if m.symbols then local function reg_symbols(tbl) - for _,sym in pairs(tbl) do + for _, sym in pairs(tbl) do if type(sym) == 'string' then rspamd_config:register_symbol({ type = 'virtual', @@ -389,7 +392,7 @@ if opts and type(opts) == 'table' then -- Add preloads if a module requires that if type(m.preloads) == 'table' then - for _,preload in ipairs(m.preloads) do + for _, preload in ipairs(m.preloads) do rspamd_config:add_on_load(function(cfg, ev_base, worker) preload(m, cfg, ev_base, worker) end) |