On Thu, 2021-12-02 at 13:42 +0000, Dominic Raferd wrote:
> I have a score-reducing algorithm for SA based on known 'good' senders. 
>  From a simple one-address-per-line file (which can easily be manually
> or automatically edited) is built a local_welcoming.cf file which is 
> used by SA - with lines like this:
> 
> score LOCAL_WELCOMING_4 -4
> header LOCAL_WELCOMING_4 From =~ 
> /(\@myfriend\.com|jennifer_smith\@btinternet\.com|\
> fred321@gmail\.com)>?\s*$/i
> 
I ran into this problem quite some time ago and wrote 'portmanteau', a
tool easing the maintenance of Spamassassin rules which consist of very
large lists of alternates. It does this by storing the rule definition
in a form that's much easier to edit than it would be if it was written
as a single very long line or split into a set of subrules plus a meta
rule to combine them. It is a bash shell script that uses a gawk script
to do the heavy lifting.

The elements of each SA rule it constructs are held in an easily edited
'.def' file which, among other things, expects each regex in a list of
alternates to be on a separate line. Normallly, you'd hold the set of
rule definitions in the same directory. Running the 'portmanteau' script
constructs one valid SA rule, which may be built from subrules and
metas, from each .def file in thr directory and writes the complete set
of generated rules to a single .cf file. The rule building process is
fast enough that its not worthwhile building them separately.

The rule constructor is an awk script, so there's nothing exotic in it
and no external dependencies, always assuming yo have awk or gawk
installed.

I use 'portmanteau' rules for everything from maintaining personal
blacklists to constructing complex rules that do things like recognising
toxic attachment types or sets of phrases that, if found in several
headers and/or body text that together identify specific spam types and
score the message accordingly.

You can find the 'portmanteau' tool here:
https://www.libelle-systems.com/free/portmanteau/portmanteau.tgz
  
Martin


Reply via email to