]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Fuzzy_check: Allow to disable subject when making short text hash
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Feb 2021 16:25:18 +0000 (16:25 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 8 Feb 2021 16:26:29 +0000 (16:26 +0000)
src/plugins/fuzzy_check.c

index 2b4a098802fefad11756ca45a858218c0759d406..1315c5374bc60bb72ded4829861801ff61c080f6 100644 (file)
@@ -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)));