[Mimedefang] mimedefang-filter, string matching from a (big) data source?

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Thu Feb 26 08:10:19 EST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 26 Feb 2015, Fredrik Pettai wrote:

> I want to make a “semi” dynamic rule that would tag emails that matches a list of strings, something like this:

Transform the strings into a SpamAssassin config file and let do it that 
job. They found out that pattern matching takes lots of memory and CPU and 
therefore invented techniques to overcome those problems, e.g. by using 
pattern matching in C files.

You can then probe for your tags.

> sub filter {
>    my($entity, $fname, $ext, $type) = @_;
>
>    return if message_rejected();
>
>    if ($Sender =~ XYZ {
>
>        if ($Subject =~ [input from a list] ) {
>            action_change_header('Subject', “[ADD CUSTOM TAG]$Subject");
>        } else {
>
>            my $io;
>            if ($io = $entity->open("r")) {
>                while (defined($_ = $io->getline)) {
>                    if ( [input from a list] ) {
>                        action_change_header('Subject', “[ADD CUSTOM TAG]$Subject");
>                        last;
>                    }
>                }
>            $io->close;
>            }
>        }
>    }
>
>    return action_accept();
> }
>
>
> I wonder what the best solution would be to achieve this?
>
> Currently, the [input from a list] is a text file which holds a lot of strings, one per line, and is currently about 6000+ lines long...
> Is it a bad idea to open and read the text file from mimedefang-filter?
> Would it be better to generate a new version of mimedefang-filter with the content of the text file inline?
> Or should I consider something else?
>
> The text file is also updated, but not that frequently…

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEVAwUBVO8bO1GgR0+MU/4GAQJosQf/e1i0UGyl0lCSbbuZbEfe55fBedOPHHlZ
Z4iGNcnRxiPnrirwpUlBXhTg3ofPr3sStBatWV+p0jJMUFgbEsnUF7LUYHauy4aA
dLPPIyyQv0QYESmu+Z669g5qFBFknzXK37FVVywd4tl1t8ugeKUOAQRYFxAa5yh+
nDjP0oJ50OjvfgQMlu2I7o6zJbtMi5rSvmzvLHq82vCsTM+TQSMt17og3qEXvAiu
jd6UE9CFwn60uLGccxkW4jHVp2K9wkzwrFKvdSIFH0Z8t8LEVpQb8LWQE+zIrIrX
i2VU4yI6W2qNPF4eWJrPz/3Ca1p06ZHu7hXUx3fRNpGK8Ivt2S3Vsg==
=EjHb
-----END PGP SIGNATURE-----


More information about the MIMEDefang mailing list