]> git.donarmstrong.com Git - spamassassin_config.git/commitdiff
add a clamav scanner to the BTS SA configuration
authorDon Armstrong <don@donarmstrong.com>
Wed, 22 Mar 2017 22:47:40 +0000 (15:47 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 22 Mar 2017 22:47:40 +0000 (15:47 -0700)
bugs/clamav.pm [new file with mode: 0644]
bugs/user_prefs

diff --git a/bugs/clamav.pm b/bugs/clamav.pm
new file mode 100644 (file)
index 0000000..3451479
--- /dev/null
@@ -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 <don@donarmstrong.com>.
+
+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__
index 09167bab4e1e308da984a9e90cac2f1ec90c4dfc..f3920efeef498f83c574f957c5fec68fa24a140f 100644 (file)
@@ -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