Mailing List Archive

svn commit: r497816 - in /spamassassin/trunk/masses: mass-check plugins/GrepRenderedBody.pm
Author: jm
Date: Fri Jan 19 05:53:45 2007
New Revision: 497816

URL: http://svn.apache.org/viewvc?view=rev&rev=497816
Log:
add 'mass_check_skip_message' plugin hook to mass-check, allowing plugins to cause mass-check to ignore some messages; add 'GrepRenderedBody.pm' mass-check plugin, which allows callers to 'grep' messages for mass-check by regexps matched against the rendered message body

Added:
spamassassin/trunk/masses/plugins/GrepRenderedBody.pm
Modified:
spamassassin/trunk/masses/mass-check

Modified: spamassassin/trunk/masses/mass-check
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/mass-check?view=diff&rev=497816&r1=497815&r2=497816
==============================================================================
--- spamassassin/trunk/masses/mass-check (original)
+++ spamassassin/trunk/masses/mass-check Fri Jan 19 05:53:45 2007
@@ -583,6 +583,15 @@
}
}

+ # plugin hook to cause us to skip messages
+ my $skip = $spamtest->call_plugins("mass_check_skip_message", {
+ class => $class,
+ 'time' => $time,
+ 'id' => $id,
+ msg => $ma
+ });
+ return if $skip;
+
# log-uris support
my $status;
my @uris;

Added: spamassassin/trunk/masses/plugins/GrepRenderedBody.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/plugins/GrepRenderedBody.pm?view=auto&rev=497816
==============================================================================
--- spamassassin/trunk/masses/plugins/GrepRenderedBody.pm (added)
+++ spamassassin/trunk/masses/plugins/GrepRenderedBody.pm Fri Jan 19 05:53:45 2007
@@ -0,0 +1,50 @@
+# GrepRenderedBody - dump SpamAssassin memory structures to disk after each message
+#
+# use as follows:
+#
+# ./mass-check --cf='loadplugin GrepRenderedBody plugins/GrepRenderedBody.pm' \
+# --cf='grep REGEXP' \
+# [normal mass-check arguments]
+#
+# e.g.
+#
+# ./mass-check --cf='loadplugin GrepRenderedBody plugins/GrepRenderedBody.pm' \
+# --cf='grep This is a test\.' \
+# --net -n -o spam:dir:/local/cor/recent/spam/high.2007010*
+
+package GrepRenderedBody;
+use strict;
+use Mail::SpamAssassin;
+use Mail::SpamAssassin::Plugin;
+our @ISA = qw(Mail::SpamAssassin::Plugin);
+
+sub new {
+ my ($class, $mailsa) = @_;
+ $class = ref($class) || $class;
+ my $self = $class->SUPER::new($mailsa);
+ warn "GrepRenderedBody plugin loaded";
+
+ $mailsa->{conf}->{parser}->register_commands([.{
+ setting => 'grep',
+ type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING
+ }]);
+
+ $self->{conf} = $mailsa->{conf};
+
+ bless ($self, $class);
+ return $self;
+}
+
+sub mass_check_skip_message {
+ my ($self, $opts) = @_;
+ my $ary = $opts->{msg}->get_rendered_body_text_array();
+ my $re = $self->{conf}->{grep};
+
+ # no RE? allow all msgs
+ if (!defined $re) { return 0; }
+
+ foreach my $l (@{$ary}) { if ($l =~ /${re}/s) { return 0; } }
+ return 1;
+}
+
+1;