return ext[1],ext[2],parts
end
- local function check_filename(fname, ct, is_archive)
+ local function check_filename(fname, ct, is_archive, part)
local ext,ext2,parts = gen_extension(fname)
-- ext is the last extension, LOWERCASED
-- ext2 is the one before last extension LOWERCASED
-- Double extension + bad extension == VERY bad
task:insert_result(settings['symbol_double_extension'], badness_mult,
string.format(".%s.%s", ext2, ext))
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", part:get_id(), '-'))
return
end
end
if badness_mult then
-- Just bad extension
task:insert_result(settings['symbol_bad_extension'], badness_mult, ext)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", part:get_id(), '-'))
end
end
if settings['archive_extensions'][ext] then
-- Archive in archive
task:insert_result(settings['symbol_archive_in_archive'], 1.0, ext)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", part:get_id(), '-'))
end
else
if ext2 then
-- Exclude multipart archive extensions, e.g. .zip.001
and not string.match(ext, '^%d+$')
then
- task:insert_result(settings['symbol_archive_in_archive'], 1.0, string.format(".%s.%s", ext2, ext))
+ task:insert_result(settings['symbol_archive_in_archive'],
+ 1.0, string.format(".%s.%s", ext2, ext))
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", part:get_id(), '-'))
end
else
check_extension(settings['bad_extensions'][ext], nil)
if not mtype then
task:insert_result(settings['symbol_unknown'], 1.0, 'missing content type')
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '~'))
else
-- Check for attachment
local filename = p:get_filename()
if filename then
filename = filename:gsub('[^%s%g]', '?')
- check_filename(filename, ct, false)
+ check_filename(filename, ct, false, p)
end
if p:is_archive() then
if arch:is_encrypted() then
task:insert_result(settings['symbol_encrypted_archive'], 1.0, filename)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '-'))
end
if check then
end
if f['encrypted'] then
- task:insert_result(settings['symbol_encrypted_archive'], 1.0, f['name'])
+ task:insert_result(settings['symbol_encrypted_archive'],
+ 1.0, f['name'])
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '-'))
end
if f['name'] then
- check_filename(f['name'], nil, true)
+ check_filename(f['name'], nil, true, p)
end
end
end
if n then
if n > 0 then
task:insert_result(settings['symbol_bad'], n, ct)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '-'))
elseif n < 0 then
task:insert_result(settings['symbol_good'], -n, ct)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '+'))
end
else
logger.warnx(task, 'unknown value: "%s" for content type %s in the map',
end
else
task:insert_result(settings['symbol_unknown'], 1.0, ct)
+ task:insert_result('MIME_TRACE', 0.0,
+ string.format("%s:%s", p:get_id(), '~'))
end
end
end
parent = id,
group = 'mime_types',
})
+ rspamd_config:register_symbol({
+ type = 'virtual,nostat',
+ name = 'MIME_TRACE',
+ parent = id,
+ group = 'mime_types',
+ score = 0,
+ })
else
lua_util.disable_module(N, "config")
end