commit b1c2596: Merge pull request #4049 from StSturge/feature/configdump_symbol_detail

GitHub noreply at github.com
Fri Jan 28 19:49:08 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-01-28 19:47:25 +0000
URL: https://github.com/rspamd/rspamd/commit/b1c259630635d5cf262cc942e1faada1616da36f (HEAD -> master)

Merge pull request #4049 from StSturge/feature/configdump_symbol_detail
[Minor] rspamadm configdump: parsing fixes and output enhancements

 src/libserver/cfg_utils.c       |   3 +-
 src/libserver/rspamd_symcache.c |  23 +++++++-
 src/libserver/rspamd_symcache.h |   5 ++
 src/lua/lua_config.c            |  35 ++++++++++++
 src/rspamadm/configdump.c       | 121 +++++++++++++++++++++++++++++++++++++++-
 5 files changed, 183 insertions(+), 4 deletions(-)

diff --combined src/libserver/cfg_utils.c
index 46ec5d5c6,4deae950e..6d2ea82d6
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@@ -817,7 -817,7 +817,7 @@@ rspamd_config_post_load (struct rspamd_
  	rspamd_regexp_library_init (cfg);
  	rspamd_multipattern_library_init (cfg->hs_cache_dir);
  
 -#if defined(WITH_HYPERSCAN) && !defined(__aarch64__)
 +#if defined(WITH_HYPERSCAN) && !defined(__aarch64__) && !defined(__powerpc64__)
  	if (!cfg->disable_hyperscan) {
  		if (!(cfg->libs_ctx->crypto_ctx->cpu_config & CPUID_SSSE3)) {
  			msg_warn_config ("CPU doesn't have SSSE3 instructions set "
@@@ -1630,8 -1630,9 +1630,9 @@@ rspamd_config_add_symbol (struct rspamd
  					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 --combined src/lua/lua_config.c
index 414f06f36,0ce93164d..467d386a7
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@@ -426,18 -426,8 +426,18 @@@ LUA_FUNCTION_DEF (config, get_key)
   * @return {boolean} true if condition has been added
   * @example
  
 +local condition_map = rspamd_config:add_map{
 +  type = "hash",
 +  urls = ['file:///path/to/file'],
 +  description = 'SMTP from map that allows FUZZY_DENIED skip for the listed addresses'
 +}
  rspamd_config:add_condition('FUZZY_DENIED', function(task)
 -  if some_map:find_key(task:get_from()) then return false end
 +  local E = {}
 +  -- Check for the smtp from address adding fail safe checks
 +  if condition_map:find_key(((task:get_from('smtp') or E)[1] or E).addr) then
 +    return false
 +  end
 +  -- Allow execution otherwise
    return true
  end)
   */
@@@ -2883,6 -2873,41 +2883,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. If the symbol was ungrouped, this will
+ 					* clear RSPAMD_SYMBOL_FLAG_UNGROUPPED from the flags. */
+ 					rspamd_config_add_symbol_group (cfg, name, group);
+ 				}
+ 			}
  
  			/* Remove table from stack */
  			lua_pop (L, 1);


More information about the Commits mailing list