From: Don Armstrong Date: Wed, 22 Mar 2017 22:47:40 +0000 (-0700) Subject: add a clamav scanner to the BTS SA configuration X-Git-Url: https://git.donarmstrong.com/?p=spamassassin_config.git;a=commitdiff_plain;h=a1c14fd92323348960ec2af8173d886407ad6977 add a clamav scanner to the BTS SA configuration --- diff --git a/bugs/clamav.pm b/bugs/clamav.pm new file mode 100644 index 0000000..3451479 --- /dev/null +++ b/bugs/clamav.pm @@ -0,0 +1,70 @@ +# This provides a spamassassin clamav plugin and +# is released under the terms of the GPL version 3, or any later +# version (at your option). See the file README and COPYING for more +# information. +# Copyright 2017 by Don Armstrong . + +package clamav; + +=head1 NAME + +clamav -- Clamav scanner + +=head1 SYNOPSIS + +Plugin for spamssassin which checks mail using clamav + +=head1 DESCRIPTION + + +=head1 BUGS + +None known. + +=cut + + +use warnings; +use strict; + +use ClamAV::Client; + +use Mail::SpamAssassin; +use base qw(Mail::SpamAssassin::Plugin); + +sub new { + my ($class,@opts) = @_; + $class = ref($class) // $class; + my $self = $class->SUPER::new(@opts); + bless($self,$class); + $self->register_eval_rule("check_clamav"); + return $self; +} + +sub check_clamav { + my ($self,$pms,$fulltext) = @_; + + my $scanner = ClamAV::Client->new(); + if (not defined $scanner) { + dbg("ClamAv is not running or could not connect to it"); + return 0; + } + my $ret = 0; + my $infected = $scanner->scan_scalar(\$fulltext); + if (defined $infected) { + $ret = 1; + $pms->set_tag('CHECKCLAMAV','Yes '.$infected); + $pms->get_message->put_metadata('X-Spam-Virus','Yes '.$infected); + } else { + $pms->set_tag('CHECKCLAMAV','No'); + $pms->get_message->put_metadata('X-Spam-Virus','No'); + } + return $ret; +} + + + +1; + + +__END__ diff --git a/bugs/user_prefs b/bugs/user_prefs index 09167ba..f3920ef 100644 --- a/bugs/user_prefs +++ b/bugs/user_prefs @@ -115,6 +115,13 @@ loadplugin Mail::SpamAssassin::Plugin::Rule2XSBody loadplugin Mail::SpamAssassin::Plugin::ImageInfo +# add our local clamav plugin +loadplugin clamav clamav.pm +if plugin(clamav) + full CLAMAV eval:check_clamav() + describe CLAMAV contains a virus according to clamav + score CLAMAV 8 +endif # blarson 2004-03-20 # Disable most DNSBLs -- overhead to high