aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-20 21:35:41 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-20 21:35:41 +0000
commit7e4aa922ca608d4567c5e9c775bbe614a4e72566 (patch)
tree58c3b70ae2c446cc9d164c9fa119c9e2f5e2e3fb /src/libserver
parent1432a7af36901e9cb5243b5d83a377656728896e (diff)
downloadrspamd-7e4aa922ca608d4567c5e9c775bbe614a4e72566.tar.gz
rspamd-7e4aa922ca608d4567c5e9c775bbe614a4e72566.zip
[Fix] Fix smtp message on passthrough result
Issue: #3269
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/protocol.c17
-rw-r--r--src/libserver/roll_history.c2
-rw-r--r--src/libserver/task.c18
3 files changed, 18 insertions, 19 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 727ada37f..ee5cc1f4d 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1167,8 +1167,9 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
struct rspamd_action *action;
ucl_object_t *obj = NULL, *sobj;
const gchar *subject;
+ struct rspamd_passthrough_result *pr = NULL;
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, &pr);
is_spam = !(action->flags & RSPAMD_ACTION_HAM);
if (task->cmd == CMD_CHECK) {
@@ -1181,6 +1182,16 @@ rspamd_scan_result_ucl (struct rspamd_task *task,
obj = top;
}
+ if (pr && pr->message && !(pr->flags & RSPAMD_PASSTHROUGH_NO_SMTP_MESSAGE)) {
+ /* Add smtp message if it does not exists: see #3269 for details */
+ if (ucl_object_lookup (task->messages, "smtp_message") == NULL) {
+ ucl_object_insert_key (task->messages,
+ ucl_object_fromstring_common (pr->message, 0, UCL_STRING_RAW),
+ "smtp_message", 0,
+ false);
+ }
+ }
+
ucl_object_insert_key (obj,
ucl_object_frombool (RSPAMD_TASK_IS_SKIPPED (task)),
"is_skipped", 0, false);
@@ -1734,13 +1745,13 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
end:
if (!(task->flags & RSPAMD_TASK_FLAG_NO_STAT)) {
/* Update stat for default metric */
+
msg_debug_protocol ("skip stats update due to no_stat flag");
metric_res = task->result;
if (metric_res != NULL) {
- action = rspamd_check_action_metric (task);
-
+ action = rspamd_check_action_metric (task, NULL);
/* TODO: handle custom actions in stats */
if (action->action_type == METRIC_ACTION_SOFT_REJECT &&
(task->flags & RSPAMD_TASK_FLAG_GREYLISTED)) {
diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c
index 1a742a441..a0197a32c 100644
--- a/src/libserver/roll_history.c
+++ b/src/libserver/roll_history.c
@@ -160,7 +160,7 @@ rspamd_roll_history_update (struct roll_history *history,
}
else {
row->score = metric_res->score;
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, NULL);
row->action = action->action_type;
row->required_score = rspamd_task_get_required_score (task, metric_res);
cbdata.pos = row->symbols;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 5c4ca4565..3e8dd381f 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -1076,7 +1076,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
khiter_t k;
mres = task->result;
- act = rspamd_check_action_metric (task);
+ act = rspamd_check_action_metric (task, NULL);
if (mres != NULL) {
switch (lf->type) {
@@ -1875,7 +1875,7 @@ rspamd_task_timeout (EV_P_ ev_timer *w, int revents)
if (task->cfg->soft_reject_on_timeout) {
struct rspamd_action *action, *soft_reject;
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, NULL);
if (action->action_type != METRIC_ACTION_REJECT) {
soft_reject = rspamd_config_get_action_by_type (task->cfg,
@@ -1887,12 +1887,6 @@ rspamd_task_timeout (EV_P_ ev_timer *w, int revents)
"timeout processing message",
"task timeout",
0);
-
- ucl_object_replace_key (task->messages,
- ucl_object_fromstring_common ("timeout processing message",
- 0, UCL_STRING_RAW),
- "smtp_message", 0,
- false);
}
}
@@ -1910,7 +1904,7 @@ rspamd_task_timeout (EV_P_ ev_timer *w, int revents)
if (task->cfg->soft_reject_on_timeout) {
struct rspamd_action *action, *soft_reject;
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, NULL);
if (action->action_type != METRIC_ACTION_REJECT) {
soft_reject = rspamd_config_get_action_by_type (task->cfg,
@@ -1922,12 +1916,6 @@ rspamd_task_timeout (EV_P_ ev_timer *w, int revents)
"timeout post-processing message",
"task timeout",
0);
-
- ucl_object_replace_key (task->messages,
- ucl_object_fromstring_common ("timeout post-processing message",
- 0, UCL_STRING_RAW),
- "smtp_message", 0,
- false);
}
}