[Mimedefang] is_multipart error

Robert Covell rcovell at rolet.com
Fri Apr 26 09:39:50 EDT 2002


My perl is stock from the Slackware 8.0 and is version: v5.6.1 built for
i386-linux

I have upgraded to MIMEdeFang 2.7 but my reports still say 2.6, not sure
why.


And my filter is:
# -*- Perl -*-
#***********************************************************************
#
# mimedefang-filter
#
# Suggested minimum-protection filter for Microsoft Windows clients, plus
# SpamAssassin checks.
#
# Copyright (C) 2002 Roaring Penguin Software Inc.
#
# This program may be distributed under the terms of the GNU General
# Public License, Version 2, or (at your option) any later version.
#
# $Id: filter-using-spamassassin,v 1.4 2002/02/26 13:25:47 dfs Exp $
#***********************************************************************

#***********************************************************************
# Set administrator's name here.  The administrator receives
# quarantine messages and is listed as the contact for site-wide
# MIMEDefang policy.  A good example would be 'defang-admin at mydomain.com'
#***********************************************************************
$Administrator = 'spamcop at rolet.com';

#***********************************************************************
# Set the e-mail address from which MIMEDefang quarantine warnings and
# user notifications appear to come.  A good example would be
# 'mimedefang at mydomain.com'.  Make sure to have an alias for this
# address if you want replies to it to work.
#***********************************************************************
$DaemonAddress = 'spamcop at rolet.com';

#***********************************************************************
# Set various stupid things your mail client does below.
#***********************************************************************

# Set the next one if your mail client cannot handle nested multipart
# messages
$Stupidity{"flatten"} = 0;

# Set the next one if your mail client cannot handle multiple "inline"
# parts (*cough* Exchange *cough* Outlook)
$Stupidity{"NoMultipleInlines"} = 0;

