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 2005/10/28 02:56:33 UTC

svn commit: r329011 - in /spamassassin/trunk/masses: rule-hits-over-time rule-qa/automc/ruleqa.cgi

Author: jm
Date: Thu Oct 27 17:56:31 2005
New Revision: 329011

URL: http://svn.apache.org/viewcvs?rev=329011&view=rev
Log:
hook rule-hits-over-time graphs into rule-QA CGI

Modified:
    spamassassin/trunk/masses/rule-hits-over-time
    spamassassin/trunk/masses/rule-qa/automc/ruleqa.cgi

Modified: spamassassin/trunk/masses/rule-hits-over-time
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/masses/rule-hits-over-time?rev=329011&r1=329010&r2=329011&view=diff
==============================================================================
--- spamassassin/trunk/masses/rule-hits-over-time (original)
+++ spamassassin/trunk/masses/rule-hits-over-time Thu Oct 27 17:56:31 2005
@@ -101,7 +101,7 @@
     push @{$file_sets}, [ $file ];
   }
   else {
-    if ($file =~ /ham/) {
+    if ($file =~ /\bham\b/) {
       push @{$file_sets->[0]}, $file;
     } else {
       push @{$file_sets->[1]}, $file;
@@ -214,7 +214,12 @@
   $seen_y = 0;
   $seen_n = 0;
 
-  open (IN, "<$file") or die "cannot read $file";
+  if ($file =~ /\.gz$/) {
+    open (IN, "gunzip -cd '$file'|") or die "cannot gunzip $file";
+  } else {
+    open (IN, "<$file") or die "cannot read $file";
+  }
+
   while (<IN>) {
     next if /^#/;
 

Modified: spamassassin/trunk/masses/rule-qa/automc/ruleqa.cgi
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/masses/rule-qa/automc/ruleqa.cgi?rev=329011&r1=329010&r2=329011&view=diff
==============================================================================
--- spamassassin/trunk/masses/rule-qa/automc/ruleqa.cgi (original)
+++ spamassassin/trunk/masses/rule-qa/automc/ruleqa.cgi Thu Oct 27 17:56:31 2005
@@ -12,6 +12,8 @@
 use bytes;
 use POSIX qw(strftime);
 
+my $myperl = $^X;
+
 open (CF, "<$automcdir/config");
 my %conf; while(<CF>) { /^(\S+)=(\S+)/ and $conf{$1} = $2; }
 close CF;
@@ -30,7 +32,6 @@
 );
 
 my $q = new CGI;
-print $q->header;
 
 my $ttk = Template->new;
 
@@ -79,11 +80,23 @@
 $daterev =~ /(\d+\/r\d+)/;
 $daterev = $1;
 
+# all known date/revision combos.  warning: could get slow in future
+my @daterevs = get_all_daterevs();
+# turn possibly-empty $daterev into a real date/rev combo (that exists)
+$daterev = date_in_direction($daterev, 0);
+
 my $rule = $q->url_param('rule') || '';
 
+$s{graph} = $q->url_param('graph') || '';
+if ($s{graph} eq 'ruleshit') {
+  graph_ruleshit();
+  die "oops! should not get here";  # prev method should exit
+}
+
 my $nicerule = $rule; if (!$nicerule) { $nicerule = 'all rules'; }
 my $title = "Mass-check: $daterev $nicerule";
 
+print $q->header;
 print q{<html><head>
 
   <style type="text/css" media="all">
@@ -226,9 +239,6 @@
 
 };
 
-# all known date/revision combos.  warning: could get slow in future
-my @daterevs = get_all_daterevs();
-
 my $days = {
   neg3 => -3,
   neg2 => -2,
@@ -294,11 +304,20 @@
 show_all_sets_for_daterev($daterev, $daterev);
 
 if ($s{detail}) {
-} else {
+  my $url_rh = gen_switch_url("s_graph", "ruleshit");
+  print qq{
+
+    <h3 class=graph_title>graphs</h3>
+    <ul>
+      <li><a href="$url_rh">rules hit over time</a></li>
+    </ul>
+
+  };
+
   my @parms =get_params_except(qw(
           rule s_age s_overlap s_all s_detail
         ));
-  my $url = $cgi_url.'?'.join('&', sort @parms);
+  $url = $cgi_url.'?'.join('&', sort @parms);
 
   print qq{
 
@@ -376,6 +395,25 @@
   # special case: we only build this for one set, as it's quite slow
   # to generate
   $s{overlap} and showfreqsubset("OVERLAP.new", $strdate);
+}
+
+###########################################################################
+
+sub graph_ruleshit {
+  $datadir = $conf{html}."/".$daterev."/";
+
+  # logs are named e.g.
+  # /home/automc/corpus/html/20051028/r328993/LOGS.all-ham-mc-fast.log.gz
+
+  # untaint
+  $rule =~ /([_0-9a-zA-Z]+)/; my $saferule = $1;
+  $datadir =~ /([-\.\,_0-9a-zA-Z]+)/; my $safedatadir = $1;
+
+  exec ("$myperl $automcdir/../../rule-hits-over-time ".
+        "--cgi --rule='$saferule' ".
+        "$safedatadir/LOGS.*.log.gz");
+
+  die "exec failed";
 }
 
 ###########################################################################