aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/fuzzy_check.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-08 16:25:18 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-08 16:26:29 +0000
commit61eb14bc48944aaec5c3db7ddcd9bb4f35af78c5 (patch)
tree1c18c2ec4b59fffe834d72794bbff4f7f74d7993 /src/plugins/fuzzy_check.c
parent154f69f000244785209dcef937c47f10ede1f113 (diff)
downloadrspamd-61eb14bc48944aaec5c3db7ddcd9bb4f35af78c5.tar.gz
rspamd-61eb14bc48944aaec5c3db7ddcd9bb4f35af78c5.zip
[Feature] Fuzzy_check: Allow to disable subject when making short text hash
Diffstat (limited to 'src/plugins/fuzzy_check.c')
-rw-r--r--src/plugins/fuzzy_check.c27
1 files 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)));