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::Plugin - SpamAssassin plugin base class |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 SpamAssassin configuration: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
loadplugin MyPlugin /path/to/myplugin.pm |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 Perl code: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package MyPlugin; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Mail::SpamAssassin::Plugin; |
33
|
|
|
|
|
|
|
our @ISA = qw(Mail::SpamAssassin::Plugin); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
|
|
|
|
|
|
my ($class, $mailsa) = @_; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# the usual perlobj boilerplate to create a subclass object |
39
|
|
|
|
|
|
|
$class = ref($class) || $class; |
40
|
|
|
|
|
|
|
my $self = $class->SUPER::new($mailsa); |
41
|
|
|
|
|
|
|
bless ($self, $class); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# then register an eval rule, if desired... |
44
|
|
|
|
|
|
|
$self->register_eval_rule ("check_for_foo"); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# and return the new plugin object |
47
|
|
|
|
|
|
|
return $self; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
...methods... |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This is the base class for SpamAssassin plugins; all plugins must be objects |
57
|
|
|
|
|
|
|
that implement this class. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This class provides no-op stub methods for all the callbacks that a plugin |
60
|
|
|
|
|
|
|
can receive. It is expected that your plugin will override one or more |
61
|
|
|
|
|
|
|
of these stubs to perform its actions. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
SpamAssassin implements a plugin chain; each callback event is passed to each |
64
|
|
|
|
|
|
|
of the registered plugin objects in turn. Any plugin can call |
65
|
|
|
|
|
|
|
C<$self-E<gt>inhibit_further_callbacks()> to block delivery of that event to |
66
|
|
|
|
|
|
|
later plugins in the chain. This is useful if the plugin has handled the |
67
|
|
|
|
|
|
|
event, and there will be no need for later plugins to handle it as well. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
If you're looking to write a simple eval rule, skip straight to |
70
|
|
|
|
|
|
|
C<register_eval_rule()>, below. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 INTERFACE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
In all the plugin APIs below, C<options> refers to a reference to a hash |
75
|
|
|
|
|
|
|
containing name-value pairs. This is used to ensure future-compatibility, in |
76
|
|
|
|
|
|
|
that we can add new options in future without affecting objects built to an |
77
|
|
|
|
|
|
|
earlier version of the API. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
For example, here would be how to print out the C<line> item in a |
80
|
|
|
|
|
|
|
C<parse_config()> method: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub parse_config { |
83
|
|
|
|
|
|
|
my ($self, $opts) = @_; |
84
|
|
|
|
|
|
|
print "MyPlugin: parse_config got ".$opts->{line}."\n"; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The following methods can be overridden by subclasses to handle events. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use Mail::SpamAssassin; |
97
|
41
|
|
|
41
|
|
331
|
use Mail::SpamAssassin::Logger; |
|
41
|
|
|
|
|
104
|
|
|
41
|
|
|
|
|
1266
|
|
98
|
41
|
|
|
41
|
|
272
|
|
|
41
|
|
|
|
|
109
|
|
|
41
|
|
|
|
|
2464
|
|
99
|
|
|
|
|
|
|
use strict; |
100
|
41
|
|
|
41
|
|
299
|
use warnings; |
|
41
|
|
|
|
|
120
|
|
|
41
|
|
|
|
|
1131
|
|
101
|
41
|
|
|
41
|
|
240
|
# use bytes; |
|
41
|
|
|
|
|
108
|
|
|
41
|
|
|
|
|
1715
|
|
102
|
|
|
|
|
|
|
use re 'taint'; |
103
|
41
|
|
|
41
|
|
283
|
|
|
41
|
|
|
|
|
93
|
|
|
41
|
|
|
|
|
17908
|
|
104
|
|
|
|
|
|
|
our @ISA = qw(); |
105
|
|
|
|
|
|
|
#Removed $VERSION per BUG 6422 |
106
|
|
|
|
|
|
|
#$VERSION = 'bogus'; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
########################################################################### |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item $plugin = MyPluginClass->new ($mailsaobject) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Constructor. Plugins that need to register themselves will need to |
113
|
|
|
|
|
|
|
define their own; the default super-class constructor will work fine |
114
|
|
|
|
|
|
|
for plugins that just override a method. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Note that subclasses must provide the C<$mailsaobject> to the |
117
|
|
|
|
|
|
|
superclass constructor, like so: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $self = $class->SUPER::new($mailsaobject); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Lifecycle note: plugins that will need to store per-scan state should not store |
122
|
|
|
|
|
|
|
that on the Plugin object; instead this should be stored on the PerMsgStatus |
123
|
|
|
|
|
|
|
object, see C<check_start()> below. It is also likewise recommended that |
124
|
|
|
|
|
|
|
configuration settings be stored on the Conf object; see C<parse_config()>. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $class = shift; |
129
|
|
|
|
|
|
|
my $mailsaobject = shift; |
130
|
2400
|
|
|
2400
|
1
|
4046
|
$class = ref($class) || $class; |
131
|
2400
|
|
|
|
|
2972
|
|
132
|
2400
|
|
33
|
|
|
7211
|
if (!defined $mailsaobject) { |
133
|
|
|
|
|
|
|
die "plugin: usage: Mail::SpamAssassin::Plugin::new(class,mailsaobject)"; |
134
|
2400
|
50
|
|
|
|
4595
|
} |
135
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
my $self = { |
137
|
|
|
|
|
|
|
main => $mailsaobject, |
138
|
2400
|
|
|
|
|
6717
|
_inhibit_further_callbacks => 0 |
139
|
|
|
|
|
|
|
}; |
140
|
|
|
|
|
|
|
bless ($self, $class); |
141
|
|
|
|
|
|
|
$self; |
142
|
2400
|
|
|
|
|
3962
|
} |
143
|
2400
|
|
|
|
|
5442
|
|
144
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
145
|
|
|
|
|
|
|
# now list the supported methods we will call into. NOTE: we don't have |
146
|
|
|
|
|
|
|
# to implement them here, since the plugin can use "can()" to introspect |
147
|
|
|
|
|
|
|
# the object and determine if it's capable of calling the method anyway. |
148
|
|
|
|
|
|
|
# Nifty! |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item $plugin->parse_config ( { options ... } ) |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Parse a configuration line that hasn't already been handled. C<options> |
153
|
|
|
|
|
|
|
is a reference to a hash containing these options: |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item line |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The line of configuration text to parse. This has leading and trailing |
160
|
|
|
|
|
|
|
whitespace, and comments, removed. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item key |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The configuration key; ie. the first "word" on the line. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item value |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The configuration value; everything after the first "word" and |
169
|
|
|
|
|
|
|
any whitespace after that. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item conf |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
174
|
|
|
|
|
|
|
data should be stored. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item user_config |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
A boolean: C<1> if reading a user's configuration, C<0> if reading the |
179
|
|
|
|
|
|
|
system-wide configuration files. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
If the configuration line was a setting that is handled by this plugin, the |
184
|
|
|
|
|
|
|
method implementation should call C<$self-E<gt>inhibit_further_callbacks()>. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
If the setting is not handled by this plugin, the method should return C<0> so |
187
|
|
|
|
|
|
|
that a later plugin may handle it, or so that SpamAssassin can output a warning |
188
|
|
|
|
|
|
|
message to the user if no plugin understands it. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Lifecycle note: it is suggested that configuration be stored on the |
191
|
|
|
|
|
|
|
C<Mail::SpamAssassin::Conf> object in use, instead of the plugin object itself. |
192
|
|
|
|
|
|
|
That can be found as C<$plugin-E<gt>{main}-E<gt>{conf}>, or as "conf" in the |
193
|
|
|
|
|
|
|
C<$options> hash reference above. By storing it on C<conf>, this allows |
194
|
|
|
|
|
|
|
per-user and system-wide configuration precedence to be dealt with correctly. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item $plugin->finish_parsing_start ( { options ... } ) |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Signals that the system-wide configuration has been completely read, |
199
|
|
|
|
|
|
|
but internal data structures are not yet created. It is possible to |
200
|
|
|
|
|
|
|
use this hook to dynamically change the configuration already read in |
201
|
|
|
|
|
|
|
or add new config options. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
C<options> is a reference to a hash containing these options: |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=over 4 |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item conf |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
210
|
|
|
|
|
|
|
data should be stored. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=back |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Note: there are no guarantees that the internal data structures of |
215
|
|
|
|
|
|
|
SpamAssassin will not change from release to release. In particular to |
216
|
|
|
|
|
|
|
this plugin hook, if you modify the rules data structures in a |
217
|
|
|
|
|
|
|
third-party plugin, all bets are off until such time that an API is |
218
|
|
|
|
|
|
|
present for modifying that configuration data. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item $plugin->finish_parsing_end ( { options ... } ) |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Signals that the system-wide configuration parsing has just finished, and |
223
|
|
|
|
|
|
|
SpamAssassin is nearly ready to check messages. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
C<options> is a reference to a hash containing these options: |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=over 4 |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item conf |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
232
|
|
|
|
|
|
|
data should be stored. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Note: there are no guarantees that the internal data structures of |
237
|
|
|
|
|
|
|
SpamAssassin will not change from release to release. In particular to |
238
|
|
|
|
|
|
|
this plugin hook, if you modify the rules data structures in a |
239
|
|
|
|
|
|
|
third-party plugin, all bets are off until such time that an API is |
240
|
|
|
|
|
|
|
present for modifying that configuration data. |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item $plugin->user_conf_parsing_start ( { options ... } ) |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Signals that the per-user configuration has been completely read, but |
245
|
|
|
|
|
|
|
not converted to internal data structures. It is possible to use this |
246
|
|
|
|
|
|
|
hook to dynamically change the configuration already read in or add |
247
|
|
|
|
|
|
|
new config options. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
If C<allow_user_rules> is enabled in the configuration, it is possible |
250
|
|
|
|
|
|
|
that additional rules have been added since the C<finish_parsing_start> |
251
|
|
|
|
|
|
|
plugin hook invocation was called. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=over 4 |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item conf |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
258
|
|
|
|
|
|
|
data should be stored. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=back |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
Note: there are no guarantees that the internal data structures of |
263
|
|
|
|
|
|
|
SpamAssassin will not change from release to release. In particular to |
264
|
|
|
|
|
|
|
this plugin hook, if you modify the rules data structures in a |
265
|
|
|
|
|
|
|
third-party plugin, all bets are off until such time that an API is |
266
|
|
|
|
|
|
|
present for modifying that configuration data. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=item $plugin->user_conf_parsing_end ( { options ... } ) |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Signals that the per-user configuration parsing has just finished, and |
271
|
|
|
|
|
|
|
SpamAssassin is nearly ready to check messages. If C<allow_user_rules> is |
272
|
|
|
|
|
|
|
enabled in the configuration, it is possible that additional rules have been |
273
|
|
|
|
|
|
|
added since the C<finish_parsing_end> plugin hook invocation was called. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
C<options> is a reference to a hash containing these options: |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=over 4 |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item conf |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
282
|
|
|
|
|
|
|
data should be stored. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=back |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Note: there are no guarantees that the internal data structures of |
287
|
|
|
|
|
|
|
SpamAssassin will not change from release to release. In particular to |
288
|
|
|
|
|
|
|
this plugin hook, if you modify the rules data structures in a |
289
|
|
|
|
|
|
|
third-party plugin, all bets are off until such time that an API is |
290
|
|
|
|
|
|
|
present for modifying that configuration data. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item $plugin->signal_user_changed ( { options ... } ) |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Signals that the current user has changed for a new one. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=over 4 |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=item username |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
The new user's username. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=item user_dir |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
The new user's home directory. (equivalent to C<~>.) |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=item userstate_dir |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
The new user's storage directory. (equivalent to C<~/.spamassassin>.) |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=back |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=item $plugin->services_authorized_for_username ( { options ... } ) |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Validates that a given username is authorized to use certain services. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
In order to authorize a user, the plugin should first check that it can |
317
|
|
|
|
|
|
|
handle any of the services passed into the method and then set the value |
318
|
|
|
|
|
|
|
for each allowed service to true (or any non-negative value). |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
The current supported services are: bayessql |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=over 4 |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=item username |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
A username |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=item services |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Reference to a hash containing the services you want to check. |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
{ |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
'bayessql' => 0 |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=item conf |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
341
|
|
|
|
|
|
|
data should be stored. |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
=back |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
=item $plugin->compile_now_start ( { options ... } ) |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
This is called at the beginning of Mail::SpamAssassin::compile_now() so |
348
|
|
|
|
|
|
|
plugins can do any necessary initialization for multi-process |
349
|
|
|
|
|
|
|
SpamAssassin (such as spamd or mass-check -j). |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
=over 4 |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=item use_user_prefs |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
The value of $use_user_prefs option in compile_now(). |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
=item keep_userstate |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
The value of $keep_userstate option in compile_now(). |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=back |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=item $plugin->compile_now_finish ( { options ... } ) |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
This is called at the end of Mail::SpamAssassin::compile_now() so |
366
|
|
|
|
|
|
|
plugins can do any necessary initialization for multi-process |
367
|
|
|
|
|
|
|
SpamAssassin (such as spamd or mass-check -j). |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
=over 4 |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
=item use_user_prefs |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
The value of $use_user_prefs option in compile_now(). |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=item keep_userstate |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
The value of $keep_userstate option in compile_now(). |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
=back |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=item $plugin->check_start ( { options ... } ) |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
Signals that a message check operation is starting. |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=over 4 |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=item permsgstatus |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
Lifecycle note: it is recommended that rules that need to track test state on a |
392
|
|
|
|
|
|
|
per-scan basis should store that state on this object, not on the plugin object |
393
|
|
|
|
|
|
|
itself, since the plugin object will be shared between all active scanners. |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
The message being scanned is accessible through the |
396
|
|
|
|
|
|
|
C<$permsgstatus-E<gt>get_message()> API; there are a number of other public |
397
|
|
|
|
|
|
|
APIs on that object, too. See C<Mail::SpamAssassin::PerMsgStatus> perldoc. |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
=back |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=item $plugin->check_main ( { options ... } ) |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
Signals that a message should be checked. Note that implementations of |
404
|
|
|
|
|
|
|
this hook should return C<1>. |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=over 4 |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
=item permsgstatus |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=back |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
=item $plugin->check_tick ( { options ... } ) |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
Called periodically during a message check operation. A callback set for |
417
|
|
|
|
|
|
|
this method is a good place to run through an event loop dealing with |
418
|
|
|
|
|
|
|
network events triggered in a C<parse_metadata> method, for example. |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=over 4 |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=item permsgstatus |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=back |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=item $plugin->check_post_dnsbl ( { options ... } ) |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
Called after the DNSBL results have been harvested. This is a good |
431
|
|
|
|
|
|
|
place to harvest your own asynchronously-started network lookups. |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=over 4 |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=item permsgstatus |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=back |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=item $plugin->check_post_learn ( { options ... } ) |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
Called after auto-learning may (or may not) have taken place. If you |
444
|
|
|
|
|
|
|
wish to perform additional learning, whether or not auto-learning |
445
|
|
|
|
|
|
|
happens, this is the place to do it. |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=over 4 |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=item permsgstatus |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=back |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=item $plugin->check_end ( { options ... } ) |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
Signals that a message check operation has just finished, and the |
458
|
|
|
|
|
|
|
results are about to be returned to the caller. |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=over 4 |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=item permsgstatus |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
465
|
|
|
|
|
|
|
The current score, names of rules that hit, etc. can be retrieved |
466
|
|
|
|
|
|
|
using the public APIs on this object. |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=back |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
=item $plugin->finish_tests ( { options ... } ) |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
Called via C<Mail::SpamAssassin::finish>. This should clear up any tests that |
473
|
|
|
|
|
|
|
a plugin has added to the namespace. |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
In certain circumstances, plugins may find it useful to compile |
476
|
|
|
|
|
|
|
perl functions from the ruleset, on the fly. It is important to |
477
|
|
|
|
|
|
|
remove these once the C<Mail::SpamAssassin> object is deleted, |
478
|
|
|
|
|
|
|
however, and this API allows this. |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
Each plugin is responsible for its own generated perl functions. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=over 4 |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=item conf |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Conf> object on which the configuration |
487
|
|
|
|
|
|
|
data should be stored. |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
=back |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
See also the C<register_generated_rule_method> helper API, below. |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=item $plugin->extract_metadata ( { options ... } ) |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
Signals that a message is being mined for metadata. Some plugins may wish |
496
|
|
|
|
|
|
|
to add their own metadata as well. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=over 4 |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=item msg |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::Message> object for this message. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=item permsgstatus |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=back |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=item $plugin->parsed_metadata ( { options ... } ) |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
Signals that a message's metadata has been parsed, and can now be |
513
|
|
|
|
|
|
|
accessed by the plugin. |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=over 4 |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=item permsgstatus |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
=back |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
=item $plugin->start_rules ( { options ... } ) |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
Called before testing a set of rules of a given type and priority. |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=over 4 |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=item permsgstatus |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=item ruletype |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
The type of the rules about to be performed. |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=item priority |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
The priority level of the rules about to be performed. |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=back |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=item $plugin->hit_rule ( { options ... } ) |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
Called when a rule fires. |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=over 4 |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=item permsgstatus |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=item ruletype |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
The type of the rule that fired. |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=item rulename |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
The name of the rule that fired. |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=item score |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
The rule's score in the active scoreset. |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=back |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=item $plugin->ran_rule ( { options ... } ) |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
Called after a rule has been tested, whether or not it fired. When the |
570
|
|
|
|
|
|
|
rule fires, the hit_rule callback is always called before this. |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
=over 4 |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
=item permsgstatus |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=item ruletype |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
The type of the rule that was tested. |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=item rulename |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
The name of the rule that was tested. |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
=back |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
=item $plugin->autolearn_discriminator ( { options ... } ) |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
Control whether a just-scanned message should be learned as either |
591
|
|
|
|
|
|
|
spam or ham. This method should return one of C<1> to learn |
592
|
|
|
|
|
|
|
the message as spam, C<0> to learn as ham, or C<undef> to not |
593
|
|
|
|
|
|
|
learn from the message at all. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=over 4 |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
=item permsgstatus |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
=back |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=item $plugin->autolearn ( { options ... } ) |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
Signals that a message is about to be auto-learned as either ham or spam. |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=over 4 |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item permsgstatus |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=item isspam |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
C<1> if the message is spam, C<0> if ham. |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
=back |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=item $plugin->per_msg_finish ( { options ... } ) |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Signals that a C<Mail::SpamAssassin::PerMsgStatus> object is being |
622
|
|
|
|
|
|
|
destroyed, and any per-scan context held on that object by this |
623
|
|
|
|
|
|
|
plugin should be destroyed as well. |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
Normally, any member variables on the C<PerMsgStatus> object will be cleaned up |
626
|
|
|
|
|
|
|
automatically -- but if your plugin has made a circular reference on that |
627
|
|
|
|
|
|
|
object, this is the place to break them so that garbage collection can operate |
628
|
|
|
|
|
|
|
correctly. |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
=over 4 |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=item permsgstatus |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
=back |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=item $plugin->have_shortcircuited ( { options ... } ) |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
Has the current scan operation 'short-circuited'? In other words, can |
642
|
|
|
|
|
|
|
further scanning be skipped, since the message is already definitively |
643
|
|
|
|
|
|
|
classified as either spam or ham? |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
Plugins should return C<0> to indicate that scanning should continue, |
646
|
|
|
|
|
|
|
or C<1> to indicate that short-circuiting has taken effect. |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
=over 4 |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=item permsgstatus |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
The C<Mail::SpamAssassin::PerMsgStatus> context object for this scan. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=back |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=item $plugin->bayes_learn ( { options ... } ) |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
Called at the end of a bayes learn operation. |
659
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
This phase is the best place to map the raw (original) token value |
661
|
|
|
|
|
|
|
to the SHA1 hashed value. |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=over 4 |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
=item toksref |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
Reference to hash returned by call to tokenize. The hash takes the |
668
|
|
|
|
|
|
|
format of: |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
{ |
671
|
|
|
|
|
|
|
'SHA1 Hash Value' => 'raw (original) value', |
672
|
|
|
|
|
|
|
... |
673
|
|
|
|
|
|
|
} |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
NOTE: This data structure has changed since it was originally introduced |
676
|
|
|
|
|
|
|
in version 3.0.0. The values are no longer perl anonymous hashes, they |
677
|
|
|
|
|
|
|
are a single string containing the raw token value. You can test for |
678
|
|
|
|
|
|
|
backward compatibility by checking to see if the value for a key is a |
679
|
|
|
|
|
|
|
reference to a perl HASH, for instance: |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
if (ref($toksref->{$sometokenkey}) eq 'HASH') {... |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
If it is, then you are using the old interface, otherwise you are using |
684
|
|
|
|
|
|
|
the current interface. |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=item isspam |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
Boolean value stating what flavor of message the tokens represent, if |
689
|
|
|
|
|
|
|
true then message was specified as spam, false is nonspam. Note, when |
690
|
|
|
|
|
|
|
function is scan then isspam value is not valid. |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=item msgid |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Generated message id of the message just learned. |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
=item msgatime |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
Received date of the current message or current time if received date |
699
|
|
|
|
|
|
|
could not be determined. In addition, if the receive date is more than |
700
|
|
|
|
|
|
|
24 hrs into the future it will be reset to current datetime. |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=back |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=item $plugin->bayes_forget ( { options ... } ) |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
Called at the end of a bayes forget operation. |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=over 4 |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=item toksref |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
Reference to hash returned by call to tokenize. See bayes_learn |
713
|
|
|
|
|
|
|
documentation for additional information on the format. |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=item isspam |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
Boolean value stating what flavor of message the tokens represent, if |
718
|
|
|
|
|
|
|
true then message was specified as spam, false is nonspam. Note, when |
719
|
|
|
|
|
|
|
function is scan then isspam value is not valid. |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
=item msgid |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
Generated message id of the message just forgotten. |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
=back |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
=item $plugin->bayes_scan ( { options ... } ) |
728
|
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
Called at the end of a bayes scan operation. NOTE: Will not be |
730
|
|
|
|
|
|
|
called in case of error or if the message is otherwise skipped. |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=over 4 |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=item toksref |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
Reference to hash returned by call to tokenize. See bayes_learn |
737
|
|
|
|
|
|
|
documentation for additional information on the format. |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=item probsref |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
Reference to hash of calculated probabilities for tokens found in |
742
|
|
|
|
|
|
|
the database. |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
{ |
745
|
|
|
|
|
|
|
'SHA1 Hash Value' => { |
746
|
|
|
|
|
|
|
'prob' => 'calculated probability', |
747
|
|
|
|
|
|
|
'spam_count' => 'Total number of spam msgs w/ token', |
748
|
|
|
|
|
|
|
'ham_count' => 'Total number of ham msgs w/ token', |
749
|
|
|
|
|
|
|
'atime' => 'Atime value for token in database' |
750
|
|
|
|
|
|
|
} |
751
|
|
|
|
|
|
|
} |
752
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
=item score |
754
|
|
|
|
|
|
|
|
755
|
|
|
|
|
|
|
Score calculated for this particular message. |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=item msgatime |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
Calculated atime of the message just learned, note it may have been adjusted |
760
|
|
|
|
|
|
|
if it was determined to be too far into the future. |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=item significant_tokens |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
Array ref of the tokens found to be significant in determining the score for |
765
|
|
|
|
|
|
|
this message. |
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
=back |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=item $plugin->plugin_report ( { options ... } ) |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
Called if the message is to be reported as spam. If the reporting system is |
772
|
|
|
|
|
|
|
available, the variable C<$options-E<gt>{report}-E<gt>report_available}> should |
773
|
|
|
|
|
|
|
be set to C<1>; if the reporting system successfully reported the message, the |
774
|
|
|
|
|
|
|
variable C<$options-E<gt>{report}-E<gt>report_return}> should be set to C<1>. |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=over 4 |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
=item report |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
Reference to the Reporter object (C<$options-E<gt>{report}> in the |
781
|
|
|
|
|
|
|
paragraph above.) |
782
|
|
|
|
|
|
|
|
783
|
|
|
|
|
|
|
=item text |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
Reference to a markup removed copy of the message in scalar string format. |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
=item msg |
788
|
|
|
|
|
|
|
|
789
|
|
|
|
|
|
|
Reference to the original message object. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=back |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
=item $plugin->plugin_revoke ( { options ... } ) |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
Called if the message is to be reported as ham (revokes a spam report). If the |
796
|
|
|
|
|
|
|
reporting system is available, the variable |
797
|
|
|
|
|
|
|
C<$options-E<gt>{revoke}-E<gt>revoke_available}> should be set to C<1>; if the |
798
|
|
|
|
|
|
|
reporting system successfully revoked the message, the variable |
799
|
|
|
|
|
|
|
C<$options-E<gt>{revoke}-E<gt>revoke_return}> should be set to C<1>. |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=over 4 |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
=item revoke |
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
Reference to the Reporter object (C<$options-E<gt>{revoke}> in the |
806
|
|
|
|
|
|
|
paragraph above.) |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
=item text |
809
|
|
|
|
|
|
|
|
810
|
|
|
|
|
|
|
Reference to a markup removed copy of the message in scalar string format. |
811
|
|
|
|
|
|
|
|
812
|
|
|
|
|
|
|
=item msg |
813
|
|
|
|
|
|
|
|
814
|
|
|
|
|
|
|
Reference to the original message object. |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
=back |
817
|
|
|
|
|
|
|
|
818
|
|
|
|
|
|
|
=item $plugin->whitelist_address( { options ... } ) |
819
|
|
|
|
|
|
|
|
820
|
|
|
|
|
|
|
Called when a request is made to add an address to a |
821
|
|
|
|
|
|
|
persistent address list. |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
=over 4 |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=item address |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
Address you wish to add. |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=item cli_p |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
Indicate if the call is being made from a command line interface. |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=back |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
=item $plugin->blacklist_address( { options ... } ) |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
Called when a request is made to add an address to a |
838
|
|
|
|
|
|
|
persistent address list. |
839
|
|
|
|
|
|
|
|
840
|
|
|
|
|
|
|
=over 4 |
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
=item address |
843
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
Address you wish to add. |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
=item cli_p |
847
|
|
|
|
|
|
|
|
848
|
|
|
|
|
|
|
Indicate if the call is being made from a command line interface. |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
=back |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
=item $plugin->remove_address( { options ... } ) |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
Called when a request is made to remove an address to a |
855
|
|
|
|
|
|
|
persistent address list. |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=over 4 |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
=item address |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
Address you wish to remove. |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
=item cli_p |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
Indicate if the call is being made from a command line interface. |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
=back |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=item $plugin->spamd_child_init () |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
Called in each new child process when it starts up under spamd. |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
=item $plugin->log_scan_result ( { options ... } ) |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
Called when spamd has completed scanning a message. Currently, |
876
|
|
|
|
|
|
|
only spamd calls this API. |
877
|
|
|
|
|
|
|
|
878
|
|
|
|
|
|
|
=over 4 |
879
|
|
|
|
|
|
|
|
880
|
|
|
|
|
|
|
=item result |
881
|
|
|
|
|
|
|
|
882
|
|
|
|
|
|
|
The C<'result: ...'> line for this scan. Format is as described |
883
|
|
|
|
|
|
|
at B<http://wiki.apache.org/spamassassin/SpamdSyslogFormat>. |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
=back |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
=item $plugin->spamd_child_post_connection_close () |
888
|
|
|
|
|
|
|
|
889
|
|
|
|
|
|
|
Called when child returns from handling a connection. |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
If there was an accept failure, the child will die and this code will |
892
|
|
|
|
|
|
|
not be called. |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
=item $plugin->finish () |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
Called when the C<Mail::SpamAssassin> object is destroyed. |
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
=cut |
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
my ($self) = @_; |
901
|
|
|
|
|
|
|
%{$self} = (); |
902
|
|
|
|
|
|
|
} |
903
|
1480
|
|
|
1480
|
1
|
1729
|
|
904
|
1480
|
|
|
|
|
1354
|
=item $plugin->learner_new () |
|
1480
|
|
|
|
|
3079
|
|
905
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
Used to support human-trained probabilistic classifiers like the BAYES_* ruleset. |
907
|
|
|
|
|
|
|
Called when a new C<Mail::SpamAssassin::Bayes> object has been created; typically |
908
|
|
|
|
|
|
|
when a new user's scan is about to start. |
909
|
|
|
|
|
|
|
|
910
|
|
|
|
|
|
|
=item $plugin->learn_message () |
911
|
|
|
|
|
|
|
|
912
|
|
|
|
|
|
|
Train the classifier with a training message. |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
=over 4 |
915
|
|
|
|
|
|
|
|
916
|
|
|
|
|
|
|
=item isspam |
917
|
|
|
|
|
|
|
|
918
|
|
|
|
|
|
|
1 if the message is spam, 0 if it's non-spam. |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
=item msg |
921
|
|
|
|
|
|
|
|
922
|
|
|
|
|
|
|
The message's C<Mail::SpamAssassin::Message> object. |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
=item id |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
An optional message-identification string, used internally to tag the message. |
927
|
|
|
|
|
|
|
If it is C<undef>, one will be generated. It should be unique to that message. |
928
|
|
|
|
|
|
|
|
929
|
|
|
|
|
|
|
=back |
930
|
|
|
|
|
|
|
|
931
|
|
|
|
|
|
|
=item $plugin->forget_message () |
932
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
Tell the classifier to 'forget' its training about a specific message. |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
=over 4 |
936
|
|
|
|
|
|
|
|
937
|
|
|
|
|
|
|
=item msg |
938
|
|
|
|
|
|
|
|
939
|
|
|
|
|
|
|
The message's C<Mail::SpamAssassin::Message> object. |
940
|
|
|
|
|
|
|
|
941
|
|
|
|
|
|
|
=item id |
942
|
|
|
|
|
|
|
|
943
|
|
|
|
|
|
|
An optional message-identification string, used internally to tag the message. |
944
|
|
|
|
|
|
|
If it is C<undef>, one will be generated. It should be unique to that message. |
945
|
|
|
|
|
|
|
|
946
|
|
|
|
|
|
|
=back |
947
|
|
|
|
|
|
|
|
948
|
|
|
|
|
|
|
=item $plugin->learner_sync () |
949
|
|
|
|
|
|
|
|
950
|
|
|
|
|
|
|
Tell the classifier to 'sync' any pending changes against the current |
951
|
|
|
|
|
|
|
user's training database. This is called by C<sa-learn --sync>. |
952
|
|
|
|
|
|
|
|
953
|
|
|
|
|
|
|
If you do not need to implement these for your classifier, create an |
954
|
|
|
|
|
|
|
implementation that just contains C<return 1>. |
955
|
|
|
|
|
|
|
|
956
|
|
|
|
|
|
|
=item $plugin->learner_expire_old_training () |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
Tell the classifier to perform infrequent, time-consuming cleanup of |
959
|
|
|
|
|
|
|
the current user's training database. This is called by C<sa-learn |
960
|
|
|
|
|
|
|
--force-expire>. |
961
|
|
|
|
|
|
|
|
962
|
|
|
|
|
|
|
If you do not need to implement these for your classifier, create an |
963
|
|
|
|
|
|
|
implementation that just contains C<return 1>. |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
=item $plugin->learner_is_scan_available () |
966
|
|
|
|
|
|
|
|
967
|
|
|
|
|
|
|
Should return 1 if it is possible to use the current user's training data for |
968
|
|
|
|
|
|
|
a message-scan operation, or 0 otherwise. |
969
|
|
|
|
|
|
|
|
970
|
|
|
|
|
|
|
=item $plugin->learner_dump_database () |
971
|
|
|
|
|
|
|
|
972
|
|
|
|
|
|
|
Dump information about the current user's training data to C<stdout>. |
973
|
|
|
|
|
|
|
This is called by C<sa-learn --dump>. |
974
|
|
|
|
|
|
|
|
975
|
|
|
|
|
|
|
=over 4 |
976
|
|
|
|
|
|
|
|
977
|
|
|
|
|
|
|
=item magic |
978
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
Set to 1 if "magic" name-value metadata should be dumped. |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
=item toks |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
Set to 1 if the database of tokens should be dumped. |
984
|
|
|
|
|
|
|
|
985
|
|
|
|
|
|
|
=item regex |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
Either C<undef> to dump all tokens, or a value which specifies a regular expression |
988
|
|
|
|
|
|
|
subset of the tokens to dump. |
989
|
|
|
|
|
|
|
|
990
|
|
|
|
|
|
|
=back |
991
|
|
|
|
|
|
|
|
992
|
|
|
|
|
|
|
=item $plugin->learner_close () |
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
Close any open databases. |
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
=over 4 |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
=item quiet |
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
Set to 1 if warning messages should be suppressed. |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
=back |
1003
|
|
|
|
|
|
|
|
1004
|
|
|
|
|
|
|
=back |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
=head1 HELPER APIS |
1007
|
|
|
|
|
|
|
|
1008
|
|
|
|
|
|
|
These methods provide an API for plugins to register themselves |
1009
|
|
|
|
|
|
|
to receive specific events, or control the callback chain behaviour. |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
=over 4 |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
=item $plugin->register_eval_rule ($nameofevalsub) |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
Plugins that implement an eval test will need to call this, so that |
1016
|
|
|
|
|
|
|
SpamAssassin calls into the object when that eval test is encountered. |
1017
|
|
|
|
|
|
|
See the B<REGISTERING EVAL RULES> section for full details. |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
=cut |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
my ($self, $nameofsub) = @_; |
1022
|
|
|
|
|
|
|
$self->{main}->{conf}->register_eval_rule ($self, $nameofsub); |
1023
|
|
|
|
|
|
|
} |
1024
|
|
|
|
|
|
|
|
1025
|
11652
|
|
|
11652
|
1
|
18050
|
=item $plugin->register_generated_rule_method ($nameofsub) |
1026
|
11652
|
|
|
|
|
23278
|
|
1027
|
|
|
|
|
|
|
In certain circumstances, plugins may find it useful to compile |
1028
|
|
|
|
|
|
|
perl functions from the ruleset, on the fly. It is important to |
1029
|
|
|
|
|
|
|
remove these once the C<Mail::SpamAssassin> object is deleted, |
1030
|
|
|
|
|
|
|
however, and this API allows this. |
1031
|
|
|
|
|
|
|
|
1032
|
|
|
|
|
|
|
Once the method C<$nameofsub> has been generated, call this API |
1033
|
|
|
|
|
|
|
with the name of the method (including full package scope). |
1034
|
|
|
|
|
|
|
This indicates that it's a temporary piece of generated code, |
1035
|
|
|
|
|
|
|
built from the SpamAssassin ruleset, and when |
1036
|
|
|
|
|
|
|
C<Mail::SpamAssassin::finish()> is called, the method will |
1037
|
|
|
|
|
|
|
be destroyed. |
1038
|
|
|
|
|
|
|
|
1039
|
|
|
|
|
|
|
This API was added in SpamAssassin 3.2.0. |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
=cut |
1042
|
|
|
|
|
|
|
|
1043
|
|
|
|
|
|
|
my ($self, $nameofsub) = @_; |
1044
|
|
|
|
|
|
|
push @Mail::SpamAssassin::PerMsgStatus::TEMPORARY_METHODS, |
1045
|
|
|
|
|
|
|
$nameofsub; |
1046
|
|
|
|
|
|
|
} |
1047
|
|
|
|
|
|
|
|
1048
|
0
|
|
|
0
|
1
|
|
=item $plugin->register_method_priority($methodname, $priority) |
1049
|
0
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
Indicate that the method named C<$methodname> on the current object |
1051
|
|
|
|
|
|
|
has a callback priority of C<$priority>. |
1052
|
|
|
|
|
|
|
|
1053
|
|
|
|
|
|
|
This is used by the plugin handler to determine the relative order of |
1054
|
|
|
|
|
|
|
callbacks; plugins with lower-numbered priorities are called before plugins |
1055
|
|
|
|
|
|
|
with higher-numbered priorities. Each method can have a different priority |
1056
|
|
|
|
|
|
|
value. The default value is C<0>. The ordering of callbacks to methods with |
1057
|
|
|
|
|
|
|
equal priority is undefined. |
1058
|
|
|
|
|
|
|
|
1059
|
|
|
|
|
|
|
Typically, you only need to worry about this if you need to ensure your |
1060
|
|
|
|
|
|
|
plugin's method is called before another plugin's implementation of that |
1061
|
|
|
|
|
|
|
method. It should be called from your plugin's constructor. |
1062
|
|
|
|
|
|
|
|
1063
|
|
|
|
|
|
|
This API was added in SpamAssassin 3.2.0. |
1064
|
|
|
|
|
|
|
|
1065
|
|
|
|
|
|
|
=cut |
1066
|
|
|
|
|
|
|
|
1067
|
|
|
|
|
|
|
my ($self, $methname, $pri) = @_; |
1068
|
|
|
|
|
|
|
$self->{method_priority}->{$methname} = $pri; |
1069
|
|
|
|
|
|
|
} |
1070
|
|
|
|
|
|
|
|
1071
|
|
|
|
|
|
|
=item $plugin->inhibit_further_callbacks() |
1072
|
|
|
|
|
|
|
|
1073
|
0
|
|
|
0
|
1
|
|
Tells the plugin handler to inhibit calling into other plugins in the plugin |
1074
|
0
|
|
|
|
|
|
chain for the current callback. Frequently used when parsing configuration |
1075
|
|
|
|
|
|
|
settings using C<parse_config()>. |
1076
|
|
|
|
|
|
|
|
1077
|
|
|
|
|
|
|
=back |
1078
|
|
|
|
|
|
|
|
1079
|
|
|
|
|
|
|
=cut |
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
my ($self) = @_; |
1082
|
|
|
|
|
|
|
$self->{_inhibit_further_callbacks} = 1; |
1083
|
|
|
|
|
|
|
} |
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
1; |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
=head1 LOGGING |
1088
|
0
|
|
|
0
|
1
|
|
|
1089
|
0
|
|
|
|
|
|
=over 4 |
1090
|
|
|
|
|
|
|
|
1091
|
|
|
|
|
|
|
=item Mail::SpamAssassin::Plugin::dbg($message) |
1092
|
|
|
|
|
|
|
|
1093
|
|
|
|
|
|
|
Output a debugging message C<$message>, if the SpamAssassin object is running |
1094
|
|
|
|
|
|
|
with debugging turned on. |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
I<NOTE:> This function is not available in the package namespace |
1097
|
|
|
|
|
|
|
of general plugins and can't be called via $self->dbg(). If a |
1098
|
|
|
|
|
|
|
plugin wishes to output debug information, it should call |
1099
|
|
|
|
|
|
|
C<Mail::SpamAssassin::Plugin::dbg($msg)>. |
1100
|
|
|
|
|
|
|
|
1101
|
|
|
|
|
|
|
=item Mail::SpamAssassin::Plugin::info($message) |
1102
|
|
|
|
|
|
|
|
1103
|
|
|
|
|
|
|
Output an informational message C<$message>, if the SpamAssassin object |
1104
|
|
|
|
|
|
|
is running with informational messages turned on. |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
I<NOTE:> This function is not available in the package namespace |
1107
|
|
|
|
|
|
|
of general plugins and can't be called via $self->info(). If a |
1108
|
|
|
|
|
|
|
plugin wishes to output debug information, it should call |
1109
|
|
|
|
|
|
|
C<Mail::SpamAssassin::Plugin::info($msg)>. |
1110
|
|
|
|
|
|
|
|
1111
|
|
|
|
|
|
|
In general, it is better for plugins to use the C<Mail::SpamAssassin::Logger> |
1112
|
|
|
|
|
|
|
module to import C<dbg> and C<info> directly, like so: |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
use Mail::SpamAssassin::Logger; |
1115
|
|
|
|
|
|
|
dbg("some message"); |
1116
|
|
|
|
|
|
|
info("some other message"); |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
=back |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
=head1 REGISTERING EVAL RULES |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
Plugins that implement an eval test must register the methods that can be |
1123
|
|
|
|
|
|
|
called from rules in the configuration files, in the plugin class' constructor. |
1124
|
|
|
|
|
|
|
|
1125
|
|
|
|
|
|
|
For example, |
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
$plugin->register_eval_rule ('check_for_foo') |
1128
|
|
|
|
|
|
|
|
1129
|
|
|
|
|
|
|
will cause C<$plugin-E<gt>check_for_foo()> to be called for this |
1130
|
|
|
|
|
|
|
SpamAssassin rule: |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
header FOO_RULE eval:check_for_foo() |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
Note that eval rules are passed the following arguments: |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
=over 4 |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=item - The plugin object itself |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
=item - The C<Mail::SpamAssassin::PerMsgStatus> object calling the rule |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
=item - standard arguments for the rule type in use |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
=item - any and all arguments as specified in the configuration file |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
=back |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
In other words, the eval test method should look something like this: |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
sub check_for_foo { |
1151
|
|
|
|
|
|
|
my ($self, $permsgstatus, ...arguments...) = @_; |
1152
|
|
|
|
|
|
|
...code returning 0 or 1 |
1153
|
|
|
|
|
|
|
} |
1154
|
|
|
|
|
|
|
|
1155
|
|
|
|
|
|
|
Note that the headers can be accessed using the C<get()> method on the |
1156
|
|
|
|
|
|
|
C<Mail::SpamAssassin::PerMsgStatus> object, and the body by |
1157
|
|
|
|
|
|
|
C<get_decoded_stripped_body_text_array()> and other similar methods. |
1158
|
|
|
|
|
|
|
Similarly, the C<Mail::SpamAssassin::Conf> object holding the current |
1159
|
|
|
|
|
|
|
configuration may be accessed through C<$permsgstatus-E<gt>{main}-E<gt>{conf}>. |
1160
|
|
|
|
|
|
|
|
1161
|
|
|
|
|
|
|
The eval rule should return C<1> for a hit, or C<0> if the rule |
1162
|
|
|
|
|
|
|
is not hit. |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
State for a single message being scanned should be stored on the C<$permsgstatus> |
1165
|
|
|
|
|
|
|
object, not on the C<$self> object, since C<$self> persists between scan |
1166
|
|
|
|
|
|
|
operations. See the 'lifecycle note' on the C<check_start()> method above. |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
=head1 STANDARD ARGUMENTS FOR RULE TYPES |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
Plugins will be called with the same arguments as a standard EvalTest. |
1171
|
|
|
|
|
|
|
Different rule types receive different information by default: |
1172
|
|
|
|
|
|
|
|
1173
|
|
|
|
|
|
|
=over 4 |
1174
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
=item - header tests: no extra arguments |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
=item - body tests: fully rendered message as array reference |
1178
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
=item - rawbody tests: fully decoded message as array reference |
1180
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
=item - full tests: pristine message as scalar reference |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=back |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
The configuration file arguments will be passed in after the standard |
1186
|
|
|
|
|
|
|
arguments. |
1187
|
|
|
|
|
|
|
|
1188
|
|
|
|
|
|
|
=head1 BACKWARD COMPATIBILITY |
1189
|
|
|
|
|
|
|
|
1190
|
|
|
|
|
|
|
Note that if you write a plugin and need to determine if a particular |
1191
|
|
|
|
|
|
|
helper method is supported on C<Mail::SpamAssassin::Plugin>, you |
1192
|
|
|
|
|
|
|
can do this: |
1193
|
|
|
|
|
|
|
|
1194
|
|
|
|
|
|
|
if ($self->can("name_of_method")) { |
1195
|
|
|
|
|
|
|
eval { |
1196
|
|
|
|
|
|
|
$self->name_of_method(); # etc. |
1197
|
|
|
|
|
|
|
} |
1198
|
|
|
|
|
|
|
} else { |
1199
|
|
|
|
|
|
|
# take fallback action |
1200
|
|
|
|
|
|
|
} |
1201
|
|
|
|
|
|
|
|
1202
|
|
|
|
|
|
|
The same applies for the public APIs on objects of other types, such as |
1203
|
|
|
|
|
|
|
C<Mail::SpamAssassin::PerMsgStatus>. |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
=head1 SEE ALSO |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
Mail::SpamAssassin(3) |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
Mail::SpamAssassin::PerMsgStatus(3) |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
http://wiki.apache.org/spamassassin/PluginWritingTips |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
http://issues.apache.org/SpamAssassin/show_bug.cgi?id=2163 |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
=cut |