aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-09 18:02:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-09 18:02:30 +0000
commitbba8973b4af2ee14b0007e97337bf9e6ff34ae1a (patch)
tree4369f623f65b417b4e257dfeb58e0850ef05f185
parent6d3508fb34675bd329fc9fdd3bb17c7647ad47d2 (diff)
downloadrspamd-bba8973b4af2ee14b0007e97337bf9e6ff34ae1a.tar.gz
rspamd-bba8973b4af2ee14b0007e97337bf9e6ff34ae1a.zip
Add rawmime class
-rw-r--r--src/libmime/mime_expressions.c5
-rw-r--r--src/libserver/re_cache.c10
-rw-r--r--src/libserver/re_cache.h1
-rw-r--r--src/lua/lua_config.c2
-rw-r--r--src/lua/lua_task.c2
-rw-r--r--src/plugins/lua/spamassassin.lua8
6 files changed, 25 insertions, 3 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 373ec955e..cf9f29fac 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -303,6 +303,10 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line)
result->type = RSPAMD_RE_MIME;
p++;
break;
+ case 'Q':
+ result->type = RSPAMD_RE_RAWMIME;
+ p++;
+ break;
case 'U':
result->type = RSPAMD_RE_URL;
p++;
@@ -743,6 +747,7 @@ rspamd_mime_expr_priority (rspamd_expression_atom_t *atom)
ret = 90;
break;
case RSPAMD_RE_MIME:
+ case RSPAMD_RE_RAWMIME:
ret = 10;
break;
default:
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index f38b254ef..da25040f8 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -633,6 +633,7 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
rspamd_regexp_get_pattern (re), ret);
break;
case RSPAMD_RE_MIME:
+ case RSPAMD_RE_RAWMIME:
/* Iterate throught text parts */
for (i = 0; i < task->text_parts->len; i++) {
part = g_ptr_array_index (task->text_parts, i);
@@ -647,9 +648,10 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
raw = TRUE;
}
/* Select data for regexp */
- if (raw) {
+ if (re_class->type == RSPAMD_RE_RAWMIME) {
in = part->orig->data;
len = part->orig->len;
+ raw = TRUE;
}
else {
in = part->content->data;
@@ -820,6 +822,9 @@ rspamd_re_cache_type_to_string (enum rspamd_re_type type)
case RSPAMD_RE_MIME:
ret = "part";
break;
+ case RSPAMD_RE_RAWMIME:
+ ret = "raw part";
+ break;
case RSPAMD_RE_BODY:
ret = "rawbody";
break;
@@ -849,6 +854,9 @@ rspamd_re_cache_type_from_string (const char *str)
else if (strcmp (str, "mime") == 0) {
ret = RSPAMD_RE_MIME;
}
+ else if (strcmp (str, "rawmime") == 0) {
+ ret = RSPAMD_RE_RAWMIME;
+ }
else if (strcmp (str, "body") == 0) {
ret = RSPAMD_RE_BODY;
}
diff --git a/src/libserver/re_cache.h b/src/libserver/re_cache.h
index 0fffc2d7c..1f0ab7c9b 100644
--- a/src/libserver/re_cache.h
+++ b/src/libserver/re_cache.h
@@ -36,6 +36,7 @@ enum rspamd_re_type {
RSPAMD_RE_RAWHEADER,
RSPAMD_RE_ALLHEADER,
RSPAMD_RE_MIME,
+ RSPAMD_RE_RAWMIME,
RSPAMD_RE_URL,
RSPAMD_RE_BODY,
RSPAMD_RE_MAX
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index b574cba59..e079517a4 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -357,6 +357,7 @@ LUA_FUNCTION_DEF (config, newindex);
* - `re`* : regular expression object
* - `type`*: type of regular expression:
* + `mime`: mime regexp
+ * + `rawmime`: raw mime regexp
* + `header`: header regexp
* + `rawheader`: raw header expression
* + `body`: raw body regexp
@@ -1571,6 +1572,7 @@ lua_config_register_regexp (lua_State *L)
* - `re`* : regular expression object
* - `type`*: type of regular expression:
* + `mime`: mime regexp
+ * + `rawmime`: raw mime regexp
* + `header`: header regexp
* + `rawheader`: raw header expression
* + `body`: raw body regexp
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 8529489f6..efe755ad7 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -436,6 +436,7 @@ LUA_FUNCTION_DEF (task, set_settings);
* + `mime`: mime regexp
* + `header`: header regexp
* + `rawheader`: raw header expression
+ * + `rawmime`: raw mime regexp
* + `body`: raw body regexp
* + `url`: url regexp
* - `header`: for header and rawheader regexp means the name of header
@@ -2017,6 +2018,7 @@ lua_task_process_regexp (lua_State *L)
* - `re`* : regular expression object
* - `type`*: type of regular expression:
* + `mime`: mime regexp
+ * + `rawmime`: raw mime regexp
* + `header`: header regexp
* + `rawheader`: raw header expression
* + `body`: raw body regexp
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index e2708bbeb..10457d2d7 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -659,9 +659,10 @@ local function process_sa_conf(f)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
cur_rule['raw'] = true
if cur_rule['re'] then
+
rspamd_config:register_regexp({
re = cur_rule['re'],
- type = 'mime',
+ type = 'rawmime',
})
valid_rule = true
cur_rule['re']:set_limit(match_limit)
@@ -1107,9 +1108,12 @@ _.each(function(k, r)
return 0
end
+ local t = 'mime'
+ if r['raw'] then t = 'rawmime' end
+
return task:process_regexp({
re = r['re'],
- type = 'mime',
+ type = t,
})
end
if r['score'] then