diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-29 15:31:44 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-29 15:31:44 +0100 |
commit | 48c027506d6cf9496975f405f64f3c143a4c4290 (patch) | |
tree | a48c6fc20f755f612947e4db6e455b8a40f20cb3 /src | |
parent | 99caa38084aa41938b98918b9119a288a0aefcf5 (diff) | |
download | rspamd-48c027506d6cf9496975f405f64f3c143a4c4290.tar.gz rspamd-48c027506d6cf9496975f405f64f3c143a4c4290.zip |
[Feature] Skip certain symbols from ANN classify
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_utils.c | 2 | ||||
-rw-r--r-- | src/libserver/symbols_cache.c | 5 | ||||
-rw-r--r-- | src/libserver/symbols_cache.h | 2 | ||||
-rw-r--r-- | src/lua/lua_config.c | 4 | ||||
-rw-r--r-- | src/lua/lua_task.c | 2 | ||||
-rw-r--r-- | src/plugins/lua/asn.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/fann_redis.lua | 6 | ||||
-rw-r--r-- | src/plugins/lua/history_redis.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/mime_types.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 5 | ||||
-rw-r--r-- | src/plugins/lua/replies.lua | 4 | ||||
-rw-r--r-- | src/plugins/lua/settings.lua | 4 |
12 files changed, 25 insertions, 15 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 7bc8994b4..7e410559f 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1118,7 +1118,7 @@ symbols_classifiers_callback (gpointer key, gpointer value, gpointer ud) /* Actually, statistics should act like any ordinary symbol */ rspamd_symbols_cache_add_symbol (cfg->cache, key, 0, NULL, NULL, - SYMBOL_TYPE_CLASSIFIER, -1); + SYMBOL_TYPE_CLASSIFIER|SYMBOL_TYPE_NOSTAT, -1); } void diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 46f1b3fc6..1c18c5559 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -730,6 +730,11 @@ rspamd_symbols_cache_add_symbol (struct symbols_cache *cache, } } + if (type & (SYMBOL_TYPE_CLASSIFIER|SYMBOL_TYPE_CALLBACK| + SYMBOL_TYPE_PREFILTER|SYMBOL_TYPE_POSTFILTER)) { + type |= SYMBOL_TYPE_NOSTAT; + } + item = rspamd_mempool_alloc0 (cache->static_pool, sizeof (struct cache_item)); item->st = rspamd_mempool_alloc0_shared (cache->static_pool, diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index f717b39b9..ade8d95b9 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -40,7 +40,7 @@ enum rspamd_symbol_type { SYMBOL_TYPE_EMPTY = (1 << 8), /* Allow execution on empty tasks */ SYMBOL_TYPE_PREFILTER = (1 << 9), SYMBOL_TYPE_POSTFILTER = (1 << 10), - SYMBOL_TYPE_NONSTAT = (1 << 11), /* Skip as statistical symbol */ + SYMBOL_TYPE_NOSTAT = (1 << 11), /* Skip as statistical symbol */ }; /** diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 398c9ed34..7423bdaeb 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -191,6 +191,7 @@ LUA_FUNCTION_DEF (config, get_classifier); * + `nice` if symbol can produce negative score; * + `empty` if symbol can be called for empty messages * + `skip` if symbol should be skipped now + * + `nostat` if symbol should be excluded from stat tokens * - `parent`: id of parent symbol (useful for virtual symbols) * * @return {number} id of symbol registered @@ -1421,6 +1422,9 @@ lua_parse_symbol_flags (const gchar *str) if (strstr (str, "skip") != NULL) { ret |= SYMBOL_TYPE_SKIPPED; } + if (strstr (str, "nostat") != NULL) { + ret |= SYMBOL_TYPE_NOSTAT; + } } return ret; diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 78d78c954..6bc6a0e29 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -3108,7 +3108,7 @@ tokens_foreach_cb (gint id, const gchar *sym, gint flags, gpointer ud) struct tokens_foreach_cbdata *cbd = ud; struct rspamd_symbol_result *s; - if (flags & SYMBOL_TYPE_NONSTAT) { + if (flags & SYMBOL_TYPE_NOSTAT) { return; } diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua index e58f1be3b..0d103fc10 100644 --- a/src/plugins/lua/asn.lua +++ b/src/plugins/lua/asn.lua @@ -103,7 +103,7 @@ end if configure_asn_module() then local id = rspamd_config:register_symbol({ name = 'ASN_CHECK', - type = 'prefilter', + type = 'prefilter,nostat', callback = asn_check, priority = 5, }) diff --git a/src/plugins/lua/fann_redis.lua b/src/plugins/lua/fann_redis.lua index dbb4955ef..a710ae264 100644 --- a/src/plugins/lua/fann_redis.lua +++ b/src/plugins/lua/fann_redis.lua @@ -879,7 +879,7 @@ else }) local id = rspamd_config:register_symbol({ name = fann_symbol_spam, - type = 'postfilter', + type = 'postfilter,nostat', priority = 6, callback = fann_scores_filter }) @@ -891,7 +891,7 @@ else }) rspamd_config:register_symbol({ name = fann_symbol_ham, - type = 'virtual', + type = 'virtual,nostat', parent = id }) if opts['train'] then @@ -909,7 +909,7 @@ else end rspamd_config:register_symbol({ name = 'FANN_VECTOR_PUSH', - type = 'postfilter', + type = 'postfilter,nostat', priority = 5, callback = ann_push_vector }) diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua index ad65184b9..002c74e55 100644 --- a/src/plugins/lua/history_redis.lua +++ b/src/plugins/lua/history_redis.lua @@ -219,7 +219,7 @@ if opts then else rspamd_config:register_symbol({ name = 'HISTORY_SAVE', - type = 'postfilter', + type = 'postfilter,nostat', callback = history_save, priority = 150 }) diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 469e0c72a..b90bcad01 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -248,7 +248,7 @@ if opts then if map then local id = rspamd_config:register_symbol({ callback = check_mime_type, - type = 'callback' + type = 'callback,nostat' }) rspamd_config:register_symbol({ diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 2c42c2876..c1d98d4aa 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -682,7 +682,7 @@ if opts then rspamd_config:register_symbol({ name = 'RATELIMIT_CHECK', callback = rate_test, - type = 'prefilter', + type = 'prefilter,nostat', priority = 4, }) else @@ -695,6 +695,7 @@ if opts then local id = rspamd_config:register_symbol({ name = symbol, callback = rate_test, + type = 'normal,nostat' }) if use_ip_score then rspamd_config:register_dependency(id, 'IP_SCORE') @@ -702,7 +703,7 @@ if opts then end rspamd_config:register_symbol({ name = 'RATELIMIT_SET', - type = 'postfilter', + type = 'postfilter,nostat', priority = 5, callback = rate_set, }) diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua index 2f24f67e9..39dfa1113 100644 --- a/src/plugins/lua/replies.lua +++ b/src/plugins/lua/replies.lua @@ -128,13 +128,13 @@ if opts then else rspamd_config:register_symbol({ name = 'REPLIES_SET', - type = 'postfilter', + type = 'postfilter,nostat', callback = replies_set, priority = 5 }) local id = rspamd_config:register_symbol({ name = 'REPLIES_CHECK', - type = 'prefilter', + type = 'prefilter,nostat', callback = replies_check, priority = 10 }) diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 3e8b6d2af..8f75d15c3 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -644,7 +644,7 @@ if redis_section then fun.each(function(id, h) rspamd_config:register_symbol({ name = 'REDIS_SETTINGS' .. tostring(id), - type = 'prefilter', + type = 'prefilter,nostat', callback = gen_redis_callback(h, id), priority = 10 }) @@ -664,7 +664,7 @@ end rspamd_config:register_symbol({ name = 'SETTINGS_CHECK', - type = 'prefilter', + type = 'prefilter,nostat', callback = check_settings, priority = 10 }) |