Courier::Filter::Module::Parts(3pm) | User Contributed Perl Documentation | Courier::Filter::Module::Parts(3pm) |
Courier::Filter::Module::Parts - Message (MIME multipart and ZIP archive) parts filter module for the Courier::Filter framework
use Courier::Filter::Module::Parts; my $module = Courier::Filter::Module::Parts->new( max_message_size => $max_message_size, max_part_size => $max_part_size, views => ['raw', 'zip'], signatures => [ { # One or more of the following options: mime_type => 'text/html' || qr/html/i, file_name => 'file_name.ext' || qr/\.(com|exe)$/i, size => 106496, digest_md5 => 'b09e26c292759d654633d3c8ed00d18d', encrypted => 0, # Optionally any of the following: views => ['raw', 'zip'], response => $response_text }, ... ], logger => $logger, inverse => 0, trusting => 0, testing => 0, debugging => 0 ); my $filter = Courier::Filter->new( ... modules => [ $module ], ... );
This class is a filter module class for use with Courier::Filter. It matches a message if one of the message's parts (MIME parts, or files in a ZIP archive) matches one of the configured signatures.
The following constructor is provided:
%options is a list of key/value pairs representing any of the following options:
The following views are supported:
As MIME multipart and ZIP archive processing can be quite CPU- and memory-intensive (although the Parts filter module makes use of temporary files since version 0.13), you should definitely restrict the message size to some sensible value that easily fits in your server's memory. 1024**2 (1MB) should be appropriate for most uses of this filter module.
The "max_message_size" option was previously called "max_size", but the latter is now deprecated and may not be supported in future versions of the Parts filter module.
Defaults to the value of the "max_message_size" option, so you don't really need to specify a part size limit if you are comfortable with using the same value for both. See the "max_message_size" option for its default.
If you make use of the 'zip' view, be aware of the risk posed by so-called decompression bombs, which allow messages to easily fall below the overall message size limit, while a file in a small attached ZIP archive can decompress to a huge size. The part size limit prevents huge files from being decompressed.
Signature aspects
Aspects may either be scalar values (for exact, case-sensitive matches), or regular expression objects created with the "qr//" operator (for inexact, partial matches). For a signature to match a message part, all of the signature's specified aspects must match those of the message part. For the filter module to match a message, any of the signatures must match any of the message's parts.
A signature aspect can be any of the following:
Signature options
A signature option can be any of the following:
Example
So for instance, a signature list could look like this:
signatures => [ { mime_type => qr/html/i, response => 'No HTML mail, please.' }, { file_name => qr/\.(com|exe|lnk|pif|scr|vbs)$/i, response => 'Executable content detected' }, { size => 106496, digest_md5 => 'b09e26c292759d654633d3c8ed00d18d', views => ['raw', 'zip'], # Look into ZIP archives, too! response => 'Worm detected: W32.Swen' }, { size => 22528, # Cannot set a specific digest_md5 since W32.Mydoom # is polymorphic. response => 'Worm suspected: W32.Mydoom' }, { encrypted => 1, views => ['zip'], response => 'Worm suspected ' . '(only worms and fools use ZIP encryption)' } ]
All options of the Courier::Filter::Module constructor are also supported by the constructor of the Parts filter module. Please see "new" in Courier::Filter::Module for their descriptions.
See "Instance methods" in Courier::Filter::Module for a description of the provided instance methods.
Courier::Filter::Module, Courier::Filter::Overview.
For AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview.
Julian Mehnle <julian@mehnle.net>
2022-10-21 | perl v5.34.0 |