rspamd_add_passthrough_result (task, action,
RSPAMD_PASSTHROUGH_CRITICAL,
score, "Gtube pattern", "GTUBE", 0);
-
- if (ucl_object_lookup (task->messages, "smtp_message") == NULL) {
- ucl_object_replace_key (task->messages,
- ucl_object_fromstring ("Gtube pattern"),
- "smtp_message", 0, false);
- }
}
rspamd_task_insert_result (task, GTUBE_SYMBOL, 0, NULL);
}
struct rspamd_action*
-rspamd_check_action_metric (struct rspamd_task *task)
+rspamd_check_action_metric (struct rspamd_task *task,
+ struct rspamd_passthrough_result **ppr)
{
struct rspamd_action_result *action_lim,
*noaction = NULL;
struct rspamd_action *selected_action = NULL, *least_action = NULL;
- struct rspamd_passthrough_result *pr;
+ struct rspamd_passthrough_result *pr, *sel_pr = NULL;
double max_score = -(G_MAXDOUBLE), sc;
int i;
struct rspamd_scan_result *mres = task->result;
}
}
+ if (ppr) {
+ *ppr = pr;
+ }
+
return selected_action;
}
else {
else {
sc = selected_action->threshold;
max_score = sc;
+ sel_pr = pr;
}
}
else {
max_score = sc;
+ sel_pr = pr;
}
}
}
selected_action->action_type != METRIC_ACTION_DISCARD) {
/* Override score based action with least action */
selected_action = least_action;
+
+ if (ppr) {
+ *ppr = sel_pr;
+ }
}
}
else {
/* Adjust score if needed */
- mres->score = MAX (max_score, mres->score);
+ if (max_score > mres->score) {
+ if (ppr) {
+ *ppr = sel_pr;
+ }
+
+ mres->score = max_score;
+ }
}
}
return selected_action;
}
+ if (ppr) {
+ *ppr = sel_pr;
+ }
+
return noaction->action;
}
#define RSPAMD_PASSTHROUGH_CRITICAL 3
#define RSPAMD_PASSTHROUGH_LEAST (1u << 0u)
+#define RSPAMD_PASSTHROUGH_NO_SMTP_MESSAGE (1u << 0u)
struct rspamd_passthrough_result {
struct rspamd_action *action;
* @param task
* @return
*/
-struct rspamd_action *rspamd_check_action_metric (struct rspamd_task *task);
+struct rspamd_action *rspamd_check_action_metric (struct rspamd_task *task,
+ struct rspamd_passthrough_result **ppr);
#ifdef __cplusplus
}
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) {
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);
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)) {
}
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;
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) {
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,
"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);
}
}
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,
"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);
}
}
if (strstr (fl_str, "least") != NULL) {
flags |= RSPAMD_PASSTHROUGH_LEAST;
}
+ else if (strstr (fl_str, "no_smtp_message") != NULL) {
+ flags |= RSPAMD_PASSTHROUGH_NO_SMTP_MESSAGE;
+ }
}
lua_pushnumber (L, metric_res->score);
lua_settable (L, -3);
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, NULL);
if (action) {
lua_pushstring (L, "action");
struct rspamd_action *action;
if (task) {
- action = rspamd_check_action_metric (task);
+ action = rspamd_check_action_metric (task, NULL);
lua_pushstring (L, action->name);
}
else {