]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to disable virtual symbols permanently
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Dec 2019 10:10:14 +0000 (10:10 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 4 Dec 2019 10:10:14 +0000 (10:10 +0000)
src/libserver/rspamd_symcache.c
src/libserver/rspamd_symcache.h
src/lua/lua_config.c

index 4e9967945ed6310aa8b1c3451eecb48ce93a8917..6a4a9f7df211d1e22214f3b5ccab18273cc18186 100644 (file)
@@ -1598,14 +1598,18 @@ rspamd_symcache_is_item_allowed (struct rspamd_task *task,
 {
        const gchar *what = "execution";
 
+       if (!exec_only) {
+               what = "symbol insertion";
+       }
+
        /* Static checks */
        if (!item->enabled ||
                (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) ||
                (item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) {
 
                if (!item->enabled) {
-                       msg_debug_cache_task ("skipping check of %s as it is permanently disabled",
-                                       item->symbol);
+                       msg_debug_cache_task ("skipping %s of %s as it is permanently disabled",
+                                       what, item->symbol);
 
                        return FALSE;
                }
@@ -1623,10 +1627,6 @@ rspamd_symcache_is_item_allowed (struct rspamd_task *task,
                }
        }
 
-       if (!exec_only) {
-               what = "symbol insertion";
-       }
-
        /* Settings checks */
        if (task->settings_elt != 0) {
                guint32 id = task->settings_elt->id;
@@ -2760,14 +2760,15 @@ rspamd_symcache_is_checked (struct rspamd_task *task,
 
 void
 rspamd_symcache_disable_symbol_perm (struct rspamd_symcache *cache,
-                                                                        const gchar *symbol)
+                                                                        const gchar *symbol,
+                                                                        gboolean resolve_parent)
 {
        struct rspamd_symcache_item *item;
 
        g_assert (cache != NULL);
        g_assert (symbol != NULL);
 
-       item = rspamd_symcache_find_filter (cache, symbol, true);
+       item = rspamd_symcache_find_filter (cache, symbol, resolve_parent);
 
        if (item) {
                item->enabled = FALSE;
index 6542e76ce48447cc32b7d482233cc1d45713f8d8..23d1a72ab08d46992be8d01652bb574147bae649 100644 (file)
@@ -242,7 +242,8 @@ void rspamd_symcache_add_delayed_dependency (struct rspamd_symcache *cache,
  * @param symbol
  */
 void rspamd_symcache_disable_symbol_perm (struct rspamd_symcache *cache,
-                                                                                 const gchar *symbol);
+                                                                                 const gchar *symbol,
+                                                                                 gboolean resolve_parent);
 
 /**
  * Enable specific symbol in the cache
index b50949bdd10f8e998c234348a165f0021e706488..266dbd1112f7a309c1c0570033397d962eeaab39 100644 (file)
@@ -431,9 +431,10 @@ LUA_FUNCTION_DEF (config, add_condition);
 LUA_FUNCTION_DEF (config, enable_symbol);
 
 /***
- * @method rspamd_config:disable_symbol(symbol)
+ * @method rspamd_config:disable_symbol(symbol, [disable_parent=true])
  * Disables execution for the specified symbol
  * @param {string} symbol symbol's name
+ * @param {boolean} disable_parent if true then disable parent execution in case of a virtual symbol
  */
 LUA_FUNCTION_DEF (config, disable_symbol);
 
@@ -2898,9 +2899,14 @@ lua_config_disable_symbol (lua_State *L)
        LUA_TRACE_POINT;
        struct rspamd_config *cfg = lua_check_config (L, 1);
        const gchar *sym = luaL_checkstring (L, 2);
+       gboolean disable_parent = TRUE;
 
        if (cfg && sym) {
-               rspamd_symcache_disable_symbol_perm (cfg->cache, sym);
+               if (lua_isboolean (L, 3)) {
+                       disable_parent = lua_toboolean (L, 3);
+               }
+
+               rspamd_symcache_disable_symbol_perm (cfg->cache, sym, disable_parent);
        }
        else {
                return luaL_error (L, "invalid arguments");