Koozali.org: home of the SME Server

howto add what spamassassin rules

Offline hanscees

  • *
  • 267
  • +0/-0
    • nl.linkedin.com/in/hanscees/
howto add what spamassassin rules
« on: September 01, 2014, 09:56:13 PM »
Hi,

I want to get rid of emails whith shortened links in them like http://ow.ly/rhjskgfurh   and so on.

I found the contribs howto here that describes howto add rules to spamassasin: http://wiki.contribs.org/Email#Spamassassin

But I do not understand what rules I can add. Can I just add every rule at: http://spamassassin.apache.org/tests_3_2_x.html

Any clues would be apreciated!

can I just add something like:

body LOCAL_DEMONSTRATION_RULE   /test/
score LOCAL_DEMONSTRATION_RULE 0.1
describe LOCAL_DEMONSTRATION_RULE       This is a simple test rule

(https://wiki.apache.org/spamassassin/WritingRules)

« Last Edit: September 01, 2014, 10:23:09 PM by hanscees »
nl.linkedin.com/in/hanscees/

Offline hanscees

  • *
  • 267
  • +0/-0
    • nl.linkedin.com/in/hanscees/
Re: howto add what spamassassin rules
« Reply #1 on: September 01, 2014, 10:42:43 PM »
Hi,

I want to get rid of emails whith shortened links in them like http://ow.ly/rhjskgfurh   and so on.

I found the contribs howto here that describes howto add rules to spamassasin: http://wiki.contribs.org/Email#Spamassassin

But I do not understand what rules I can add. Can I just add every rule at: http://spamassassin.apache.org/tests_3_2_x.html

Any clues would be apreciated!

can I just add something like:

body LOCAL_DEMONSTRATION_RULE   /test/
score LOCAL_DEMONSTRATION_RULE 0.1
describe LOCAL_DEMONSTRATION_RULE       This is a simple test rule

(https://wiki.apache.org/spamassassin/WritingRules)


the rule as a above works. Of course that does not mean it is a sensable rule and it should be added to the server as the contrib above writes.
nl.linkedin.com/in/hanscees/

Offline hanscees

  • *
  • 267
  • +0/-0
    • nl.linkedin.com/in/hanscees/
Re: howto add what spamassassin rules
« Reply #2 on: September 01, 2014, 11:22:20 PM »
yes it works. Here is how I added a spamassassin rule on sme9 to identify emails with url shorteners with a score of +4.1


mkdir -p /etc/e-smith/templates-custom/etc/mail/spamassassin/local.cf
vi /etc/e-smith/templates-custom/etc/mail/spamassassin/local.cf/20localscores

add to file:

rawbody OWLYANDSOON /\bhttp:\/\/\w{1,3}\.\w{1,3}\/[a-zA-Z0-9]{1,11}\b/
score OWLYANDSOON  6.1
describe OWLYANDSOON  no mail with url shorteners


save file

expand-template /etc/mail/spamassassin/local.cf

##did the file expand correct?
cat /etc/mail/spamassassin/local.cf
## is syntax correct?
spamassassin --lint

signal-event email-update


nl.linkedin.com/in/hanscees/

Offline hanscees

  • *
  • 267
  • +0/-0
    • nl.linkedin.com/in/hanscees/
Re: howto add what spamassassin rules
« Reply #3 on: September 01, 2014, 11:43:06 PM »

Actually, it fails because
signal-event email-update
or expand-template /etc/mail/spamassassin/local.cf

eats some {} form the regeps:

this in a custom template:
rawbody OWLYANDSOON /\bhttp:\/\/\w{1,3}\.\w{1,3}\/[a-zA-Z0-9]{1,11}\b/

is garbled to this:
rawbody OWLYANDSOON /\bhttp:\/\/\w3\.\w3\/[a-zA-Z0-9]11\b/


bug?
nl.linkedin.com/in/hanscees/

Re: howto add what spamassassin rules
« Reply #4 on: September 03, 2014, 12:28:18 PM »
I know weird. But it work.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: howto add what spamassassin rules
« Reply #5 on: September 03, 2014, 06:04:44 PM »
bug?

Only in your template, or perhaps some missing documentation about use of templates (I haven't checked).

{ and } need to be escaped in templates - use \{ and \}.