diff options
author | ssturges <ststurge@cisco.com> | 2022-01-25 13:37:10 -0500 |
---|---|---|
committer | ssturges <ststurge@cisco.com> | 2022-01-25 13:37:10 -0500 |
commit | 13a13685b067c15cf25d867e3b8663ef8835b9f9 (patch) | |
tree | 81c6b382c81ad6196db668c35d78d2aa82c72036 /src | |
parent | f90765d9c840b17ad68fe2f422807f70ab08ae41 (diff) | |
download | rspamd-13a13685b067c15cf25d867e3b8663ef8835b9f9.tar.gz rspamd-13a13685b067c15cf25d867e3b8663ef8835b9f9.zip |
[Fix] Support definition of ungrouped symbol in conf file, use group info from lua or other conf file
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_utils.c | 3 | ||||
-rw-r--r-- | src/lua/lua_config.c | 35 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 44cdbc84f..4deae950e 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1630,8 +1630,9 @@ rspamd_config_add_symbol (struct rspamd_config *cfg, sym_group = rspamd_config_new_group (cfg, group); } - if (!sym_def->gr) { + if ((!sym_def->gr) || (sym_def->flags & RSPAMD_SYMBOL_FLAG_UNGROUPPED)) { sym_def->gr = sym_group; + sym_def->flags &= ~RSPAMD_SYMBOL_FLAG_UNGROUPPED; } g_hash_table_insert (sym_group->symbols, sym_def->name, sym_def); diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 8b0a4a46c..d66af2d0c 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -2873,6 +2873,41 @@ lua_config_newindex (lua_State *L) lua_pop (L, 1); } } + else + { + /* Fill in missing fields from lua defintion if they are not set */ + if (sym->description == NULL) { + lua_pushstring (L, "description"); + lua_gettable (L, -2); + + if (lua_type (L, -1) == LUA_TSTRING) { + description = lua_tostring (L, -1); + } + lua_pop (L, 1); + + if (description) { + sym->description = rspamd_mempool_strdup (cfg->cfg_pool, description); + } + } + + /* If ungrouped and there is a group defined in lua, change the primary group + * Otherwise, add to the list of groups for this symbol. */ + lua_pushstring (L, "group"); + lua_gettable (L, -2); + if (lua_type (L, -1) == LUA_TSTRING) { + group = lua_tostring (L, -1); + } + lua_pop (L, 1); + if (group) { + if (sym->flags & RSPAMD_SYMBOL_FLAG_UNGROUPPED) + { + /* Unset the "ungrouped" group */ + sym->gr = NULL; + } + /* Add the group */ + rspamd_config_add_symbol_group (cfg, name, group); + } + } /* Remove table from stack */ lua_pop (L, 1); |