]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Warn about using of settings and settings-id together
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 16 Aug 2019 12:22:47 +0000 (13:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 16 Aug 2019 12:22:47 +0000 (13:22 +0100)
src/libserver/protocol.c
src/libserver/protocol_internal.h
src/plugins/lua/settings.lua

index 3f07926be15ad53113166289a6a4723dc77513bf..ef8700340a19926d6fe4356f9f0b57f119fb20db 100644 (file)
@@ -446,7 +446,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
        struct rspamd_http_message *msg)
 {
        rspamd_ftok_t *hn_tok, *hv_tok, srch;
-       gboolean has_ip = FALSE;
+       gboolean has_ip = FALSE, seen_settings_header = FALSE;
        struct rspamd_http_header *header, *h, *htmp;
        gchar *ntok;
 
@@ -601,6 +601,10 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
                                                                task->settings_elt->id);
                                        }
                                }
+                               IF_HEADER (SETTINGS_HEADER) {
+                                       msg_debug_protocol ("read settings header, value: %T", hv_tok);
+                                       seen_settings_header = TRUE;
+                               }
                                break;
                        case 'u':
                        case 'U':
@@ -696,6 +700,14 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
                }
        }
 
+       if (seen_settings_header && task->settings_elt) {
+               msg_warn_task ("ignore settings id %s as settings header is also presented",
+                               task->settings_elt->name);
+               REF_RELEASE (task->settings_elt);
+
+               task->settings_elt = NULL;
+       }
+
        if (!has_ip) {
                task->flags |= RSPAMD_TASK_FLAG_NO_IP;
        }
index 8cec5d80e6f3eeae3bd935366ebda0878673b28d..a20ecbd6e6dcd22a889b1047f918e0be5e4fe451 100644 (file)
@@ -68,6 +68,7 @@ extern "C" {
 #define RCPT_HEADER "Rcpt"
 #define SUBJECT_HEADER "Subject"
 #define SETTINGS_ID_HEADER "Settings-ID"
+#define SETTINGS_HEADER "Settings"
 #define QUEUE_ID_HEADER "Queue-ID"
 #define USER_HEADER "User"
 #define URLS_HEADER "URL-Format"
index 94f7a609169c123cd1811e0c55a7a4700f728dc7..237ed41be4341bc61e1940b4dbea653af0c0c519 100644 (file)
@@ -98,11 +98,15 @@ end
 -- settings are overridden
 local function check_query_settings(task)
   -- Try 'settings' attribute
+  local settings_id = task:get_settings_id()
   local query_set = task:get_request_header('settings')
   if query_set then
+
     local parser = ucl.parser()
     local res,err = parser:parse_string(tostring(query_set))
     if res then
+      rspamd_logger.warnx(task, "both settings-id '%s' and settings headers are presented, ignore settings-id; ",
+          tostring(settings_id))
       local settings_obj = parser:get_object()
       apply_settings(task, settings_obj, nil)
 
@@ -113,7 +117,6 @@ local function check_query_settings(task)
   end
 
   local query_maxscore = task:get_request_header('maxscore')
-  local settings_id = task:get_settings_id()
   local nset
 
   if query_maxscore then