You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2006/04/14 20:33:33 UTC

svn commit: r394166 - in /spamassassin/branches/bug-3109-shortcircuiting: lib/Mail/SpamAssassin/Conf.pm lib/Mail/SpamAssassin/PerMsgStatus.pm rules/60_shortcircuit.cf

Author: jm
Date: Fri Apr 14 11:33:27 2006
New Revision: 394166

URL: http://svn.apache.org/viewcvs?rev=394166&view=rev
Log:
simplify shortcircuit; 'ham' and 'spam' are now just shortcuts that evaluate as shortcircuit 'on' plus a few sane defaults for shortcircuit rules, as per comment 50 on bug 3109

Modified:
    spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/branches/bug-3109-shortcircuiting/rules/60_shortcircuit.cf

Modified: spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/Conf.pm?rev=394166&r1=394165&r2=394166&view=diff
==============================================================================
--- spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/Conf.pm Fri Apr 14 11:33:27 2006
@@ -2215,7 +2215,7 @@
     type => $CONF_TYPE_HASH_KEY_VALUE
   });
 
-=item shortcircuit SYMBOLIC_TEST_NAME {spam|ham|default|off}
+=item shortcircuit SYMBOLIC_TEST_NAME {ham|spam|on|off}
 
 Shortcircuiting a test will force all other pending rules to be skipped, if
 that test is hit.
@@ -2229,17 +2229,7 @@
 
 =over 4
 
-=item spam
-
-Override the default score of this rule with the score from
-C<shortcircuit_spam_score>.
-
-=item ham
-
-Override the default score of this rule with the score from
-C<shortcircuit_ham_score>.
-
-=item default
+=item on
 
 Shortcircuits the rest of the tests, but does not make a strict classification
 of spam or ham.  Rather, it uses the default score for the rule being
@@ -2250,8 +2240,8 @@
   body TEST /test/
   describe TEST test rule that scores barely over spam threshold
   score TEST 5.5
-  priority TEST -10
-  shortcircuit TEST default
+  priority TEST -100
+  shortcircuit TEST on
 
 =back
 
@@ -2262,6 +2252,38 @@
 
 Disables shortcircuiting on said rule.
 
+=item spam
+
+Shortcircuit the rule using a set of defaults; override the default score of
+this rule with the score from C<shortcircuit_spam_score>, set the
+C<noautolearn> tflag, and set priority to C<-100>.  In other words,
+equivalent to:
+
+=over 4
+
+  shortcircuit TEST on
+  priority TEST -100
+  score TEST 100
+  tflags TEST noautolearn
+
+=back
+
+=item ham
+
+Shortcircuit the rule using a set of defaults; override the default score of
+this rule with the score from C<shortcircuit_ham_score>, set the C<noautolearn>
+and C<nice> tflags, and set priority to C<-100>.   In other words, equivalent
+to:
+
+=over 4
+
+  shortcircuit TEST on
+  priority TEST -100
+  score TEST -100
+  tflags TEST noautolearn nice
+
+=back
+
 =back
 
 =cut
@@ -2280,12 +2302,26 @@
       } else {
         return $INVALID_VALUE;
       }
-      if ($type =~ m/^(?:spam|ham|default)$/) {
-        dbg("shortcircuit: adding $rule $type");
+
+      if ($type =~ m/^(?:spam|ham)$/) {
+        dbg("shortcircuit: adding $rule using abbreviation $type");
+
+        # set the defaults:
         $self->{shortcircuit}->{$rule} = $type;
-      } elsif ($type eq "off") {
+        $self->{priority}->{$rule} = -100;
+
+        my $tf = $self->{tflags}->{$rule};
+        $self->{tflags}->{$rule} = ($tf ? $tf." " : "") .
+                ($type eq 'ham' ? "nice " : "") .
+                "noautolearn";
+      }
+      elsif ($type eq "on") {
+        $self->{shortcircuit}->{$rule} = "on";
+      }
+      elsif ($type eq "off") {
         delete $self->{shortcircuit}->{$rule};
-      } else {
+      }
+      else {
         return $INVALID_VALUE;
       }
     }

Modified: spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=394166&r1=394165&r2=394166&view=diff
==============================================================================
--- spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/bug-3109-shortcircuiting/lib/Mail/SpamAssassin/PerMsgStatus.pm Fri Apr 14 11:33:27 2006
@@ -2944,22 +2944,21 @@
 
   my $score = $self->{conf}->{scores}->{$rule};
 
-  my $sc = $self->{conf}->{shortcircuit};
-
-  if (exists $sc->{$rule}) {
+  my $sctype = $self->{conf}->{shortcircuit}->{$rule};
+  if ($sctype) {
     $self->{shortcircuit_rule} = $rule;
-    $self->{shortcircuit_type} = $sc->{$rule};
-
-    if ($self->{shortcircuit_type} eq "spam") {
-      $score = $self->{conf}->{shortcircuit_spam_score};
-      dbg("shortcircuit: s/c as spam, score of $score");
-    }
-    elsif ($self->{shortcircuit_type} eq "ham") {
-      $score = $self->{conf}->{shortcircuit_ham_score};
-      dbg("shortcircuit: s/c as ham, score of $score");
+    if ($sctype eq 'on') {  # guess by rule score
+      $self->{shortcircuit_type} = ($score < 0 ? 'ham' : 'spam');
+      dbg("shortcircuit: s/c due to $rule, using score of $score");
     }
     else {
-      dbg("shortcircuit: s/c classification not specified, using default score of $score");
+      $self->{shortcircuit_type} = $sctype;
+      if ($sctype eq 'ham') {
+        $score = $self->{conf}->{shortcircuit_ham_score};
+      } else {
+        $score = $self->{conf}->{shortcircuit_spam_score};
+      }
+      dbg("shortcircuit: s/c $sctype due to $rule, using score of $score");
     }
   }
 

Modified: spamassassin/branches/bug-3109-shortcircuiting/rules/60_shortcircuit.cf
URL: http://svn.apache.org/viewcvs/spamassassin/branches/bug-3109-shortcircuiting/rules/60_shortcircuit.cf?rev=394166&r1=394165&r2=394166&view=diff
==============================================================================
--- spamassassin/branches/bug-3109-shortcircuiting/rules/60_shortcircuit.cf (original)
+++ spamassassin/branches/bug-3109-shortcircuiting/rules/60_shortcircuit.cf Fri Apr 14 11:33:27 2006
@@ -39,16 +39,16 @@
 ###########################################################################
 # SHORTCIRCUITS
 
-shortcircuit USER_IN_WHITELIST       default
-shortcircuit USER_IN_DEF_WHITELIST   default
-shortcircuit USER_IN_ALL_SPAM_TO     default
-shortcircuit SUBJECT_IN_WHITELIST    default
+shortcircuit USER_IN_WHITELIST       on
+shortcircuit USER_IN_DEF_WHITELIST   on
+shortcircuit USER_IN_ALL_SPAM_TO     on
+shortcircuit SUBJECT_IN_WHITELIST    on
 
-# shortcircuit ALL_TRUSTED           default
+# shortcircuit ALL_TRUSTED           on
 
-shortcircuit USER_IN_BLACKLIST       default
-shortcircuit USER_IN_BLACKLIST_TO    default
-shortcircuit SUBJECT_IN_BLACKLIST    default
+shortcircuit USER_IN_BLACKLIST       on
+shortcircuit USER_IN_BLACKLIST_TO    on
+shortcircuit SUBJECT_IN_BLACKLIST    on
 
 # shortcircuit BAYES_99              spam
 # shortcircuit BAYES_00              ham