]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] fuzzy_check: log rule and server for error replies
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Jul 2026 15:27:56 +0000 (16:27 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Jul 2026 15:27:56 +0000 (16:27 +0100)
403 (rate limit), 503 (access denied) and 415 (encryption required)
replies used to insert their symbols silently; with several rules
configured there was no way to tell from the logs which rule and which
server produced the error. Log an info message with the rule name and
the upstream in both the UDP and TCP reply paths.

src/plugins/fuzzy_check.c

index 20743b189d94bd14107a5611007388739d4a9272..9175623b4a6c3dba253d21787ca83e4e8b0f4d33 100644 (file)
@@ -115,9 +115,9 @@ struct fuzzy_rule {
        gboolean skip_unknown;
        gboolean no_share;
        gboolean no_subject;
-       gboolean html_shingles;     /* Enable HTML fuzzy hashing */
-       gboolean text_hashes;       /* Enable/disable generation of text hashes */
-       unsigned int min_html_tags; /* Minimum tags for HTML hash */
+       gboolean html_shingles;       /* Enable HTML fuzzy hashing */
+       gboolean text_hashes;         /* Enable/disable generation of text hashes */
+       unsigned int min_html_tags;   /* Minimum tags for HTML hash */
        gboolean html_ignore_domains; /* Ignore link domains in HTML structural tokens */
        int learn_condition_cb;
        uint32_t retransmits;
@@ -1554,14 +1554,24 @@ fuzzy_tcp_process_reply(struct fuzzy_tcp_connection *conn,
        }
        else if (rep->v1.value == 403) {
                /* In fact, it should be 429, but we preserve compatibility */
+               msg_info_task("fuzzy rule %s: rate limit reached on %s",
+                                         rule->name,
+                                         rspamd_upstream_name(conn->server));
                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_RATELIMITED, 1.0,
                                                                  rule->name);
        }
        else if (rep->v1.value == 503) {
+               msg_info_task("fuzzy rule %s: access denied by %s",
+                                         rule->name,
+                                         rspamd_upstream_name(conn->server));
                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_FORBIDDEN, 1.0,
                                                                  rule->name);
        }
        else if (rep->v1.value == 415) {
+               msg_info_task("fuzzy rule %s: encryption is required by %s; "
+                                         "add encryption_key option to the rule",
+                                         rule->name,
+                                         rspamd_upstream_name(conn->server));
                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_ENCRYPTION_REQUIRED, 1.0,
                                                                  rule->name);
        }
@@ -4730,14 +4740,24 @@ fuzzy_check_try_read(struct fuzzy_client_session *session)
                        }
                        else if (rep->v1.value == 403) {
                                /* In fact, it should be 429, but we preserve compatibility */
+                               msg_info_task("fuzzy rule %s: rate limit reached on %s",
+                                                         session->rule->name,
+                                                         rspamd_upstream_name(session->server));
                                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_RATELIMITED, 1.0,
                                                                                  session->rule->name);
                        }
                        else if (rep->v1.value == 503) {
+                               msg_info_task("fuzzy rule %s: access denied by %s",
+                                                         session->rule->name,
+                                                         rspamd_upstream_name(session->server));
                                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_FORBIDDEN, 1.0,
                                                                                  session->rule->name);
                        }
                        else if (rep->v1.value == 415) {
+                               msg_info_task("fuzzy rule %s: encryption is required by %s; "
+                                                         "add encryption_key option to the rule",
+                                                         session->rule->name,
+                                                         rspamd_upstream_name(session->server));
                                rspamd_task_insert_result(task, RSPAMD_FUZZY_SYMBOL_ENCRYPTION_REQUIRED, 1.0,
                                                                                  session->rule->name);
                        }