You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Kelly Jones <ke...@gmail.com> on 2006/12/22 02:09:23 UTC

Capturing regular expression while testing new rule?

Many people write test rules w/ small negative scores like this:

header SUBJ_FOO_BAR_TEST Subject =~ /foo.*bar/
describe SUBJ_FOO_BAR_TEST Subject contains both "foo" and "bar" in that order
score SUBJ_FOO_BAR_TEST -0.001

The logs will then show when SUBJ_FOO_BAR_TEST is hit.

I want to go one step further and log what's between the "foo" and the
"bar" in the subject. If I do this:

header SUBJ_FOO_BAR_TEST Subject =~ /foo(.*)bar/
describe SUBJ_FOO_BAR_TEST Subject contains both "foo" and "bar" in that order
score SUBJ_FOO_BAR_TEST -0.001

will the parentheses capture and log the $1 match above?

If not, how can I log the string a given rule matches?

Can I log the psuedo-headers X-Spam-Relays-Trusted and
X-Spam-Relays-Untrusted?

If not, can I make SpamAssassin add these headers to the email before
its delivered?

I'm running on a production system, so I can't do anything too risky--
I just want to test a rule and see what regexps it's matching.

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.

Re: Capturing regular expression while testing new rule?

Posted by Theo Van Dinter <fe...@apache.org>.
On Fri, Dec 22, 2006 at 10:16:13AM +0000, Justin Mason wrote:
> Actually, if you run with -D, like:
>     spamassassin -D -Lt < spam.txt
> part of the debug output is
> 1. the Relays-Trusted etc lines
> 2. the parts of the message text that caused any body rules
> to fire:

Right, so true, one thing I missed is running spamd in debug mode and likely
specifying the channels you want to see, and then that stuff would get sent to
syslog.

My thought when previously answering was about only logging at very specific
points (ie: just the text in between the words in the rule, not the results
from all rules, etc,) which would require code of some form.

-- 
Randomly Selected Tagline:
Are you a turtle?

Re: Capturing regular expression while testing new rule?

Posted by Theo Van Dinter <fe...@apache.org>.
On Thu, Dec 21, 2006 at 06:09:23PM -0700, Kelly Jones wrote:
> Many people write test rules w/ small negative scores like this:
> header SUBJ_FOO_BAR_TEST Subject =~ /foo.*bar/

Really?  Why would you write a rule like that?

> header SUBJ_FOO_BAR_TEST Subject =~ /foo(.*)bar/
> will the parentheses capture and log the $1 match above?

No.

> If not, how can I log the string a given rule matches?

Short of writing your own plugin/code, you can't.

> Can I log the psuedo-headers X-Spam-Relays-Trusted and
> X-Spam-Relays-Untrusted?

If you write code.

> If not, can I make SpamAssassin add these headers to the email before
> its delivered?

Sure, use add_header.

-- 
Randomly Selected Tagline:
Bender: "You know the secret of traditional robot cooking? Start with a good
 high-quality oil, then eat it."