From: Dmitriy Alekseev <1865999+dragoangel@users.noreply.github.com> Date: Thu, 11 Apr 2024 16:17:08 +0000 (+0300) Subject: [Enhancement] Exclude false positives of MIME_DOUBLE_BAD_EXTENSION X-Git-Tag: 3.9.0~70^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7d14e4af43ee1435b47a5d38b699b24bf598d4bf;p=rspamd.git [Enhancement] Exclude false positives of MIME_DOUBLE_BAD_EXTENSION If we detected extension of the file and this extension is equal to the real extension then we should not pass second extension to check function as it will trigger false positive for MIME_DOUBLE_BAD_EXTENSION. --- diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index 167ed38e2..71b6481d8 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -397,7 +397,12 @@ local function check_mime_type(task) if ext2 then local score1 = check_tables(ext) local score2 = check_tables(ext2) - check_extension(score1, score2) + -- Check if detected extension match real extension + if detected_ext and detected_ext == ext then + check_extension(score1, nil) + else + check_extension(score1, score2) + end -- Check for archive cloaking like .zip.gz if settings['archive_extensions'][ext2] -- Exclude multipart archive extensions, e.g. .zip.001