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'
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
* @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),
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},
return 1;
}
+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)
{