Whitelisting File Extension Types?

Kelly Marchewa kmarchewa at midamcorp.com
Thu Mar 24 20:39:56 CET 2022


Hello,

I know one can block file extensions in amavis using the 
$banned_file_name_re variable. However, I would like to adopt a "deny by 
default" approach and whitelist only a handful of file types.

I thought I could use a regex such as:

qr'^(?!.*\.gif|.*\.heic|.*\.jpg|.*\.jpeg|.*\.mp4|.*\.png|.*\.pdf|.*\.txt|.*\.wav|.*\.webm)(.*)$'i

However, even if I send an "allowed" file type (such as a PDF) the 
"banned content" action is triggered with the following message:

"No viruses were found.

Banned name: text/plain,.asc
Content type: Banned
Internal reference code for the message is 891228-01/WX804g-n9ggX"


I am not sure why it is finding an "asc" file as only a PDF was 
attached. Furthermore, even if I added ".asc" to the list above, it is 
still flagging the email as having banned content.

I have tested the Regex on https://regexr.com/ and it seems to work as 
expected. What might the issue be?

-- 
Thanks,
Kelly Marchewa
Software Engineer | Midamerica Hotels Corporation



More information about the amavis-users mailing list