View | Details | Raw Unified | Return to bug 3109
Collapse All | Expand All

(-)Mail-SpamAssassin-3.1.1-vanilla/lib/Mail/SpamAssassin/Conf.pm (+61 lines)
Lines 2149-2154 Link Here
2149
2149
2150
=back
2150
=back
2151
2151
2152
=item shortcircuit SYMBOLIC_TEST_NAME [default|spam|ham]
2153
2154
Short Circuiting a test will force all other pending rules to be
2155
skipped.  Recomended usage would be in conjunction with priority to
2156
set rules with strong S/O values (ie 1.0) to be ran first and make
2157
instant spam or ham classification based on that.
2158
2159
=over 4
2160
2161
=item spam
2162
2163
override the default score of this rule with the score from C<shortcircuit_spam_score>.
2164
2165
=item ham
2166
2167
override the default score of this rule with the score from C<shortcircuit_ham_score>.
2168
2169
=item default
2170
2171
uses the default score for this rule.
2172
2173
=back
2174
2175
=cut
2176
2177
  push (@cmds, {
2178
    setting => 'shortcircuit',
2179
    is_priv => 1,
2180
    type => $CONF_TYPE_HASH_KEY_VALUE
2181
  });
2182
2183
=item shortcircuit_spam_score n.nn (default: 100)
2184
2185
when shortcircuit is used on a rule, and the shortcircuit type is
2186
set to C<spam>, this value should be applied in place of the default
2187
score for that rule.
2188
2189
=cut
2190
2191
  push (@cmds, {
2192
    setting => 'shortcircuit_spam_score',
2193
    default => 100,
2194
    type => $CONF_TYPE_NUMERIC
2195
  });
2196
2197
=item shortcircuit_ham_score n.nn (default: -100)
2198
2199
when shortcircuit is used on a rule, and the shortcircuit type is
2200
set to C<ham>, this value should be applied in place of the default
2201
score for that rule.
2202
2203
=cut
2204
2205
  push (@cmds, {
2206
    setting => 'shortcircuit_ham_score',
2207
    default => -100,
2208
    type => $CONF_TYPE_NUMERIC
2209
  });
2210
2211
=back
2212
2152
=head1 ADMINISTRATOR SETTINGS
2213
=head1 ADMINISTRATOR SETTINGS
2153
2214
2154
These settings differ from the ones above, in that they are considered 'more
2215
These settings differ from the ones above, in that they are considered 'more
(-)Mail-SpamAssassin-3.1.1-vanilla/lib/Mail/SpamAssassin/PerMsgStatus.pm (+35 lines)
Lines 170-175 Link Here
170
      # happen in Conf.pm when we switch a rules from one priority to another
170
      # happen in Conf.pm when we switch a rules from one priority to another
171
      next unless ($self->{conf}->{priorities}->{$priority} > 0);
171
      next unless ($self->{conf}->{priorities}->{$priority} > 0);
172
172
173
      # if shortcircuiting is it, we skip all other priorities...
174
      last if (exists $self->{shortcircuit});
175
173
      dbg("check: running tests for priority: $priority");
176
      dbg("check: running tests for priority: $priority");
174
177
175
      # only harvest the dnsbl queries once priority HARVEST_DNSBL_PRIORITY
178
      # only harvest the dnsbl queries once priority HARVEST_DNSBL_PRIORITY
Lines 1613-1618 Link Here
1613
  my ($self, $priority) = @_;
1616
  my ($self, $priority) = @_;
1614
  local ($_);
1617
  local ($_);
1615
1618
1619
  return if (exists $self->{shortcircuit});
1620
1616
  # note: we do this only once for all head pattern tests.  Only
1621
  # note: we do this only once for all head pattern tests.  Only
1617
  # eval tests need to use stuff in here.
1622
  # eval tests need to use stuff in here.
1618
  $self->{test_log_msgs} = ();        # clear test state
1623
  $self->{test_log_msgs} = ();        # clear test state
Lines 1639-1644 Link Here
1639
  my $evalstr2 = '';
1644
  my $evalstr2 = '';
