Plugin/RedisAWL.pm

filter: Statementstmt 72.0% 18 / 25 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 100% 1 / 1 totaltotal 64.8% 24 / 37 CC 2 SCAR 8.9
CC
2
Cov
64%
new
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« RedisAddrList.pm ↑ Summary
1 package Mail::SpamAssassin::Plugin::RedisAWL;
2  
3 1 ▶use Mail::SpamAssassin::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mail::SpamAssassin::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: redis support for spamassassin AWL/TxRep
9 1 our $VERSION = '1.001'; # VERSION
10  
11 1 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 @ISA = qw(Mail::SpamAssassin::Plugin);
13  
14  
15 sub new {
16 0 ▶ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
17 0 my $mailsaobject = shift;
18  
19 0 ▶ $class = ref($class) || $class;
Condition0%0/3
ref $class || $class
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table0%0/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
20 0 my $self = $class->SUPER::new($mailsaobject);
21 0 bless ($self, $class);
22  
23 $mailsaobject->{conf}->{parser}->register_commands( [
24 {
25 0 setting => 'auto_whitelist_redis_server',
26 type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
27 default => '127.0.0.1:6379',
28 is_admin => 1,
29 }, {
30 setting => 'auto_whitelist_redis_prefix',
31 type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
32 default => 'awl_',
33 is_admin => 1,
34 }, {
35 setting => 'auto_whitelist_redis_password',
36 is_admin => 1,
37 type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
38 }, {
39 setting => 'auto_whitelist_redis_database',
40 is_admin => 1,
41 type => $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC,
42 default => 0,
43 }, {
44 setting => 'auto_whitelist_redis_debug',
45 is_admin => 1,
46 type => $Mail::SpamAssassin::Conf::CONF_TYPE_BOOL,
47 default => 0,
48 },
49 ] );
50  
51 0 return( $self );
52 }
53  
54 1 1;
55  
56 __END__
57  
58 =pod
59  
60 =encoding UTF-8
61  
62 =head1 NAME
63  
64 Mail::SpamAssassin::Plugin::RedisAWL - redis support for spamassassin AWL/TxRep
65  
66 =head1 VERSION
67  
68 version 1.001
69  
70 =head1 DESCRIPTION
71  
72 RedisAWL implements a redis table for the spamassassin AWL/TxRep plugin.
73  
74 =head1 INSTALLATION
75  
76 To install the plugin from CPAN:
77  
78 $ cpanm Mail::SpamAssassin::Plugin::RedisAWL
79  
80 =head1 CONFIGURATION
81  
82 Load the plugin in init.pre:
83  
84 loadplugin Mail::SpamAssassin::Plugin::RedisAWL
85  
86 If you're using the AWL plugin change the AWL datebase type to redis in local.cf:
87  
88 auto_whitelist_factory Mail::SpamAssassin::RedisAddrList
89  
90 If you're using the TxRep plugin use:
91  
92 txrep_factory Mail::SpamAssassin::RedisAddrList
93  
94 And you may have to configure the redis server and prefix:
95  
96 auto_whitelist_redis_server 127.0.0.1:6379
97 auto_whitelist_redis_prefix awl_
98  
99 =head1 PARAMETERS
100  
101 =head2 auto_whitelist_redis_server
102  
103 The redis server to use.
104  
105 Default: 127.0.0.1:6379
106  
107 =head2 auto_whitelist_redis_password (default: no password)
108  
109 Set if you redis server requires a password.
110  
111 =head2 auto_whitelist_redis_prefix
112  
113 A prefix for AWL keys.
114  
115 Default: awl_
116  
117 =head2 auto_whitelist_redis_database (default: 0)
118  
119 Will call SELECT to switch database after connect if set to a non-zero value.
120  
121 Database 0 is the default in redis.
122  
123 =head2 timing_redis_debug (default: 0)
124  
125 Turn on/off debug on the Redis connection.
126  
127 =head1 CHECK YOUR CONFIGURATION
128  
129 Scan a mail an check debug output for redis/awl messages:
130  
131 $ spamassassin -D < /tmp/testmail 2>&1 | egrep -e 'auto-whitelist' -e 'redis'
132  
133 Query redis for awl data:
134  
135 $ redis-cli
136 redis 127.0.0.1:6379> keys awl_*
137 1)...
138 redis 127.0.0.1:6379> get awl_bla@blub.de|ip=1.2.3.4_score
139 "-5099"
140 redis 127.0.0.1:6379> get awl_bla@blub.de|ip=1.2.3.4_count
141 "1"
142  
143 =head1 AUTHOR
144  
145 Markus Benning <ich@markusbenning.de>
146  
147 =head1 COPYRIGHT AND LICENSE
148  
149 This software is Copyright (c) 2015 by Markus Benning.
150  
151 This is free software, licensed under:
152  
153 The Apache License, Version 2.0, January 2004
154  
155 =cut
« RedisAddrList.pm ↑ Summary