From 61eb14bc48944aaec5c3db7ddcd9bb4f35af78c5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 8 Feb 2021 16:25:18 +0000 Subject: [PATCH] [Feature] Fuzzy_check: Allow to disable subject when making short text hash --- src/plugins/fuzzy_check.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 2b4a09880..1315c5374 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -86,6 +86,7 @@ struct fuzzy_rule { gboolean read_only; gboolean skip_unknown; gboolean no_share; + gboolean no_subject; gint learn_condition_cb; struct rspamd_hash_map_helper *skip_map; struct fuzzy_ctx *ctx; @@ -442,6 +443,10 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, rule->no_share = ucl_obj_toboolean (value); } + if ((value = ucl_object_lookup (obj, "no_subject")) != NULL) { + rule->no_subject = ucl_obj_toboolean (value); + } + if ((value = ucl_object_lookup (obj, "algorithm")) != NULL) { rule->algorithm_str = ucl_object_tostring (value); @@ -908,7 +913,7 @@ fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) UCL_BOOLEAN, NULL, 0, - NULL, + "true", 0); rspamd_rcl_add_doc_by_path (cfg, "fuzzy_check.rule", @@ -938,6 +943,24 @@ fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) 0, NULL, 0); + rspamd_rcl_add_doc_by_path (cfg, + "fuzzy_check.rule", + "Do no use subject to distinguish short text hashes", + "no_subject", + UCL_BOOLEAN, + NULL, + 0, + "false", + 0); + rspamd_rcl_add_doc_by_path (cfg, + "fuzzy_check.rule", + "Disable sharing message stats with the fuzzy server", + "no_share", + UCL_BOOLEAN, + NULL, + 0, + "false", + 0); return 0; } @@ -1688,7 +1711,7 @@ fuzzy_cmd_from_text_part (struct rspamd_task *task, rspamd_cryptobox_hash_update (&st, part->utf_stripped_content->data, part->utf_stripped_content->len); - if (MESSAGE_FIELD (task, subject)) { + if (!rule->no_subject && (MESSAGE_FIELD (task, subject))) { /* We also include subject */ rspamd_cryptobox_hash_update (&st, MESSAGE_FIELD (task, subject), strlen (MESSAGE_FIELD (task, subject))); -- 2.39.5