diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-25 18:03:30 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-25 18:03:30 +0000 |
commit | b6a5d60e0c8b2ab385ea0dfdd2b3e8fe3d2a5d60 (patch) | |
tree | 96daadc4608ea3451d7ffb5405d80c245d5c929e /src | |
parent | 898a828cf646830dff0d4edb24104a6152196bb8 (diff) | |
download | rspamd-b6a5d60e0c8b2ab385ea0dfdd2b3e8fe3d2a5d60.tar.gz rspamd-b6a5d60e0c8b2ab385ea0dfdd2b3e8fe3d2a5d60.zip |
Add extended output format for URLs.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/protocol.c | 34 | ||||
-rw-r--r-- | src/libserver/task.h | 1 | ||||
-rw-r--r-- | src/libserver/url.h | 7 |
3 files changed, 35 insertions, 7 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index f4e8da09d..d735d62fd 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -90,6 +90,7 @@ #define QUEUE_ID_HEADER "Queue-ID" #define ERROR_HEADER "Error" #define USER_HEADER "User" +#define URLS_HEADER "URL-Format" #define PASS_HEADER "Pass" #define JSON_HEADER "Json" #define HOSTNAME_HEADER "Hostname" @@ -383,6 +384,13 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, if (g_ascii_strcasecmp (headern, USER_HEADER) == 0) { task->user = h->value->str; } + if (g_ascii_strcasecmp (headern, URLS_HEADER) == 0) { + if (h->value->len == sizeof ("extended") - 1 && + g_ascii_strcasecmp (h->value->str, "extended") == 0) { + task->extended_urls = TRUE; + debug_task ("extended urls information"); + } + } else { validh = FALSE; } @@ -485,9 +493,31 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud) { struct tree_cb_data *cb = ud; struct uri *url = value; - ucl_object_t *obj; + ucl_object_t *obj, *elt; + + if (!cb->task->extended_urls) { + obj = ucl_object_fromlstring (url->host, url->hostlen); + } + else { + obj = ucl_object_typed_new (UCL_OBJECT); - obj = ucl_object_fromlstring (url->host, url->hostlen); + elt = ucl_object_fromstring (url->string); + ucl_object_insert_key (obj, elt, "url", 0, false); + + elt = ucl_object_fromlstring (url->host, url->hostlen); + ucl_object_insert_key (obj, elt, "host", 0, false); + + elt = ucl_object_fromlstring (url->data, url->datalen); + ucl_object_insert_key (obj, elt, "data", 0, false); + + if (url->surbl) { + elt = ucl_object_fromlstring (url->surbl, url->surbllen); + ucl_object_insert_key (obj, elt, "surbl", 0, false); + } + + elt = ucl_object_frombool (url->is_phished); + ucl_object_insert_key (obj, elt, "phished", 0, false); + } DL_APPEND (cb->top->value.av, obj); if (cb->task->cfg->log_urls) { diff --git a/src/libserver/task.h b/src/libserver/task.h index 2fd634e54..1261dd134 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -79,6 +79,7 @@ struct rspamd_task { gboolean is_json; /**< output is JSON */ gboolean skip_extra_filters; /**< skip pre and post filters */ gboolean is_skipped; /**< whether message was skipped by configuration */ + gboolean extended_urls; /**< output URLs in details */ gchar *helo; /**< helo header value */ gchar *queue_id; /**< queue id if specified */ diff --git a/src/libserver/url.h b/src/libserver/url.h index 5b508e056..c9700436b 100644 --- a/src/libserver/url.h +++ b/src/libserver/url.h @@ -21,14 +21,10 @@ struct uri { gchar *password; gchar *host; gchar *port; - /* @data can contain both the path and query uri fields. - * It can never be NULL but can have zero length. */ gchar *data; gchar *fragment; - /* @post can contain some special encoded form data, used internally - * to make form data handling more efficient. The data is marked by - * POST_CHAR in the uri string. */ gchar *post; + gchar *surbl; struct uri *phished_url; @@ -41,6 +37,7 @@ struct uri { guint portlen; guint datalen; guint fragmentlen; + guint surbllen; /* Flags */ gboolean ipv6; /* URI contains IPv6 host */ |