commit ddcbe39: [Minor] Add public_groups_only flag

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Aug 30 18:42:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-30 19:27:26 +0100
URL: https://github.com/rspamd/rspamd/commit/ddcbe3942b37a765387a4257b559add9502f7821

[Minor] Add public_groups_only flag

---
 src/libserver/cfg_file.h | 1 +
 src/libserver/cfg_rcl.c  | 6 ++++++
 src/libserver/protocol.c | 5 +++++
 3 files changed, 12 insertions(+)

diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 9573b776a..cffe997e4 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -368,6 +368,7 @@ struct rspamd_config {
 	gboolean disable_pcre_jit;                      /**< Disable pcre JIT									*/
 	gboolean own_lua_state;                         /**< True if we have created lua_state internally		*/
 	gboolean soft_reject_on_timeout;                /**< If true emit soft reject on task timeout (if not reject) */
+	gboolean public_groups_only;                    /**< Output merely public groups everywhere				*/
 
 	gsize max_cores_size;                           /**< maximum size occupied by rspamd core files			*/
 	gsize max_cores_count;                          /**< maximum number of core files						*/
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index d224b4029..2bdb6adc6 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1960,6 +1960,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg, GHashTable *skip_sections)
 				G_STRUCT_OFFSET (struct rspamd_config, check_all_filters),
 				0,
 				"Always check all filters");
+		rspamd_rcl_add_default_handler (sub,
+				"public_groups_only",
+				rspamd_rcl_parse_struct_boolean,
+				G_STRUCT_OFFSET (struct rspamd_config, public_groups_only),
+				0,
+				"Output merely public groups everywhere");
 		rspamd_rcl_add_default_handler (sub,
 				"enable_experimental",
 				rspamd_rcl_parse_struct_boolean,
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index f09784c48..469b834dc 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1248,8 +1248,13 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
 		gdouble gr_score;
 
 		obj = ucl_object_typed_new (UCL_OBJECT);
+		ucl_object_reserve (obj, kh_size (mres->sym_groups));
 
 		kh_foreach (mres->sym_groups, gr, gr_score,{
+			if (task->cfg->public_groups_only &&
+				!(gr->flags & RSPAMD_SYMBOL_GROUP_PUBLIC)) {
+				continue;
+			}
 			sobj = rspamd_metric_group_ucl (task, gr, gr_score);
 			ucl_object_insert_key (obj, sobj, gr->name, 0, false);
 		});


More information about the Commits mailing list