Discussion:
script for reporting ham/spam/resending?
Leon Kolchinsky
2006-10-31 17:45:29 UTC
Permalink
Hello All,

I'm running Cyrus as my IMAP server (Cyrus+Postfix+Amavis_ClamAV+Spamassassin+Web-Cyradm).

I've wrote a script for reporting spam to Razor DB and teaching with it Bayesian DB, revoking false positives from Razor DB and teaching Bayesian DB with false positives.

It looks like this (didn't test it yet, waiting for your suggestions), had to do it this way (for i in *.) cause Razor manual says that more than one non-mbox mail cannot be read from stdin:


#!/bin/bash

#######Razor stuff###############

##########Revoking############
cd /ham_folder/
chmod 644 *.
for i in *.;
do
echo Revoking $i
su vscan -c "(/usr/lib/razor-revoke $i)"
done
echo Razor Revoke Completed!
###########Reporting###########
cd /spam_folder/
chmod 644 *.
for i in *.;
do
echo Reporting $i
su vscan -c "(/usr/lib/razor-report $i)"
done
echo Razor Reporting Completed!

###########Bayesian stuff###########
su vscan -c "(sa-learn --showdots --spam /spam_folder/)"
su vscan -c "(sa-learn --showdots --ham /ham_folder/"

###########Cleaning spam folder from learned emails###########
su cyrus -c "(/usr/lib/cyrus/bin/ipurge -d0 -f user/spamkiller/spam)"

####End of the script#######


What I'm missing is a proper way of resending false positives (located now in /ham_folder/).
Should I also add the sender to a whitelist? If yes how?

How should I remove SA headers (how exactly?) and resend ham in the proper way?



Best Regards
Leon Kolchinsky
Chris Purves
2006-11-01 16:12:48 UTC
Permalink
Post by Leon Kolchinsky
Hello All,
I'm running Cyrus as my IMAP server (Cyrus+Postfix+Amavis_ClamAV+Spamassassin+Web-Cyradm).
I've wrote a script for reporting spam to Razor DB and teaching with it Bayesian DB, revoking false positives from Razor DB and teaching Bayesian DB with false positives.
#!/bin/bash
#######Razor stuff###############
##########Revoking############
cd /ham_folder/
chmod 644 *.
for i in *.;
do
echo Revoking $i
su vscan -c "(/usr/lib/razor-revoke $i)"
done
echo Razor Revoke Completed!
###########Reporting###########
cd /spam_folder/
chmod 644 *.
for i in *.;
do
echo Reporting $i
su vscan -c "(/usr/lib/razor-report $i)"
done
echo Razor Reporting Completed!
###########Bayesian stuff###########
su vscan -c "(sa-learn --showdots --spam /spam_folder/)"
su vscan -c "(sa-learn --showdots --ham /ham_folder/"
###########Cleaning spam folder from learned emails###########
su cyrus -c "(/usr/lib/cyrus/bin/ipurge -d0 -f user/spamkiller/spam)"
####End of the script#######
What I'm missing is a proper way of resending false positives (located now in /ham_folder/).
Should I also add the sender to a whitelist? If yes how?
How should I remove SA headers (how exactly?) and resend ham in the proper way?
You're making it a lot harder for yourself.

Take a look at the manual pages 'man 3 spamassassin'

spamassassin -r < ... This performes bayes learning and reports message
to razor, pyzor, DCC, and spamcop.

spamassassin -k < ... This learns as ham and revokes message with razor.
--
Chris
Leon Kolchinsky
2006-11-02 21:10:25 UTC
Permalink
Post by Leon Kolchinsky
Hello All,
I'm running Cyrus as my IMAP server (Cyrus+Postfix+Amavis_ClamAV+Spamassassin+Web-Cyradm).
I've wrote a script for reporting spam to Razor DB and teaching with it Bayesian DB, revoking false positives from Razor DB and teaching Bayesian DB with false positives.
#!/bin/bash
#######Razor stuff###############
##########Revoking############
cd /ham_folder/
chmod 644 *.
for i in *.;
do
echo Revoking $i
su vscan -c "(/usr/lib/razor-revoke $i)"
done
echo Razor Revoke Completed!
###########Reporting###########
cd /spam_folder/
chmod 644 *.
for i in *.;
do
echo Reporting $i
su vscan -c "(/usr/lib/razor-report $i)"
done
echo Razor Reporting Completed!
###########Bayesian stuff###########
su vscan -c "(sa-learn --showdots --spam /spam_folder/)"
su vscan -c "(sa-learn --showdots --ham /ham_folder/"
###########Cleaning spam folder from learned emails###########
su cyrus -c "(/usr/lib/cyrus/bin/ipurge -d0 -f user/spamkiller/spam)"
####End of the script#######
What I'm missing is a proper way of resending false positives (located now in /ham_folder/).
Should I also add the sender to a whitelist? If yes how?
How should I remove SA headers (how exactly?) and resend ham in the proper way?
You're making it a lot harder for yourself.

Take a look at the manual pages 'man 3 spamassassin'

spamassassin -r < ... This performes bayes learning and reports message
to razor, pyzor, DCC, and spamcop.

spamassassin -k < ... This learns as ham and revokes message with razor.
--
Chris

-----------




Thanks Cris,

What about resending false positives, after all filters learned that this is a ham, how should I resend these messages (on Cyrus system) to the original recipients?

Any sample code would be very welcome :)


