commit 9145d76: [Minor] Export allowed/forbidden ids for symbols

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jul 2 17:07:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-02 18:02:00 +0100
URL: https://github.com/rspamd/rspamd/commit/9145d76eed392cfb7096c5c3879cd05adeeb6e37 (HEAD -> master)

[Minor] Export allowed/forbidden ids for symbols

---
 src/lua/lua_config.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 6abddc4ff..db0105cbc 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -3338,6 +3338,36 @@ lua_metric_symbol_inserter (gpointer k, gpointer v, gpointer ud)
 		guint sflags = rspamd_symcache_get_symbol_flags (cbd->cfg->cache, sym);
 
 		lua_push_symbol_flags (L, sflags, LUA_SYMOPT_FLAG_USE_MAP);
+
+		guint nids;
+		const guint *allowed_ids = rspamd_symcache_get_allowed_settings_ids (cbd->cfg->cache,
+				sym, &nids);
+
+		if (allowed_ids && nids > 0) {
+			lua_createtable (L, nids, 0);
+
+			for (i = 0; i < nids; i ++) {
+				lua_pushinteger (L, allowed_ids[i]);
+				lua_rawseti (L, -2, i + 1);
+			}
+
+			lua_setfield (L, -2, "allowed_ids");
+		}
+
+		const guint *forbidden_ids = rspamd_symcache_get_forbidden_settings_ids (
+				cbd->cfg->cache,
+				sym, &nids);
+
+		if (forbidden_ids && nids > 0) {
+			lua_createtable (L, nids, 0);
+
+			for (i = 0; i < nids; i ++) {
+				lua_pushinteger (L, forbidden_ids[i]);
+				lua_rawseti (L, -2, i + 1);
+			}
+
+			lua_setfield (L, -2, "forbidden_ids");
+		}
 	}
 
 	lua_settable (L, -3); /* Flags -> flags_table */


More information about the Commits mailing list