/
etc
/
mail
/
spamassassin
/
CMAE-SA
/
/etc/mail/spamassassin/CMAE-SA
mkdir
upload
Name
Size
Mode
Actions
cloudmark/
-
0755
rm
CMAE.pm
5685
0444
edit
dl
rm
INSTALL
27033
0644
edit
dl
rm
install.pl
6407
0755
edit
dl
rm
README
6065
0644
edit
dl
rm
sa_cmae_plugin.cfg.sample
4278
0644
edit
dl
rm
SpamDNA.tar.gz
5994664
0700
edit
dl
rm
Edit:
/etc/mail/spamassassin/CMAE-SA/CMAE.pm
(5685B)
# $Id: CMAE.pm,v 1.14 2008/02/05 17:57:56 jrobin Exp $ package Mail::SpamAssassin::Plugin::CMAE; use Mail::SpamAssassin::Plugin; use strict; use warnings; use bytes; use Cloudmark::CMAE::Client qw( :errors ); use vars qw(@ISA); @ISA = qw(Mail::SpamAssassin::Plugin); my $VERSION = "1.2.0.14"; sub new { my $class = shift; my $mailsaobject = shift; # configuration file for this filter my $CONFIG = '/etc/sa_cmae_plugin.cfg'; $class = ref($class) || $class; my $self = $class->SUPER::new($mailsaobject); bless ($self, $class); $self->register_eval_rule("check_msg"); $self->read_conf($CONFIG); dbg("CMAE SpamAssassin $VERSION started up."); return $self; } sub check_msg() { my ($self, $permsgstatus, $full) = @_; ################## # Config Options # ################## my $HOSTNAME = $$self{conf}{'cmae-server hostname'} || 'localhost'; my $PORT = $$self{conf}{'cmae-server port'} || 2703; my $THRESHOLD = $$self{conf}{'spam score threshold'} || 0; my $SHOW_CATS = $$self{conf}{'show categories'} || 'no'; my ($client, $err) = Cloudmark::CMAE::Client->new ( host => $HOSTNAME, timeout => 60, port => $PORT, ); if ($err) { dbg("Can't connect to cmae-server on $HOSTNAME:$PORT.\n"); return 0; } my $score; my $category; my $sub_category; my $rescan; my $analysis; $err = $client->score(rfc822 => $$full, out_score => \$score, out_category => \$category, out_sub_category => \$sub_category, out_rescan => \$rescan, out_analysis => \$analysis); if ($err) { dbg("Scoring on $HOSTNAME:$PORT failed.\n"); return 0; } my $header = "$analysis"; if ($SHOW_CATS eq 'yes') { my $out_cat; my $out_subcat; $err = $client->describe_category(category => $category, sub_category => $sub_category, out_category_desc => \$out_cat, out_sub_category_desc => \$out_subcat); if ($err) { dbg("Can't extract category/subcat names. They will not be included in the CMAE analysis header.\n"); } else { # replace all punctuation and whitespace with underscores $out_subcat =~ s/[[:punct:]\s]/_/g; $header .= " xcat=$out_cat/$out_subcat"; } } # Add a X header with analysis header. $permsgstatus->set_tag("CMAETAG", $header); if ($score >= $THRESHOLD) { return $score; } else { return 0; } } sub read_conf() { my ($self, $file) = @_; if (! open CFILE, "<$file") { dbg("Couldn't read config file: $file. Defaults will be used\n"); return 0; } for (<CFILE>) { next if /^\s*#/; # ignore comments next unless /=/; # ignore if not a config option chomp; # remove trailing [\r\n] s/#.*$//g; # remove trailing comments my ($option, $value) = split /\s*=\s*/, $_, 2; if ($option) { $option =~ s/\s*$//g; # remove trailing spaces $value =~ s/\s*$//g; # remove trailing spaces $$self{conf}{$option} = $value; } } } ########################################################################### sub dbg { Mail::SpamAssassin::dbg (@_); } 1; # Copyright (c) 2007, Cloudmark, Inc. # All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Cloudmark, Inc. nor the # names of its contributors may be used to endorse or promote products # derived from this software without specific prior written permission. # THIS SOFTWARE IS PROVIDED BY CLOUDMARK, INC. ``AS IS'' AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL CLOUDMARK, INC. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF YOUR JURISDICTION. It is licensee's responsibility to comply with any export regulations applicable in licensee's jurisdiction. Under CURRENT (May 2000) U.S. export regulations this software is eligible for export from the U.S. and can be downloaded by or otherwise exported or reexported worldwide EXCEPT to U.S. embargoed destinations which include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan, Afghanistan and any other country to which the U.S. has embargoed goods and services.
Save
cmd:
run