Regards,
Leon
Chris Purves
2006-11-02 22:06:09 UTC
Permalink
Post by Leon Kolchinsky
Thanks Cris,
What about resending false positives, after all filters learned that
this is a ham, how should I resend these messages (on Cyrus system)
to > the original recipients?
Post by Leon Kolchinsky
Any sample code would be very welcome :)
If I understand you correctly, your setup takes all your users spam and
puts it into one maildir where you can accesss it. Now you have
identified false positives and have learned them as ham, but you need to
get those messages back into your users accounts.

Probably the most straightforward method would be to write a scipt that
checks the Envelope-to header and moves the file to that users inbox.

Personally, I don't manage users spam. I give them imap folders for
learn-spam and learn-ham then have a script that checks those folders
and runs sa-learn. Spam is deleted once it is learned and ham is moved
back to the inbox. For myself I also have report and revoke scripts
that do the same, but instead of using sa-learn they use spamassasin -r
or -k.
--
Chris
Leon Kolchinsky
2006-11-02 22:17:18 UTC
Permalink
Hi,

You're right, this is my situation exactly.
Your method is good for smart (intelligent) users.
This is not my case (my users here are very hard nut :)).

Just thought that may be someone have such script (for resending ham to its original recipients) running and could spare it with me :)


Best Regards,
Leon Kolchinsky

-----Original Message-----
From: Chris Purves [mailto:***@northfolk.ca]
Sent: Friday, November 03, 2006 12:06 AM
To: ***@spamassassin.apache.org
Subject: Re: script for reporting ham/spam/resending?
Post by Leon Kolchinsky
Thanks Cris,
What about resending false positives, after all filters learned that
this is a ham, how should I resend these messages (on Cyrus system)
to > the original recipients?
Post by Leon Kolchinsky
Any sample code would be very welcome :)
If I understand you correctly, your setup takes all your users spam and
puts it into one maildir where you can accesss it. Now you have
identified false positives and have learned them as ham, but you need to
get those messages back into your users accounts.

Probably the most straightforward method would be to write a scipt that
checks the Envelope-to header and moves the file to that users inbox.

Personally, I don't manage users spam. I give them imap folders for
learn-spam and learn-ham then have a script that checks those folders
and runs sa-learn. Spam is deleted once it is learned and ham is moved
back to the inbox. For myself I also have report and revoke scripts
that do the same, but instead of using sa-learn they use spamassasin -r
or -k.
--
Chris
Loading...