#***********************************************************************
# %PROCEDURE: filter_begin
# %ARGUMENTS:
#  None
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  Called just before e-mail parts are processed
#***********************************************************************
sub filter_begin {
    # ALWAYS drop messages with suspicious chars in headers or body
    if ($SuspiciousCharsInHeaders || $SuspiciousCharsInBody) {
	action_quarantine_entire_message();
	if ($SuspiciousCharsInHeaders) {
	    action_notify_administrator("Message quarantined because of suspicious
characters in headers");
	} else {
	    action_notify_administrator("Message quarantined because of suspicious
characters in body");
	}
	# Do NOT allow message to reach recipient(s)
	action_discard();
    }

    # action_rebuild() is DEPRECATED.  It causes all kinds of problems.
    # action_rebuild();

    # Spam checks

    $Boilerplate = "";
    $action = "send";

    if ((-s "./INPUTMSG") <= (200 * 1024)) {
        my($hits, $req, $names, $report) = spam_assassin_check();
        $SAReport = $report;
        if ($hits >= $req) {
            action_add_header("X-Spam-Warning", "SpamAssassin says this
message is SPAM");
            action_add_header("X-Spam-Status", "Yes, hits=$hits
required=$req");
            action_add_header("X-Spam-Report","$report");
	    $action = "notify";
	    $Boilerplate = $report;
#	    if ($RelayAddr eq "208.1.216.6")
#	    {
#		$action = "send";
#	    }
#	    if ($RelayHostname eq "alertsnat.marketwatchmail.com")
#	    {
#		$action = "send";
#	    }
#	    if ($RelayHostname eq "q2.marketwatchmail.com")
#	    {
#		$action = "send";
#	    }
#	    if ($RelayHostname eq "q3.marketwatchmail.com")
#	    {
#		$action = "send";
#	    }
        } else {
            action_add_header("X-Spam-Status", "No");
        }
        # if we're quite confident it actually IS spam, just bounce it
        if ($hits > 9) {
	     $action = "drop";
###          $bounce = "yes";
###          action_quarantine_entire_message();
###	  action_discard();
##	  action_notify_administrator("Message quarantined because of SPAM");
##          action_bounce("Message seems to be spam, rejected");
        }
    }


##    my($hits, $req, $names, $report) = spam_assassin_check();
##    if ($hits >= $req) {
##	action_add_header("X-Spam-Warning", "SpamAssassin says this message is
SPAM");
##        $Boilerplate = $report;
##    }
}

#***********************************************************************
# %PROCEDURE: filter
# %ARGUMENTS:
#  entity -- a Mime::Entity object (see MIME-tools documentation for
details)
#  fname -- the suggested filename, taken from the MIME Content-Disposition:
#           header.  If no filename was suggested, then fname is ""
#  ext -- the file extension (everything from the last period in the name
#         to the end of the name, including the period.)
#  type -- the MIME type, taken from the Content-Type: header.
#
#  NOTE: There are two likely and one unlikely place for a filename to
#  appear in a MIME message:  In Content-Disposition: filename, in
#  Content-Type: name, and in Content-Description.  If you are paranoid,
#  you will use the re_match and re_match_ext functions, which return true
#  if ANY of these possibilities match.  re_match checks the whole name;
#  re_match_ext checks the extension.  See the sample filter below for
usage.
# %RETURNS:
#  Nothing
# %DESCRIPTION:
#  This function is called once for each part of a MIME message.
#  There are many action_*() routines which can decide the fate
#  of each part; see the mimedefang-filter man page.
#***********************************************************************
sub filter {
    my($entity, $fname, $ext, $type) = @_;

    if (re_match_ext($entity,
'^\.(bat|chm|cmd|com|cpl|dll|eml|exe|hlp|hta|ini|js|lib|lnk|msi|msp|ocx|pif|
reg|reg|scr|sct|shb|shs|sys|vbe|vbs?|vxd|wsf|wsh)$')) {
	action_notify_sender("Your message contained an attachment ($fname)
considered to be potentially harmful.  This has been removed and not sent to
the recipient.  If the attachment was valid please find other means of
sending the data.  You might try utilizing WinZip (PC) or Stuff It(Mac) to
compress the data and resend the email.\n\n-Rolet Email Support");
	return action_quarantine($entity, "An attachment named $fname was removed
from this document as it\nconstituted a security hazard.  If you require
this document, please contact\nthe sender and arrange an alternate means of
receiving it.\n");
    }

    # Uncomment next three lines ONLY if you have installed the Anomy tools!
    #if ($type eq "text/html") {
    #    return anomy_clean_html($entity);
    #}

    return action_accept();
}

# If SpamAssassin found SPAM, append report.
sub filter_end {
    my($entity) = @_;
    if ($action eq "drop") {
	action_quarantine_entire_message();
	action_discard();
    }
    if ($action eq "notify") {
	action_change_header("Subject", "****POTENTIAL SPAM****" . "$Subject");
        append_boilerplate("$entity", "$Boilerplate");
    }
}

#***********************************************************************
# %PROCEDURE: defang_warning
# %ARGUMENTS:
#  oldfname -- the old file name of an attachment
#  fname -- the new "defanged" name
# %RETURNS:
#  A warning message
# %DESCRIPTION:
#  This function customizes the warning message when an attachment
#  is defanged.
#***********************************************************************
sub defang_warning {
    my($oldfname, $fname) = @_;
    return
	"An attachment named '$oldfname' was converted to '$fname'.\n" .
	"To recover the file, right-click on the attachment and Save As\n" .
	"'$oldfname'\n";
}

# DO NOT delete the next line, or Perl will complain.
1;


-----Original Message-----
From: mimedefang-admin at lists.roaringpenguin.com
[mailto:mimedefang-admin at lists.roaringpenguin.com]On Behalf Of Jason
Englander
Sent: Thursday, April 25, 2002 12:21 PM
To: mimedefang at lists.roaringpenguin.com
Subject: RE: [Mimedefang] is_multipart error


On Thu, 25 Apr 2002, Robert Covell wrote:

> Ok, I have made no headway at all.  I cannot repeat the error and even
> forced mimedefang.pl to use: use MIME::Entity;

I don't have a clue either, but for sh*ts and grins can you post what
version of Perl you use (and if it's source built or not) and your filter?

  Jason



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






More information about the MIMEDefang mailing list