aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rules/misc.lua12
-rw-r--r--src/lua/lua_mimepart.c27
2 files changed, 38 insertions, 1 deletions
diff --git a/rules/misc.lua b/rules/misc.lua
index 8cfd71619..de088ae4c 100644
--- a/rules/misc.lua
+++ b/rules/misc.lua
@@ -168,7 +168,7 @@ rspamd_config.R_SUSPICIOUS_URL = {
end
return false
end,
- score = 6.0,
+ score = 5.0,
one_shot = true,
description = 'Obfusicated or suspicious URL has been found in a message',
group = 'url'
@@ -183,6 +183,16 @@ rspamd_config.BROKEN_HEADERS = {
description = 'Headers structure is likely broken'
}
+rspamd_config.BROKEN_CONTENT_TYPE = {
+ callback = function(task)
+ return fun.any(function(p) return p:is_broken() end,
+ task:get_parts())
+ end,
+ score = 3.0,
+ group = 'header',
+ description = 'Message has part with broken content type'
+}
+
rspamd_config.HEADER_RCONFIRM_MISMATCH = {
callback = function (task)
local header_from = nil
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index dba66b818..6d17c3a66 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -288,6 +288,12 @@ LUA_FUNCTION_DEF (mimepart, get_text);
* @return {string} 128 characters hex string with digest of the part
*/
LUA_FUNCTION_DEF (mimepart, get_digest);
+/***
+ * @method mime_part:is_broken()
+ * Returns true if mime part has incorrectly specified content type
+ * @return {bool} true if a part has bad content type
+ */
+LUA_FUNCTION_DEF (mimepart, is_broken);
static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, get_content),
@@ -302,6 +308,7 @@ static const struct luaL_reg mimepartlib_m[] = {
LUA_INTERFACE_DEF (mimepart, is_archive),
LUA_INTERFACE_DEF (mimepart, get_archive),
LUA_INTERFACE_DEF (mimepart, is_text),
+ LUA_INTERFACE_DEF (mimepart, is_broken),
LUA_INTERFACE_DEF (mimepart, get_text),
LUA_INTERFACE_DEF (mimepart, get_digest),
{"__tostring", rspamd_lua_class_tostring},
@@ -739,6 +746,26 @@ lua_mimepart_is_text (lua_State * L)
}
static gint
+lua_mimepart_is_broken (lua_State * L)
+{
+ struct rspamd_mime_part *part = lua_check_mimepart (L);
+
+ if (part == NULL) {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ if (part->ct) {
+ lua_pushboolean (L, (part->ct->flags & RSPAMD_CONTENT_TYPE_BROKEN) ?
+ true : false);
+ }
+ else {
+ lua_pushboolean (L, true);
+ }
+
+ return 1;
+}
+
+static gint
lua_mimepart_get_image (lua_State * L)
{
struct rspamd_mime_part *part = lua_check_mimepart (L);