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.003'; # 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_expire',
45 is_admin => 1,
46 type => $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC,
47 default => 0,
48 }, {
49 setting => 'auto_whitelist_redis_debug',
50 is_admin => 1,
51 type => $Mail::SpamAssassin::Conf::CONF_TYPE_BOOL,
52 default => 0,
53 },
54 ] );
55  
56 0 return( $self );
57 }
58  
59 1 1;
60  
61 __END__
62  
63 =pod
64  
65 =encoding UTF-8
66  
67 =head1 NAME
68  
69 Mail::SpamAssassin::Plugin::RedisAWL - redis support for spamassassin AWL/TxRep
70  
71 =head1 VERSION
72  
73 version 1.003
74  
75 =head1 DESCRIPTION
76  
77 RedisAWL implements a redis table for the spamassassin AWL/TxRep plugin.
78  
79 =head1 INSTALLATION
80  
81 To install the plugin from CPAN:
82  
83 $ cpanm Mail::SpamAssassin::Plugin::RedisAWL
84  
85 =head1 CONFIGURATION
86  
87 Load the plugin in init.pre:
88  
89 loadplugin Mail::SpamAssassin::Plugin::RedisAWL
90  
91 If you're using the AWL plugin change the AWL datebase type to redis in local.cf:
92  
93 auto_whitelist_factory Mail::SpamAssassin::RedisAddrList
94  
95 If you're using the TxRep plugin use:
96  
97 txrep_factory Mail::SpamAssassin::RedisAddrList
98  
99 And you may have to configure the redis server and prefix:
100  
101 auto_whitelist_redis_server 127.0.0.1:6379
102 auto_whitelist_redis_prefix awl_
103  
104 =head1 PARAMETERS
105  
106 =head2 auto_whitelist_redis_server
107  
108 The redis server to use.
109  
110 Default: 127.0.0.1:6379
111  
112 =head2 auto_whitelist_redis_password (default: no password)
113  
114 Set if you redis server requires a password.
115  
116 =head2 auto_whitelist_redis_prefix
117  
118 A prefix for AWL keys.
119  
120 Default: awl_
121  
122 =head2 auto_whitelist_redis_database (default: 0)
123  
124 Will call SELECT to switch database after connect if set to a non-zero value.
125  
126 Database 0 is the default in redis.
127  
128 =head2 auto_whitelist_redis_expire (default: 0)
129  
130 Add an expire timeout to entries in redis.
131  
132 The default 0 means that no expire timeout is set.
133  
134 Timeout must be set in seconds.
135  
136 An entries expiration timeout will be updated whenever a new score is applied to it.
137  
138 =head2 auto_whitelist_redis_debug (default: 0)
139  
140 Turn on/off debug on the Redis connection.
141  
142 =head1 CHECK YOUR CONFIGURATION
143  
144 Scan a mail an check debug output for redis/awl messages:
145  
146 $ spamassassin -D < /tmp/testmail 2>&1 | egrep -e 'auto-whitelist' -e 'redis'
147  
148 Query redis for awl data:
149  
150 $ redis-cli
151 redis 127.0.0.1:6379> keys awl_*
152 1)...
153 redis 127.0.0.1:6379> get awl_bla@blub.de|ip=1.2.3.4_score
154 "-5099"
155 redis 127.0.0.1:6379> get awl_bla@blub.de|ip=1.2.3.4_count
156 "1"
157  
158 =head1 AUTHOR
159  
160 Markus Benning <ich@markusbenning.de>
161  
162 =head1 COPYRIGHT AND LICENSE
163  
164 This software is Copyright (c) 2015 by Markus Benning.
165  
166 This is free software, licensed under:
167  
168 The Apache License, Version 2.0, January 2004
169  
170 =cut
« RedisAddrList.pm ↑ Summary