Box/Search/SpamAssassin.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 75 CC 7 SCAR 23.5
CC
7
Cov
0%
init
20.0
searchPart
20.0
assassinator
2.0
CRAP 10.5
1 # Copyrights 2001-2020 by [Mark Overmeer].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.02.
5 # This code is part of distribution Mail-Box. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Box::Search::SpamAssassin;
10 use vars '$VERSION';
11 $VERSION = '3.009';
12  
13 use base 'Mail::Box::Search';
14  
15 use strict;
16 use warnings;
17  
18 use Mail::SpamAssassin;
19 use Mail::Message::Wrapper::SpamAssassin;
20  
21 #-------------------------------------------
22  
23  
24 sub init($)
25 { my ($self, $args) = @_;
26  
27 $args->{in} ||= 'MESSAGE';
28 $args->{label} = 'spam' unless exists $args->{label};
29  
30 $self->SUPER::init($args);
31  
32 $self->{MBSS_rewrite_mail}
33 = defined $args->{rewrite_mail} ? $args->{rewrite_mail} : 1;
34  
35 $self->{MBSS_sa}
36 = defined $args->{spamassassin} ? $args->{spamassassin}
37 : Mail::SpamAssassin->new($args->{sa_options} || {});
38  
39 $self;
40 }
41  
42 #-------------------------------------------
43  
44  
45 sub assassinator() { shift->{MBSS_sa} }
46  
47 #-------------------------------------------
48  
49 sub searchPart($)
50 { my ($self, $message) = @_;
51  
52 my @details = (message => $message);
53
54 my $sa = Mail::Message::Wrapper::SpamAssassin->new($message)
55 or return;
56  
57 my $status = $self->assassinator->check($sa);
58  
59 my $is_spam = $status->is_spam;
60 $status->rewrite_mail if $self->{MBSS_rewrite_mail};
61  
62 if($is_spam)
63 { my $deliver = $self->{MBS_deliver};
64 $deliver->( {@details, status => $status} ) if defined $deliver;
65 }
66  
67 $is_spam;
68 }
69  
70 #-------------------------------------------
71  
72 sub inHead(@) {shift->notImplemented}
73  
74 #-------------------------------------------
75  
76 sub inBody(@) {shift->notImplemented}
77  
78 #-------------------------------------------
79  
80 1;