aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-14 13:30:55 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-14 13:30:55 +0000
commitb22485f657c40c9b9fda9675d25c9294288c5732 (patch)
tree2ade5a2bfb8d39c7c1379dcc3ff72bb6b27c4188 /src/plugins
parente0fa8bf017a672d178f9024eeb46ce81eeaf188c (diff)
downloadrspamd-b22485f657c40c9b9fda9675d25c9294288c5732.tar.gz
rspamd-b22485f657c40c9b9fda9675d25c9294288c5732.zip
Allow processing images urls for SURBL
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/surbl.c47
-rw-r--r--src/plugins/surbl.h1
2 files changed, 48 insertions, 0 deletions
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 7572a0df8..8942f9ec5 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -48,6 +48,7 @@
#include "rspamd.h"
#include "surbl.h"
#include "utlist.h"
+#include "libserver/html.h"
#include "unix-std.h"
static struct surbl_ctx *surbl_module_ctx = NULL;
@@ -412,6 +413,15 @@ surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
0);
rspamd_rcl_add_doc_by_path (cfg,
"surbl.rule",
+ "Check images URLs with this URL list",
+ "images",
+ UCL_BOOLEAN,
+ NULL,
+ 0,
+ NULL,
+ 0);
+ rspamd_rcl_add_doc_by_path (cfg,
+ "surbl.rule",
"Parse IP bits in DNS reply, the content is 'symbol = <bit>'",
"bits",
UCL_OBJECT,
@@ -631,6 +641,7 @@ surbl_module_config (struct rspamd_config *cfg)
new_suffix->options |= SURBL_OPTION_NOIP;
}
}
+
cur = ucl_obj_get_key (cur_rule, "resolve_ip");
if (cur != NULL && cur->type == UCL_BOOLEAN) {
if (ucl_object_toboolean (cur)) {
@@ -638,6 +649,13 @@ surbl_module_config (struct rspamd_config *cfg)
}
}
+ cur = ucl_obj_get_key (cur_rule, "images");
+ if (cur != NULL && cur->type == UCL_BOOLEAN) {
+ if (ucl_object_toboolean (cur)) {
+ new_suffix->options |= SURBL_OPTION_CHECKIMAGES;
+ }
+ }
+
if ((new_suffix->options & (SURBL_OPTION_RESOLVEIP|SURBL_OPTION_NOIP)) ==
(SURBL_OPTION_NOIP|SURBL_OPTION_RESOLVEIP)) {
/* Mutually exclusive options */
@@ -1425,6 +1443,10 @@ surbl_test_url (struct rspamd_task *task, void *user_data)
{
struct redirector_param param;
struct suffix_item *suffix = user_data;
+ guint i, j;
+ struct mime_text_part *part;
+ struct html_image *img;
+ struct rspamd_url *url;
param.task = task;
param.suffix = suffix;
@@ -1433,4 +1455,29 @@ surbl_test_url (struct rspamd_task *task, void *user_data)
(rspamd_mempool_destruct_t)g_hash_table_unref,
param.tree);
g_hash_table_foreach (task->urls, surbl_tree_url_callback, &param);
+
+ /* We also need to check and process img URLs */
+ if (suffix->options & SURBL_OPTION_CHECKIMAGES) {
+ for (i = 0; i < task->text_parts->len; i ++) {
+ part = g_ptr_array_index (task->text_parts, i);
+
+ if (part->html && part->html->images) {
+ for (j = 0; j < part->html->images->len; j ++) {
+ img = g_ptr_array_index (part->html->images, j);
+
+ if ((img->flags & RSPAMD_HTML_FLAG_IMAGE_EXTERNAL)
+ && img->src) {
+ url = rspamd_html_process_url (task->task_pool,
+ img->src, strlen (img->src), NULL);
+
+ if (url) {
+ surbl_tree_url_callback (url, url, &param);
+ msg_debug_task ("checked image url %s over %s",
+ img->src, suffix->suffix);
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/plugins/surbl.h b/src/plugins/surbl.h
index 2477032b9..68b27c3f0 100644
--- a/src/plugins/surbl.h
+++ b/src/plugins/surbl.h
@@ -14,6 +14,7 @@
#define DEFAULT_SURBL_SUFFIX "multi.surbl.org"
#define SURBL_OPTION_NOIP (1 << 0)
#define SURBL_OPTION_RESOLVEIP (1 << 1)
+#define SURBL_OPTION_CHECKIMAGES (1 << 2)
#define MAX_LEVELS 10
struct surbl_ctx {