gboolean
rspamd_message_parse (struct rspamd_task *task)
{
- struct rspamd_mime_text_part *p1, *p2;
struct received_header *recv, *trecv;
const gchar *p;
gsize len;
guint i;
- gdouble diff, *pdiff;
- guint tw, *ptw, dw;
GError *err = NULL;
rspamd_cryptobox_hash_state_t st;
guchar digest_out[rspamd_cryptobox_HASHBYTES];
task->queue_id = "undef";
}
- for (i = 0; i < task->parts->len; i ++) {
- struct rspamd_mime_part *part;
-
- part = g_ptr_array_index (task->parts, i);
- rspamd_message_process_text_part (task, part);
- }
-
- rspamd_images_process (task);
- rspamd_archives_process (task);
-
if (task->received->len > 0) {
gboolean need_recv_correction = FALSE;
rspamd_inet_addr_t *raddr;
rspamd_url_task_subject_callback, task);
}
+ for (i = 0; i < task->parts->len; i ++) {
+ struct rspamd_mime_part *part;
+
+ part = g_ptr_array_index (task->parts, i);
+ rspamd_cryptobox_hash_update (&st, part->digest, sizeof (part->digest));
+ }
+
+ rspamd_cryptobox_hash_final (&st, digest_out);
+ memcpy (task->digest, digest_out, sizeof (task->digest));
+
+ if (task->queue_id) {
+ msg_info_task ("loaded message; id: <%s>; queue-id: <%s>; size: %z; "
+ "checksum: <%*xs>",
+ task->message_id, task->queue_id, task->msg.len,
+ (gint)sizeof (task->digest), task->digest);
+ }
+ else {
+ msg_info_task ("loaded message; id: <%s>; size: %z; "
+ "checksum: <%*xs>",
+ task->message_id, task->msg.len,
+ (gint)sizeof (task->digest), task->digest);
+ }
+
+ return TRUE;
+}
+
+void
+rspamd_message_process (struct rspamd_task *task)
+{
+ guint i;
+ struct rspamd_mime_text_part *p1, *p2;
+ gdouble diff, *pdiff;
+ guint tw, *ptw, dw;
+
+ for (i = 0; i < task->parts->len; i ++) {
+ struct rspamd_mime_part *part;
+
+ part = g_ptr_array_index (task->parts, i);
+ rspamd_message_process_text_part (task, part);
+ }
+
+ rspamd_images_process (task);
+ rspamd_archives_process (task);
+
/* Calculate distance for 2-parts messages */
if (task->text_parts->len == 2) {
p1 = g_ptr_array_index (task->text_parts, 0);
if (rspamd_ftok_cmp (&p1->mime_part->parent_part->ct->subtype, &srch) == 0) {
if (!IS_PART_EMPTY (p1) && !IS_PART_EMPTY (p2) &&
- p1->normalized_hashes && p2->normalized_hashes) {
+ p1->normalized_hashes && p2->normalized_hashes) {
/*
* We also detect language on one part and propagate it to
* another one
}
}
- for (i = 0; i < task->parts->len; i ++) {
- struct rspamd_mime_part *part;
-
- part = g_ptr_array_index (task->parts, i);
- rspamd_cryptobox_hash_update (&st, part->digest, sizeof (part->digest));
- }
-
/* Calculate average words length and number of short words */
struct rspamd_mime_text_part *text_part;
gdouble *var;
*var /= (double)total_words;
}
}
-
- rspamd_cryptobox_hash_final (&st, digest_out);
- memcpy (task->digest, digest_out, sizeof (task->digest));
-
- if (task->queue_id) {
- msg_info_task ("loaded message; id: <%s>; queue-id: <%s>; size: %z; "
- "checksum: <%*xs>",
- task->message_id, task->queue_id, task->msg.len,
- (gint)sizeof (task->digest), task->digest);
- }
- else {
- msg_info_task ("loaded message; id: <%s>; size: %z; "
- "checksum: <%*xs>",
- task->message_id, task->msg.len,
- (gint)sizeof (task->digest), task->digest);
- }
-
- return TRUE;
}
*/
gboolean rspamd_message_parse (struct rspamd_task *task);
+/**
+ * Process content in task (e.g. HTML parsing)
+ * @param task
+ */
+void rspamd_message_process (struct rspamd_task *task);
+
/**
* Get an array of header's values with specified header's name using raw headers
* @param task worker task structure
RSPAMD_TASK_STAGE_PRE_FILTERS);
break;
+ case RSPAMD_TASK_STAGE_PROCESS_MESSAGE:
+ if (!(task->flags & RSPAMD_TASK_FLAG_SKIP_PROCESS)) {
+ rspamd_message_process (task);
+ }
+ break;
+
case RSPAMD_TASK_STAGE_FILTERS:
rspamd_symbols_cache_process_symbols (task, task->cfg->cache,
RSPAMD_TASK_STAGE_FILTERS);
RSPAMD_TASK_STAGE_ENVELOPE = (1 << 1),
RSPAMD_TASK_STAGE_READ_MESSAGE = (1 << 2),
RSPAMD_TASK_STAGE_PRE_FILTERS = (1 << 3),
- RSPAMD_TASK_STAGE_FILTERS = (1 << 4),
- RSPAMD_TASK_STAGE_CLASSIFIERS_PRE = (1 << 5),
- RSPAMD_TASK_STAGE_CLASSIFIERS = (1 << 6),
- RSPAMD_TASK_STAGE_CLASSIFIERS_POST = (1 << 7),
- RSPAMD_TASK_STAGE_COMPOSITES = (1 << 8),
- RSPAMD_TASK_STAGE_POST_FILTERS = (1 << 9),
- RSPAMD_TASK_STAGE_LEARN_PRE = (1 << 10),
- RSPAMD_TASK_STAGE_LEARN = (1 << 11),
- RSPAMD_TASK_STAGE_LEARN_POST = (1 << 12),
- RSPAMD_TASK_STAGE_COMPOSITES_POST = (1 << 13),
- RSPAMD_TASK_STAGE_IDEMPOTENT = (1 << 14),
- RSPAMD_TASK_STAGE_DONE = (1 << 15),
- RSPAMD_TASK_STAGE_REPLIED = (1 << 16)
+ RSPAMD_TASK_STAGE_PROCESS_MESSAGE = (1 << 4),
+ RSPAMD_TASK_STAGE_FILTERS = (1 << 5),
+ RSPAMD_TASK_STAGE_CLASSIFIERS_PRE = (1 << 6),
+ RSPAMD_TASK_STAGE_CLASSIFIERS = (1 << 7),
+ RSPAMD_TASK_STAGE_CLASSIFIERS_POST = (1 << 8),
+ RSPAMD_TASK_STAGE_COMPOSITES = (1 << 9),
+ RSPAMD_TASK_STAGE_POST_FILTERS = (1 << 10),
+ RSPAMD_TASK_STAGE_LEARN_PRE = (1 << 11),
+ RSPAMD_TASK_STAGE_LEARN = (1 << 12),
+ RSPAMD_TASK_STAGE_LEARN_POST = (1 << 13),
+ RSPAMD_TASK_STAGE_COMPOSITES_POST = (1 << 14),
+ RSPAMD_TASK_STAGE_IDEMPOTENT = (1 << 15),
+ RSPAMD_TASK_STAGE_DONE = (1 << 16),
+ RSPAMD_TASK_STAGE_REPLIED = (1 << 17)
};
#define RSPAMD_TASK_PROCESS_ALL (RSPAMD_TASK_STAGE_CONNECT | \
RSPAMD_TASK_STAGE_ENVELOPE | \
RSPAMD_TASK_STAGE_READ_MESSAGE | \
RSPAMD_TASK_STAGE_PRE_FILTERS | \
+ RSPAMD_TASK_STAGE_PROCESS_MESSAGE | \
RSPAMD_TASK_STAGE_FILTERS | \
RSPAMD_TASK_STAGE_CLASSIFIERS_PRE | \
RSPAMD_TASK_STAGE_CLASSIFIERS | \
#define RSPAMD_TASK_PROCESS_LEARN (RSPAMD_TASK_STAGE_CONNECT | \
RSPAMD_TASK_STAGE_ENVELOPE | \
RSPAMD_TASK_STAGE_READ_MESSAGE | \
+ RSPAMD_TASK_STAGE_PROCESS_MESSAGE | \
RSPAMD_TASK_STAGE_CLASSIFIERS_PRE | \
RSPAMD_TASK_STAGE_CLASSIFIERS | \
RSPAMD_TASK_STAGE_CLASSIFIERS_POST | \
#define RSPAMD_TASK_FLAG_MIME (1 << 0)
#define RSPAMD_TASK_FLAG_JSON (1 << 1)
-#define RSPAMD_TASK_FLAG_SKIP_EXTRA (1 << 2)
+#define RSPAMD_TASK_FLAG_SKIP_PROCESS (1 << 2)
#define RSPAMD_TASK_FLAG_SKIP (1 << 3)
#define RSPAMD_TASK_FLAG_EXT_URLS (1 << 4)
#define RSPAMD_TASK_FLAG_SPAMC (1 << 5)
if (task != NULL) {
if (task->msg.len > 0) {
- if (rspamd_message_parse (task) == 0) {
+ if (rspamd_message_parse (task)) {
lua_pushboolean (L, TRUE);
+ rspamd_message_process (task);
}
else {
lua_pushboolean (L, FALSE);
"Message processing error");
return;
}
+
+ rspamd_message_process (task);
}
PTR_ARRAY_FOREACH (fuzzy_module_ctx->fuzzy_rules, i, rule) {
continue;
}
+ rspamd_message_process (task);
lua_pushcfunction (L, &rspamd_lua_traceback);
err_idx = lua_gettop (L);