1640
1645
1641
  while (my($rulename, $rule) = each %{$self->{conf}{head_tests}->{$priority}}) {
1646
  while (my($rulename, $rule) = each %{$self->{conf}{head_tests}->{$priority}}) {
1647
    last if (exists $self->{shortcircuit});
1642
    my $def = '';
1648
    my $def = '';
1643
    my ($hdrname, $testtype, $pat) =
1649
    my ($hdrname, $testtype, $pat) =
1644
        $rule =~ /^\s*(\S+)\s*(\=|\!)\~\s*(\S.*?\S)\s*$/;
1650
        $rule =~ /^\s*(\S+)\s*(\=|\!)\~\s*(\S.*?\S)\s*$/;
Lines 1717-1722 Link Here
1717
  my ($self, $priority, $textary) = @_;
1723
  my ($self, $priority, $textary) = @_;
1718
  local ($_);
1724
  local ($_);
1719
1725
1726
  return if (exists $self->{shortcircuit});
1727
1720
  dbg("rules: running body-text per-line regexp tests; score so far=".$self->{score});
1728
  dbg("rules: running body-text per-line regexp tests; score so far=".$self->{score});
1721
1729
1722
  my $doing_user_rules = 
1730
  my $doing_user_rules = 
Lines 1740-1745 Link Here
1740
  my $evalstr2 = '';
1748
  my $evalstr2 = '';
1741
1749
1742
  while (my($rulename, $pat) = each %{$self->{conf}{body_tests}->{$priority}}) {
1750
  while (my($rulename, $pat) = each %{$self->{conf}{body_tests}->{$priority}}) {
1751
    last if (exists $self->{shortcircuit});
1743
    $evalstr .= '
1752
    $evalstr .= '
1744
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
1753
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
1745
        # call procedurally as it is faster.
1754
        # call procedurally as it is faster.
Lines 2129-2134 Link Here
2129
  my ($self, $priority, @uris) = @_;
2138
  my ($self, $priority, @uris) = @_;
2130
  local ($_);
2139
  local ($_);
2131
2140
2141
  return if (exists $self->{shortcircuit});
2142
2132
  dbg("uri: running uri tests; score so far=".$self->{score});
2143
  dbg("uri: running uri tests; score so far=".$self->{score});
2133
2144
2134
  my $doing_user_rules = 
2145
  my $doing_user_rules = 
Lines 2152-2157 Link Here
2152
  my $evalstr2 = '';
2163
  my $evalstr2 = '';
2153
2164
2154
  while (my($rulename, $pat) = each %{$self->{conf}{uri_tests}->{$priority}}) {
2165
  while (my($rulename, $pat) = each %{$self->{conf}{uri_tests}->{$priority}}) {
2166
    last if (exists $self->{shortcircuit});
2167
2155
    $evalstr .= '
2168
    $evalstr .= '
2156
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
2169
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
2157
        '.$rulename.'_uri_test($self, @_); # call procedurally for speed
2170
        '.$rulename.'_uri_test($self, @_); # call procedurally for speed
Lines 2218-2223 Link Here
2218
  my ($self, $priority, $textary) = @_;
2231
  my ($self, $priority, $textary) = @_;
2219
  local ($_);
2232
  local ($_);
2220
2233
2234
  return if (exists $self->{shortcircuit});
2235
2221
  dbg("rules: running raw-body-text per-line regexp tests; score so far=".$self->{score});
2236
  dbg("rules: running raw-body-text per-line regexp tests; score so far=".$self->{score});
2222
2237
2223
  my $doing_user_rules = 
2238
  my $doing_user_rules = 
Lines 2241-2246 Link Here
2241
  my $evalstr2 = '';
2256
  my $evalstr2 = '';
2242
2257
2243
  while (my($rulename, $pat) = each %{$self->{conf}{rawbody_tests}->{$priority}}) {
2258
  while (my($rulename, $pat) = each %{$self->{conf}{rawbody_tests}->{$priority}}) {
2259
    last if (exists $self->{shortcircuit});
2244
    $evalstr .= '
2260
    $evalstr .= '
2245
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
2261
      if ($self->{conf}->{scores}->{q{'.$rulename.'}}) {
2246
         '.$rulename.'_rawbody_test($self, @_); # call procedurally for speed
2262
         '.$rulename.'_rawbody_test($self, @_); # call procedurally for speed
Lines 2405-2410 Link Here
2405
  my ($self, $priority) = @_;
2421
  my ($self, $priority) = @_;
2406
  local ($_);
2422
  local ($_);
2407
2423
2424
  return if (exists $self->{shortcircuit});
2425
2408
  dbg("rules: running meta tests; score so far=" . $self->{score} );
2426
  dbg("rules: running meta tests; score so far=" . $self->{score} );
2409
2427
2410
  my $doing_user_rules = 
2428
  my $doing_user_rules = 
Lines 2431-2436 Link Here
2431
2449
2432
  # Go through each rule and figure out what we need to do
2450
  # Go through each rule and figure out what we need to do
2433
  foreach $rulename (@metas) {
2451
  foreach $rulename (@metas) {
2452
    last if (exists $self->{shortcircuit});
2434
    my $rule   = $self->{conf}->{meta_tests}->{$priority}->{$rulename};
2453
    my $rule   = $self->{conf}->{meta_tests}->{$priority}->{$rulename};
2435
    my $token;
2454
    my $token;
2436
2455
Lines 2545-2556 Link Here
2545
sub run_eval_tests {
2564
sub run_eval_tests {
2546
  my ($self, $evalhash, $prepend2desc, @extraevalargs) = @_;
2565
  my ($self, $evalhash, $prepend2desc, @extraevalargs) = @_;
2547
  local ($_);
2566
  local ($_);
2567
2568
  return if (exists $self->{shortcircuit});
2548
  
2569
  
2549
  my $debugenabled = would_log('dbg');
2570
  my $debugenabled = would_log('dbg');
2550
2571
2551
  my $scoreset = $self->{conf}->get_score_set();
2572
  my $scoreset = $self->{conf}->get_score_set();
2552
  while (my ($rulename, $test) = each %{$evalhash}) {
2573
  while (my ($rulename, $test) = each %{$evalhash}) {
2553
2574
2575
    last if (exists $self->{shortcircuit});
2576
2554
    # Score of 0, skip it.
2577
    # Score of 0, skip it.
2555
    next unless ($self->{conf}->{scores}->{$rulename});
2578
    next unless ($self->{conf}->{scores}->{$rulename});
2556
2579
Lines 2753-2758 Link Here
2753
2776
2754
  my $score = $self->{conf}->{scores}->{$rule};
2777
  my $score = $self->{conf}->{scores}->{$rule};
2755
2778
2779
  my $sc = $self->{conf}->{shortcircuit};
2780
  if (defined $sc->{$rule}) {
2781
    $self->{shortcircuit} = $rule;
2782
    if ($sc->{$rule} =~ m/spam/) {
2783
         $score = $self->{conf}->{shortcircuit_spam_score};
2784
    }
2785
    elsif ($sc->{$rule} =~ m/ham/) {
2786
         $score = $self->{conf}->{shortcircuit_ham_score};
2787
    }
2788
    dbg("shortcircuit: hit on rule $rule, sc type is " . $sc->{$rule} . ", apply score of $score");
2789
  }
2790
2756
  $self->_handle_hit($rule, $score, $area, $desc);
2791
  $self->_handle_hit($rule, $score, $area, $desc);
2757
}
2792
}
2758
2793
(-)Mail-SpamAssassin-3.1.1-vanilla/MANIFEST (+1 lines)
Lines 197-202 Link Here
197
rules/30_text_pt_br.cf
197
rules/30_text_pt_br.cf
198
rules/50_scores.cf
198
rules/50_scores.cf
199
rules/60_awl.cf
199
rules/60_awl.cf
200
rules/60_shortcircuit.cf
200
rules/60_whitelist.cf
201
rules/60_whitelist.cf
201
rules/60_whitelist_spf.cf
202
rules/60_whitelist_spf.cf
202
rules/60_whitelist_subject.cf
203
rules/60_whitelist_subject.cf
(-)Mail-SpamAssassin-3.1.1-vanilla/rules/60_shortcircuit.cf (+57 lines)
Line 0 Link Here
1
# SpamAssassin rules file: spam and ham shortcircuiting using priorities
2
#
3
# Please don't modify this file as your changes will be overwritten with
4
# the next update. Use @@LOCAL_RULES_DIR@@/local.cf instead.
5
# See 'perldoc Mail::SpamAssassin::Conf' for details.
6
#
7
# <@LICENSE>
8
# Copyright 2004 Apache Software Foundation
9
#
10
# Licensed under the Apache License, Version 2.0 (the "License");
11
# you may not use this file except in compliance with the License.
12
# You may obtain a copy of the License at
13
#
14
#     http://www.apache.org/licenses/LICENSE-2.0
15
#
16
# Unless required by applicable law or agreed to in writing, software
17
# distributed under the License is distributed on an "AS IS" BASIS,
18
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
# See the License for the specific language governing permissions and
20
# limitations under the License.
21
# </@LICENSE>
22
23
###########################################################################
24
# HAM
25
26
priority USER_IN_WHITELIST -100
27
shortcircuit USER_IN_WHITELIST default
28
29
priority USER_IN_DEF_WHITELIST -100
30
shortcircuit USER_IN_DEF_WHITELIST default
31
32
priority USER_IN_ALL_SPAM_TO -100
33
shortcircuit USER_IN_ALL_SPAM_TO default
34
35
priority SUBJECT_IN_WHITELIST	-100
36
shortcircuit SUBJECT_IN_WHITELIST default
37
38
priority ALL_TRUSTED -95
39
shortcircuit ALL_TRUSTED default
40
41
42
###########################################################################
43
# SPAM
44
45
priority USER_IN_BLACKLIST -90
46
shortcircuit USER_IN_BLACKLIST default
47
48
priority USER_IN_BLACKLIST_TO -90
49
shortcircuit USER_IN_BLACKLIST_TO default
50
51
priority SUBJECT_IN_BLACKLIST	-90
52
shortcircuit SUBJECT_IN_BLACKLIST default
53
54
# some people may want this?
55
# priority BAYES_99	-90
56
# shortcircuit BAYES_99 spam
57

Return to bug 3109