[Mimedefang] mimedefang filter > filter file names < ??

Troy R. LeBouef troy at lebouef.com
Tue Aug 5 21:58:09 EDT 2003


Well this is what I did ... Not working though ?? 

# This procedure returns true for entities with bad filenames.
sub filter_bad_filename ($) {
    my($entity) = @_;
    my($bad_exts, $re);
>>>    my($bad_files);

    # Bad extensions
    $bad_exts =
'(ade|adp|app|asd|asf|asx|bas|bat|chm|cmd|com|cpl|crt|dll|exe|fxp|hlp|ht
a|hto|inf|ini|ins|isp|jse?|lib|lnk|mdb|mde|msc|msi|msp|mst|ocx|pcd|pif|p
rg|reg|scr|sct|sh|shb|shs|sys|url|vb|vbe|vbs|vcs|vxd|wmd|wms|wmz|wsc|wsf
|wsh|\{)';
    # Bad files
>>>    $bad_files = '(file.zip|\{)';

    # Do not allow:
    # - curlies
    # - bad extensions (possibly with trailing dots) at end or
    #   followed by non-alphanum
>>>    $re = '\.' . $bad_exts . $bad_files . '\.*([^-A-Za-z0-9_.,]|$)';
    return re_match($entity, $re);
}

-----Original Message-----
From: Cormack, Ken [mailto:kcormack at acs.roadway.com] 
Sent: Tuesday, August 05, 2003 3:56 PM
To: mimedefang at lists.roaringpenguin.com
Subject: RE: [Mimedefang] mimedefang filter > filter file names < ??

My customer just happened to ask about this very thing this morning, as
well.

I kicked around the following idea with him... (snippet of that dialog,
below)

========== :: start of snippet ::
In mimedefang-filter, immediately after the list of extensions to
reject,
you'll see where the attachment name is evaluated against the list of
bad
extensions...

    # Do not allow:
    # - curlies
    # - bad extensions (possibly with trailing dots) at end or
    #   followed by non-alphanum
    $re = '\.' . $bad_exts . '\.*([^-A-Za-z0-9_.,]|$)';
    return re_match($entity, $re);

Since it's a regular expression, it should be possible to do something
like
this.  In addition to "#bad_exts =", we could define:

    "$bad_filenames = '(message.zip|badname2.foo)'  ...etc

Then, change the comparison to this:

    $re = '\.' . $bad_exts . $bad_filenames . '\.*([^-A-Za-z0-9_.,]|$)';
    return re_match($entity, $re);

A few lines above that, this would have to change, too...
    my($bad_exts, $re);

You know perl better than I, so does it look good to you?
=========== :: end of snippet ::

He and I have both been busy today, so the discussion hasnt yet gone any
further than this since this morning, but I dont see any great
difficulty
(unless my perl syntax is wrong, in the expanded regex test - I'm not
strong
in perl.)

Ken

-----Original Message-----
From: troy at lebouef.com [mailto:troy at lebouef.com]
Sent: Tuesday, August 05, 2003 4:15 PM
To: mimedefang at lists.roaringpenguin.com
Subject: [Mimedefang] mimedefang filter > filter file names < ??


Anyone know how to modify fimedefang-filter in order to filter names of
files and not just extentions ?

And if so , an example of the mod would be great ... Thanks in advance.

Troy

_______________________________________________
MIMEDefang mailing list
MIMEDefang at lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
_______________________________________________
MIMEDefang mailing list
MIMEDefang at lists.roaringpenguin.com
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang




More information about the MIMEDefang mailing list