line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# <@LICENSE> |
2
|
|
|
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more |
3
|
|
|
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
4
|
|
|
|
|
|
|
# this work for additional information regarding copyright ownership. |
5
|
|
|
|
|
|
|
# The ASF licenses this file to you under the Apache License, Version 2.0 |
6
|
|
|
|
|
|
|
# (the "License"); you may not use this file except in compliance with |
7
|
|
|
|
|
|
|
# the License. You may obtain a copy of the License at: |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
12
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
15
|
|
|
|
|
|
|
# limitations under the License. |
16
|
|
|
|
|
|
|
# </@LICENSE> |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Mail::SpamAssassin::PersistentAddrList - persistent address list base class |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $factory = PersistentAddrListSubclass->new(); |
25
|
|
|
|
|
|
|
$spamtest->set_persistent_addr_list_factory ($factory); |
26
|
|
|
|
|
|
|
... call into SpamAssassin classes... |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
SpamAssassin will call: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $addrlist = $factory->new_checker($spamtest); |
31
|
|
|
|
|
|
|
$entry = $addrlist->get_addr_entry ($addr); |
32
|
|
|
|
|
|
|
... |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
All persistent address list implementations, used by the auto-whitelist |
37
|
|
|
|
|
|
|
code to track known-good email addresses, use this as a base class. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
See C<Mail::SpamAssassin::DBBasedAddrList> for an example. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over 4 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
use strict; |
49
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
143
|
|
50
|
6
|
|
|
6
|
|
26
|
# use bytes; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
220
|
|
51
|
|
|
|
|
|
|
use re 'taint'; |
52
|
6
|
|
|
6
|
|
34
|
|
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
1479
|
|
53
|
|
|
|
|
|
|
our @ISA = qw(); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
########################################################################### |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item $factory = PersistentAddrListSubclass->new(); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This creates a factory object, which SpamAssassin will call to create |
60
|
|
|
|
|
|
|
a new checker object for the persistent address list. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $class = shift; |
65
|
|
|
|
|
|
|
$class = ref($class) || $class; |
66
|
7
|
|
|
7
|
1
|
16
|
my $self = { }; |
67
|
7
|
|
33
|
|
|
25
|
bless ($self, $class); |
68
|
7
|
|
|
|
|
16
|
$self; |
69
|
7
|
|
|
|
|
13
|
} |
70
|
7
|
|
|
|
|
19
|
|
71
|
|
|
|
|
|
|
########################################################################### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item my $addrlist = $factory->new_checker(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Create a new address-list checker object from the factory. Called by the |
76
|
|
|
|
|
|
|
SpamAssassin classes. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my ($factory, $main) = @_; |
81
|
|
|
|
|
|
|
die "auto-whitelist: unimplemented base method"; # override this |
82
|
|
|
|
|
|
|
} |
83
|
0
|
|
|
0
|
1
|
|
|
84
|
0
|
|
|
|
|
|
########################################################################### |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item $entry = $addrlist->get_addr_entry ($addr); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Given an email address C<$addr>, return an entry object with the details of |
89
|
|
|
|
|
|
|
that address. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The entry object is a reference to a hash, which must contain at least |
92
|
|
|
|
|
|
|
two keys: C<count>, which is the count of times that address has been |
93
|
|
|
|
|
|
|
encountered before; and C<totscore>, which is the total of all scores for |
94
|
|
|
|
|
|
|
messages associated with that address. From these two fields, an average |
95
|
|
|
|
|
|
|
score will be calculated, and the score for the current message will be |
96
|
|
|
|
|
|
|
regressed towards that mean message score. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The hash can contain whatever other data your back-end needs to store, |
99
|
|
|
|
|
|
|
under other keys. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The method should never return C<undef>, or a hash that does not contain |
102
|
|
|
|
|
|
|
a C<count> key and a C<totscore> key. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my ($self, $addr, $signedby) = @_; |
107
|
|
|
|
|
|
|
my $entry = { }; |
108
|
|
|
|
|
|
|
die "auto-whitelist: unimplemented base method"; # override this |
109
|
|
|
|
|
|
|
return $entry; |
110
|
0
|
|
|
0
|
1
|
|
} |
111
|
0
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
########################################################################### |
113
|
0
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item $entry = $addrlist->add_score($entry, $score); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This method should add the given score to the whitelist database for the |
117
|
|
|
|
|
|
|
given entry, and then return the new entry. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my ($self, $entry, $score) = @_; |
122
|
|
|
|
|
|
|
die "auto-whitelist: unimplemented base method"; # override this |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
########################################################################### |
126
|
0
|
|
|
0
|
1
|
|
|
127
|
0
|
|
|
|
|
|
=item $entry = $addrlist->remove_entry ($entry); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This method should remove the given entry from the whitelist database. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my ($self, $entry) = @_; |
134
|
|
|
|
|
|
|
die "auto-whitelist: unimplemented base method"; # override this |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
########################################################################### |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
0
|
1
|
|
=item $entry = $addrlist->finish (); |
140
|
0
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Clean up, if necessary. Called by SpamAssassin when it has finished |
142
|
|
|
|
|
|
|
checking, or adding to, the auto-whitelist database. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my ($self) = @_; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
########################################################################### |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
0
|
1
|
|
=back |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |