aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-07 12:14:01 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-07 12:14:01 +0100
commit33773cc81fe34d96d27aba8a3a752958302f93f3 (patch)
tree5bbb22ca302378dd284ec7b3ee0e87dcea3a3fe6
parent1b3208fd723c0de8239386d1f60ca088e9f8a29f (diff)
downloadrspamd-33773cc81fe34d96d27aba8a3a752958302f93f3.tar.gz
rspamd-33773cc81fe34d96d27aba8a3a752958302f93f3.zip
[Feature] Insert redirected URL to the urls list
-rw-r--r--src/libserver/protocol.c52
-rw-r--r--src/libserver/url.h1
-rw-r--r--src/plugins/surbl.c7
3 files changed, 43 insertions, 17 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 35c912f59..e32dfc6e5 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -595,6 +595,39 @@ struct tree_cb_data {
struct rspamd_task *task;
};
+static ucl_object_t *
+rspamd_protocol_extended_url (struct rspamd_url *url)
+{
+ ucl_object_t *obj, *elt;
+
+ obj = ucl_object_typed_new (UCL_OBJECT);
+
+ elt = ucl_object_fromlstring (url->string, url->urllen);
+ ucl_object_insert_key (obj, elt, "url", 0, false);
+
+ if (url->surbllen > 0) {
+ elt = ucl_object_fromlstring (url->surbl, url->surbllen);
+ ucl_object_insert_key (obj, elt, "surbl", 0, false);
+ }
+ if (url->hostlen > 0) {
+ elt = ucl_object_fromlstring (url->host, url->hostlen);
+ ucl_object_insert_key (obj, elt, "host", 0, false);
+ }
+
+ elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_PHISHED);
+ ucl_object_insert_key (obj, elt, "phished", 0, false);
+
+ elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_REDIRECTED);
+ ucl_object_insert_key (obj, elt, "redirected", 0, false);
+
+ if (url->phished_url) {
+ elt = rspamd_protocol_extended_url (url->phished_url);
+ ucl_object_insert_key (obj, elt, "orig_url", 0, false);
+ }
+
+ return obj;
+}
+
/*
* Callback for writing urls
*/
@@ -603,7 +636,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud)
{
struct tree_cb_data *cb = ud;
struct rspamd_url *url = value;
- ucl_object_t *obj, *elt;
+ ucl_object_t *obj;
struct rspamd_task *task = cb->task;
const gchar *user_field = "unknown";
gboolean has_user = FALSE;
@@ -612,22 +645,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud)
obj = ucl_object_fromlstring (url->string, url->urllen);
}
else {
- obj = ucl_object_typed_new (UCL_OBJECT);
-
- elt = ucl_object_fromlstring (url->string, url->urllen);
- ucl_object_insert_key (obj, elt, "url", 0, false);
-
- if (url->surbllen > 0) {
- elt = ucl_object_fromlstring (url->surbl, url->surbllen);
- ucl_object_insert_key (obj, elt, "surbl", 0, false);
- }
- if (url->hostlen > 0) {
- elt = ucl_object_fromlstring (url->host, url->hostlen);
- ucl_object_insert_key (obj, elt, "host", 0, false);
- }
-
- elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_PHISHED);
- ucl_object_insert_key (obj, elt, "phished", 0, false);
+ obj = rspamd_protocol_extended_url (url);
}
ucl_array_append (cb->top, obj);
diff --git a/src/libserver/url.h b/src/libserver/url.h
index 4d38e3d79..7dfcb05af 100644
--- a/src/libserver/url.h
+++ b/src/libserver/url.h
@@ -13,6 +13,7 @@ enum rspamd_url_flags {
RSPAMD_URL_FLAG_PHISHED = 1 << 0,
RSPAMD_URL_FLAG_NUMERIC = 1 << 1,
RSPAMD_URL_FLAG_OBSCURED = 1 << 2,
+ RSPAMD_URL_FLAG_REDIRECTED = 1 << 3,
};
struct rspamd_url {
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index dcf69f8f2..ad2c3be9c 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -1281,6 +1281,13 @@ surbl_redirector_finish (struct rspamd_http_connection *conn,
task->task_pool);
if (r == URI_ERRNO_OK) {
+ if (!g_hash_table_lookup (task->urls, redirected_url)) {
+ g_hash_table_insert (task->urls, redirected_url,
+ redirected_url);
+ redirected_url->phished_url = param->url;
+ redirected_url->flags |= RSPAMD_URL_FLAG_REDIRECTED;
+ }
+
make_surbl_requests (redirected_url,
param->task,
param->suffix,