You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2011/05/12 17:58:28 UTC
svn commit: r1102360 - in /spamassassin/trunk/lib/Mail: SpamAssassin.pm
SpamAssassin/Conf.pm SpamAssassin/PerMsgStatus.pm
SpamAssassin/Plugin/Check.pm
Author: mmartinec
Date: Thu May 12 15:58:28 2011
New Revision: 1102360
URL: http://svn.apache.org/viewvc?rev=1102360&view=rev
Log:
Bug 6515: spamd timeout_child option overrides time_limit configuration option with nastier behaviour
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?rev=1102360&r1=1102359&r2=1102360&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Thu May 12 15:58:28 2011
@@ -491,10 +491,16 @@ sub parse {
my $timer = $self->time_method("parse");
my $master_deadline;
+ # passed in at a function call
if (ref $suppl_attrib && exists $suppl_attrib->{master_deadline}) {
$master_deadline = $suppl_attrib->{master_deadline}; # may be undef
- } elsif ($self->{conf}->{time_limit}) { # defined and nonzero
- $master_deadline = $start_time + $self->{conf}->{time_limit};
+ }
+ # found in a config file - overrides passed-in number if lower
+ if ($self->{conf}->{time_limit}) { # defined and nonzero
+ my $time_limit_deadline = $start_time + $self->{conf}->{time_limit};
+ if (!defined $master_deadline || $time_limit_deadline < $master_deadline) {
+ $master_deadline = $time_limit_deadline;
+ }
}
if (defined $master_deadline) {
dbg("config: time limit %.1f s", $master_deadline - $start_time);
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1102360&r1=1102359&r2=1102360&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Thu May 12 15:58:28 2011
@@ -2001,20 +2001,25 @@ compiled rules.
When a message is passed to Mail::SpamAssassin::parse, a deadline time
is established as a sum of current time and the C<time_limit> setting.
-This deadline may be overruled by a caller through option 'master_deadline'
-in $suppl_attrib on a call to parse(), possibly providing a more accurate
-deadline taking into account past and expected future processing of a
-message in a mail filtering setup. Note that spamd (and possibly some
-third-party callers of SpamAssassin) will overrule the C<time_limit> setting
-based on its --timeout-child option, unlike the command line C<spamassassin>,
-which has no such command line option.
+This deadline may also be specified by a caller through an option
+'master_deadline' in $suppl_attrib on a call to parse(), possibly providing
+a more accurate deadline taking into account past and expected future
+processing of a message in a mail filtering setup. If both the config
+option as well as a 'master_deadline' option in a call are provided,
+the shorter time limit of the two is used (since version 3.3.2).
+Note that spamd (and possibly third-party callers of SpamAssassin) will
+supply the 'master_deadline' option in a call based on its --timeout-child
+option (or equivalent), unlike the command line C<spamassassin>, which has
+no such command line option.
When a time limit is exceeded, most of the remaining tests will be skipped,
as well as auto-learning. Whatever tests fired so far will determine the
final score. The behaviour is similar to short-circuiting with attribute 'on',
as implemented by a Shortcircuit plugin. A synthetic hit on a rule named
-TIME_LIMIT_EXCEEDED with a near-zero score is generated, so that the report
-will reflect the event.
+TIME_LIMIT_EXCEEDED with a near-zero default score is generated, so that
+the report will reflect the event. A score for TIME_LIMIT_EXCEEDED may
+be provided explicitly in a configuration file, for example to achieve
+whitelisting or blacklisting effect for messages with long processing times.
The C<time_limit> option is a useful protection against excessive processing
time on certain degenerate or unusually long or complex mail messages, as well
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1102360&r1=1102359&r2=1102360&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Thu May 12 15:58:28 2011
@@ -2335,7 +2335,13 @@ data:
Optional: the score to use for the rule hit. If unspecified,
the value from the C<Mail::SpamAssassin::Conf> object's C<{scores}>
-hash will be used.
+hash will be used (a configured score), and in its absence the
+C<defscore> option value.
+
+=item defscore => $num
+
+Optional: the score to use for the rule hit if neither the
+option C<score> is provided, nor a configured score value is provided.
=item value => $num
@@ -2376,10 +2382,11 @@ sub got_hit {
my $dynamic_score_provided;
my $score = $params{score};
- if (defined $score) {
+ if (defined $score) { # overrides any configured scores
$dynamic_score_provided = 1;
} else {
$score = $conf_ref->{scores}->{$rule};
+ $score = $params{defscore} if !defined $score;
}
# adding a hit does nothing if we don't have a score -- we probably
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?rev=1102360&r1=1102359&r2=1102360&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Thu May 12 15:58:28 2011
@@ -57,10 +57,13 @@ sub check_main {
dbg("check: adding caller rule hits, %d rules", scalar(@caller_rule_hits));
for my $caller_rule_hit (@caller_rule_hits) {
next if ref $caller_rule_hit ne 'HASH';
- my($rulename, $area, $score, $value, $ruletype, $tflags, $description) =
- @$caller_rule_hit{qw(rule area score value ruletype tflags descr)};
+ my($rulename, $area, $score, $defscore, $value,
+ $ruletype, $tflags, $description) =
+ @$caller_rule_hit{qw(rule area score defscore value
+ ruletype tflags descr)};
$pms->got_hit($rulename, $area,
!defined $score ? () : (score => $score),
+ !defined $defscore ? () : (defscore => $defscore),
!defined $value ? () : (value => $value),
!defined $tflags ? () : (tflags => $tflags),
!defined $description ? () : (description => $description),