From a1dc1fd0591d0880c1537c4032d404cc748537f6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 22 Apr 2017 23:17:13 +0100 Subject: [PATCH] [Fix] Detect confighelp in plugins initialisation --- src/lua/lua_common.c | 4 ++- src/plugins/lua/antivirus.lua | 40 +++++++++++++++++++++++++++ src/plugins/lua/asn.lua | 4 +++ src/plugins/lua/clickhouse.lua | 4 +++ src/plugins/lua/dcc.lua | 25 +++++++++-------- src/plugins/lua/dkim_signing.lua | 4 +++ src/plugins/lua/dmarc.lua | 4 +++ src/plugins/lua/dynamic_conf.lua | 4 +++ src/plugins/lua/emails.lua | 4 +++ src/plugins/lua/fann_classifier.lua | 4 +++ src/plugins/lua/fann_redis.lua | 4 +++ src/plugins/lua/fann_scores.lua | 4 +++ src/plugins/lua/force_actions.lua | 4 +++ src/plugins/lua/forged_recipients.lua | 4 +++ src/plugins/lua/fuzzy_collect.lua | 4 +++ src/plugins/lua/greylist.lua | 4 +++ src/plugins/lua/hfilter.lua | 4 +++ src/plugins/lua/history_redis.lua | 4 +++ src/plugins/lua/ip_score.lua | 4 +++ src/plugins/lua/maillist.lua | 4 +++ src/plugins/lua/metadata_exporter.lua | 4 +++ src/plugins/lua/metric_exporter.lua | 4 +++ src/plugins/lua/mid.lua | 4 +++ src/plugins/lua/mime_types.lua | 4 +++ src/plugins/lua/multimap.lua | 4 +++ src/plugins/lua/mx_check.lua | 4 +++ src/plugins/lua/once_received.lua | 4 +++ src/plugins/lua/phishing.lua | 4 +++ src/plugins/lua/ratelimit.lua | 4 +++ src/plugins/lua/rbl.lua | 4 +++ src/plugins/lua/replies.lua | 4 +++ src/plugins/lua/rmilter_headers.lua | 4 +++ src/plugins/lua/rspamd_update.lua | 4 +++ src/plugins/lua/settings.lua | 4 +++ src/plugins/lua/spamassassin.lua | 4 +++ src/plugins/lua/trie.lua | 4 +++ src/plugins/lua/url_redirector.lua | 4 +++ src/plugins/lua/url_reputation.lua | 4 +++ src/plugins/lua/url_tags.lua | 4 +++ src/plugins/lua/whitelist.lua | 4 +++ 40 files changed, 205 insertions(+), 12 deletions(-) diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 4f494971b..634f7c569 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -390,7 +390,9 @@ rspamd_init_lua_filters (struct rspamd_config *cfg, gboolean force_load) continue; } - msg_info_config ("init lua module %s", module->name); + if (!force_load) { + msg_info_config ("init lua module %s", module->name); + } lua_pop (L, 1); /* Error function */ } diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index e83308b4e..63d2685ec 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -23,6 +23,46 @@ local redis_params local N = "antivirus" +if confighelp then + rspamd_config:add_example(nil, 'antivirus', + "Check messages for viruses", + [[ +antivirus { + # multiple scanners could be checked, for each we create a configuration block with an arbitrary name + clamav { + # If set force this action if any virus is found (default unset: no action is forced) + # action = "reject"; + # if `true` only messages with non-image attachments will be checked (default true) + attachments_only = true; + # If `max_size` is set, messages > n bytes in size are not scanned + max_size = 20000000; + # symbol to add (add it to metric if you want non-zero weight) + symbol = "CLAM_VIRUS"; + # type of scanner: "clamav", "fprot", "sophos" or "savapi" + type = "clamav"; + # For "savapi" you must also specify the following variable + product_id = 12345; + # You can enable logging for clean messages + log_clean = true; + # servers to query (if port is unspecified, scanner-specific default is used) + # can be specified multiple times to pool servers + # can be set to a path to a unix socket + # Enable this in local.d/antivirus.conf + servers = "127.0.0.1:3310"; + # 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 match_patterns(default_sym, found, patterns) if not patterns then return default_sym end for sym, pat in pairs(patterns) do diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua index 32f3871a7..e58f1be3b 100644 --- a/src/plugins/lua/asn.lua +++ b/src/plugins/lua/asn.lua @@ -18,6 +18,10 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local rspamd_regexp = require "rspamd_regexp" +if confighelp then + return +end + local options = { provider_type = 'rspamd', provider_info = { diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index e80b5652a..50808812b 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -17,6 +17,10 @@ limitations under the License. local rspamd_logger = require 'rspamd_logger' local rspamd_http = require "rspamd_http" +if confighelp then + return +end + local E = {} local rows = {} diff --git a/src/plugins/lua/dcc.lua b/src/plugins/lua/dcc.lua index cf44c3224..7995699b2 100644 --- a/src/plugins/lua/dcc.lua +++ b/src/plugins/lua/dcc.lua @@ -24,6 +24,19 @@ local logger = require "rspamd_logger" local tcp = require "rspamd_tcp" local fun = require "fun" +if confighelp then + rspamd_config:add_example(nil, 'dcc', + "Check messages for 'bulkiness' using DCC", + [[ +dcc { + host = "/var/dcc/dccifd"; # Unix socket or hostname + port = 1234 # Port to use (needed for TCP socket) + timeout = 2s; # Timeout to wait for checks +} +]]) + return +end + local function check_dcc (task) -- Connection local client = '0.0.0.0' @@ -127,14 +140,4 @@ if opts and opts['host'] then }) else logger.infox('DCC module not configured'); -end - -rspamd_config:add_example(nil, 'dcc', - "Check messages for 'bulkiness' using DCC", -[[ -dcc { - host = "/var/dcc/dccifd"; # Unix socket or hostname - port = 1234 # Port to use (needed for TCP socket) - timeout = 2s; # Timeout to wait for checks -} -]]) \ No newline at end of file +end \ No newline at end of file diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua index 71ec7fd38..ec2f70dc5 100644 --- a/src/plugins/lua/dkim_signing.lua +++ b/src/plugins/lua/dkim_signing.lua @@ -18,6 +18,10 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" +if confighelp then + return +end + local settings = { allow_envfrom_empty = true, allow_hdrfrom_mismatch = false, diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 936c3947c..443b31e30 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -22,6 +22,10 @@ local rspamd_util = require "rspamd_util" local check_local = false local check_authed = false +if confighelp then + return +end + local symbols = { spf_allow_symbol = 'R_SPF_ALLOW', spf_deny_symbol = 'R_SPF_FAIL', diff --git a/src/plugins/lua/dynamic_conf.lua b/src/plugins/lua/dynamic_conf.lua index b109c714f..9c017d6c9 100644 --- a/src/plugins/lua/dynamic_conf.lua +++ b/src/plugins/lua/dynamic_conf.lua @@ -19,6 +19,10 @@ local redis_params local ucl = require "ucl" local fun = require "fun" +if confighelp then + return +end + local settings = { redis_key = "dynamic_conf", redis_watch_interval = 10.0, diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua index 1eac27929..bda3d4f77 100644 --- a/src/plugins/lua/emails.lua +++ b/src/plugins/lua/emails.lua @@ -16,6 +16,10 @@ limitations under the License. -- Emails is module for different checks for emails inside messages +if confighelp then + return +end + -- Rules format: -- symbol = sym, map = file:///path/to/file, domain_only = yes -- symbol = sym2, dnsbl = bl.somehost.com, domain_only = no diff --git a/src/plugins/lua/fann_classifier.lua b/src/plugins/lua/fann_classifier.lua index c4110981d..f4133eb9e 100644 --- a/src/plugins/lua/fann_classifier.lua +++ b/src/plugins/lua/fann_classifier.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin is a concept of FANN scores adjustment -- NOT FOR PRODUCTION USE so far local rspamd_logger = require "rspamd_logger" diff --git a/src/plugins/lua/fann_redis.lua b/src/plugins/lua/fann_redis.lua index ecbd7528c..528d6535e 100644 --- a/src/plugins/lua/fann_redis.lua +++ b/src/plugins/lua/fann_redis.lua @@ -17,6 +17,10 @@ limitations under the License. -- This plugin is a concept of FANN scores adjustment -- NOT FOR PRODUCTION USE so far +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_fann = require "rspamd_fann" local rspamd_util = require "rspamd_util" diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index a96d27701..4737c7ba0 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -17,6 +17,10 @@ limitations under the License. -- This plugin is a concept of FANN scores adjustment -- NOT FOR PRODUCTION USE so far +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_fann = require "rspamd_fann" local rspamd_util = require "rspamd_util" diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index 2f87f728e..88b09dfad 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -17,6 +17,10 @@ limitations under the License. -- A plugin that forces actions +if confighelp then + return +end + local E = {} local N = 'force_actions' diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua index 0b6ff7911..a07fc668c 100644 --- a/src/plugins/lua/forged_recipients.lua +++ b/src/plugins/lua/forged_recipients.lua @@ -17,6 +17,10 @@ limitations under the License. -- Plugin for comparing smtp dialog recipients and sender with recipients and sender -- in mime headers +if confighelp then + return +end + local symbol_rcpt = 'FORGED_RECIPIENTS' local symbol_sender = 'FORGED_SENDER' diff --git a/src/plugins/lua/fuzzy_collect.lua b/src/plugins/lua/fuzzy_collect.lua index 663f48e13..b5dae4e20 100644 --- a/src/plugins/lua/fuzzy_collect.lua +++ b/src/plugins/lua/fuzzy_collect.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]] -- +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" local rspamd_http = require "rspamd_http" diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 37ebf6f02..dfcb29386 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -35,6 +35,10 @@ greylist { } --]] +if confighelp then + return +end + -- A plugin that implements greylisting using redis local redis_params diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index 0e06f683c..19ded363f 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -19,6 +19,10 @@ limitations under the License. -- Weight for checks_hellohost and checks_hello: 5 - very hard, 4 - hard, 3 - meduim, 2 - low, 1 - very low. -- From HFILTER_HELO_* and HFILTER_HOSTNAME_* symbols the maximum weight is selected in case of their actuating. +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_regexp = require "rspamd_regexp" local rspamc_local_helo = "rspamc.local" diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua index 8a1968542..ad65184b9 100644 --- a/src/plugins/lua/history_redis.lua +++ b/src/plugins/lua/history_redis.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + local redis_params local settings = { diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index 4d9573382..a1a88d4b2 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- IP score is a module that set ip score of specific ip, asn, country local rspamd_logger = require "rspamd_logger" local rspamd_regexp = require "rspamd_regexp" diff --git a/src/plugins/lua/maillist.lua b/src/plugins/lua/maillist.lua index e63eba6dc..3b23e25f1 100644 --- a/src/plugins/lua/maillist.lua +++ b/src/plugins/lua/maillist.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- Module for checking mail list headers local symbol = 'MAILLIST' diff --git a/src/plugins/lua/metadata_exporter.lua b/src/plugins/lua/metadata_exporter.lua index 3c0e1b2dc..a6bf0fa55 100644 --- a/src/plugins/lua/metadata_exporter.lua +++ b/src/plugins/lua/metadata_exporter.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that pushes metadata (or whole messages) to external services local redis_params diff --git a/src/plugins/lua/metric_exporter.lua b/src/plugins/lua/metric_exporter.lua index dfd7f64bd..c28e58560 100644 --- a/src/plugins/lua/metric_exporter.lua +++ b/src/plugins/lua/metric_exporter.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]] -- +if confighelp then + return +end + local N = 'metric_exporter' local logger = require "rspamd_logger" local mempool = require "rspamd_mempool" diff --git a/src/plugins/lua/mid.lua b/src/plugins/lua/mid.lua index 959697cd9..19c85dac0 100644 --- a/src/plugins/lua/mid.lua +++ b/src/plugins/lua/mid.lua @@ -19,6 +19,10 @@ MID plugin - suppress INVALID_MSGID and MISSING_MID for messages originating from listed valid DKIM domains with missed or known proprietary Message-IDs ]]-- +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_regexp = require "rspamd_regexp" diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index c1847f771..e510b627c 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin implements mime types checks for mail messages local logger = require "rspamd_logger" local settings = { diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index c85919881..ae63b47bd 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- Multimap is rspamd module designed to define and operate with different maps local rules = {} diff --git a/src/plugins/lua/mx_check.lua b/src/plugins/lua/mx_check.lua index f81d5ba93..b1d07209b 100644 --- a/src/plugins/lua/mx_check.lua +++ b/src/plugins/lua/mx_check.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- MX check plugin local rspamd_logger = require "rspamd_logger" local rspamd_tcp = require "rspamd_tcp" diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua index e1eea2ca5..e6dd44436 100644 --- a/src/plugins/lua/once_received.lua +++ b/src/plugins/lua/once_received.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- 0 or 1 received: = spam local symbol = 'ONCE_RECEIVED' diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua index 74909e9da..880b85b8f 100644 --- a/src/plugins/lua/phishing.lua +++ b/src/plugins/lua/phishing.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- Phishing detection interface for selecting phished urls and inserting corresponding symbol -- -- diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 341f9e658..15cbe953c 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that implements ratelimits using redis or kvstorage server local E = {} diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 01c12baef..7d22c6fa8 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin implements various types of RBL checks -- Documentation can be found here: -- https://rspamd.com/doc/modules/rbl.html diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua index b8f60288b..2f24f67e9 100644 --- a/src/plugins/lua/replies.lua +++ b/src/plugins/lua/replies.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that implements replies check using redis -- Default port for redis upstreams diff --git a/src/plugins/lua/rmilter_headers.lua b/src/plugins/lua/rmilter_headers.lua index 82a4de6bf..3221aa496 100644 --- a/src/plugins/lua/rmilter_headers.lua +++ b/src/plugins/lua/rmilter_headers.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that provides common header manipulations local logger = require "rspamd_logger" diff --git a/src/plugins/lua/rspamd_update.lua b/src/plugins/lua/rspamd_update.lua index f53967317..c0a5a4d61 100644 --- a/src/plugins/lua/rspamd_update.lua +++ b/src/plugins/lua/rspamd_update.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin implements dynamic updates for rspamd local ucl = require "ucl" diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 758bc9b94..81498dc71 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin implements user dynamic settings -- Settings documentation can be found here: -- https://rspamd.com/doc/configuration/settings.html diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 2a3c04bfc..fdf2568b7 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- This plugin is intended to read and parse spamassassin rules with regexp -- rules. SA plugins or statistics are not supported diff --git a/src/plugins/lua/trie.lua b/src/plugins/lua/trie.lua index d72526e62..2794e80c8 100644 --- a/src/plugins/lua/trie.lua +++ b/src/plugins/lua/trie.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- Trie is rspamd module designed to define and operate with suffix trie local N = 'trie' diff --git a/src/plugins/lua/url_redirector.lua b/src/plugins/lua/url_redirector.lua index d75de4a25..cc654b1fa 100644 --- a/src/plugins/lua/url_redirector.lua +++ b/src/plugins/lua/url_redirector.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + local redis_params local N = 'url_redirector' local settings = { diff --git a/src/plugins/lua/url_reputation.lua b/src/plugins/lua/url_reputation.lua index 056e6b30f..73043aa4e 100644 --- a/src/plugins/lua/url_reputation.lua +++ b/src/plugins/lua/url_reputation.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that restores/persists URL tags & calculates reputation local E = {} diff --git a/src/plugins/lua/url_tags.lua b/src/plugins/lua/url_tags.lua index 8cdc22a6c..3fe010546 100644 --- a/src/plugins/lua/url_tags.lua +++ b/src/plugins/lua/url_tags.lua @@ -15,6 +15,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + -- A plugin that restores/persists URL tags local N = 'url_tags' diff --git a/src/plugins/lua/whitelist.lua b/src/plugins/lua/whitelist.lua index 68a0d017d..634591e03 100644 --- a/src/plugins/lua/whitelist.lua +++ b/src/plugins/lua/whitelist.lua @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. ]]-- +if confighelp then + return +end + local rspamd_logger = require "rspamd_logger" local rspamd_util = require "rspamd_util" local fun = require "fun" -- 2.39.5