#1006439 Spamassassin is ignoring additional own rules

#1006439#5
Date:
2022-02-25 12:57:08 UTC
From:
To:
Hello,

i think this is not a bug and spamassassin is simply not using the rules.
First i have added my own rules to /etc/spamassassin/local.cf without success.
Because this has no effect i put the files in an extra file /etc/spamassassin/myrules.cf
This is ignored too.

The aim is to recognize additional german words that are not catched with the standard rules.
Special all this sexual content is really annoying. The rule is

header CONTAINS_SUB Subject =~ /(Sex|Potenz|Dating|Finanz|FFP-2|M[aä]dchen|Bett|ficken)/i
score CONTAINS_SUB 5
describe CONTAINS_SUB Betreff enthält Spam-Wörter

I could check that the file myrules.cf has been parsed with a manual start of spamassassin, but the rules are not used.
It seems that in reality a complete other configuration is used.

Is it possible that only this directory is used:
/var/lib/spamassassin/3.004006/updates_spamassassin_org/
But this will be overwritten in updates?

Additional the package sa-compile is installed.
How can i check wether the *.cf files are used or the compiled rules that seems to be in
/var/lib/spamassassin/compiled/5.032/3.004006/auto/Mail/SpamAssassin/CompiledRegexps/body_0/body_0.so
How can i check which rules are compiled using re2c (https://re2c.org) ?

Please help to understand where own rules must be placed so that they can work?

Best regards
karsten

#1006439#12
Date:
2022-02-26 17:25:10 UTC
From:
To:
Hello Karsten,
notable?  Also consider adding the '-D' flag to generate copious
additional debug output.

I have done the following to test it, and things seem to work as
expected:

1. Install the rules:

root@a103ba41188a:/# cat > /etc/spamassassin/test.cf
header CONTAINS_SUB Subject =~
/(Sex|Potenz|Dating|Finanz|FFP-2|M[aä]dchen|Bett|ficken)/i
score CONTAINS_SUB 5
describe CONTAINS_SUB Betreff enthält Spam-Wörter

2. Construct a message to trigger the rule:

root@a103ba41188a:/# sed 's,Subject:.*,Subject: Potenz,; s,GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL,,' /usr/share/doc/spamassassin/examples/sample-spam.txt > /tmp/test.txt

3. Process the message with spamassassin. Note the report results at the
bottom:

Date: Wed, 23 Jul 2003 23:30:00 +0200
From: Sender <sender@example.net>
To: Recipient <recipient@example.net>
Precedence: junk
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is the GTUBE, the
        Generic
        Test for
        Unsolicited
        Bulk
        Email

If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):

XJS*C4JDBQADN1.NSBN3*2IDNEN**C.34X

You should send this test mail from an account outside of your network.

Spam detection software, running on the system "a103ba41188a",
has NOT identified this incoming email as spam.  The original
message has been attached to this so you can view it or label
similar future email.  If you have any questions, see
@@CONTACT_ADDRESS@@ for details.

Content preview:  This is the GTUBE, the Generic Test for Unsolicited Bulk Email
   If your spam filter supports it, the GTUBE provides a test by which you can
   verify that the filter is installed correctly and is detecting incoming spam.
   You can send yourself a test mail containing t [...]

Content analysis details:   (4.9 points, 5.0 required)

 pts rule name              description
---- ---------------------- --------------------------------------------------
 5.0 CONTAINS_SUB           Betreff enthält Spam-Wörter
-0.0 NO_RELAYS              Informational: message was not relayed via SMTP
-0.0 NO_RECEIVED            Informational: message has no Received headers

#1006439#19
Date:
2022-02-27 11:53:19 UTC
From:
To:
Hello Noah,

thank you for your support.

Am 26.02.22 um 18:25 schrieb Noah Meyerhans:
spamassassin --lint -D &> spam.log
and get

Feb 27 12:31:05.285 [2778089] dbg: config: read file /etc/spamassassin/local.cf
Feb 27 12:31:05.285 [2778089] dbg: config: read file /etc/spamassassin/myrules.cf
Feb 27 12:31:05.283 [2778089] dbg: config: read file /etc/spamassassin/sa-compile.pre
Feb 27 12:31:05.305 [2778089] dbg: pyzor: local tests only, disabling Pyzor
Feb 27 12:31:05.305 [2778089] dbg: plugin: loading Mail::SpamAssassin::Plugin::Razor2 from @INC
Feb 27 12:31:05.308 [2778089] dbg: razor2: local tests only, skipping Razor
Feb 27 12:31:05.308 [2778089] dbg: plugin: loading Mail::SpamAssassin::Plugin::SpamCop from @INC
Feb 27 12:31:05.311 [2778089] dbg: reporter: local tests only, disabling SpamCop

Feb 27 12:31:05.404 [2778089] dbg: config: fixed relative path:
/var/lib/spamassassin/3.004006/updates_spamassassin_org/10_default_prefs.cf
Feb 27 12:31:05.404 [2778089] dbg: config: using
"/var/lib/spamassassin/3.004006/updates_spamassassin_org/10_default_prefs.cf" for included file
Feb 27 12:31:05.404 [2778089] dbg: config: read file
/var/lib/spamassassin/3.004006/updates_spamassassin_org/10_default_prefs.cf
Feb 27 12:31:05.420 [2778089] dbg: config: fixed relative path:
/var/lib/spamassassin/3.004006/updates_spamassassin_org/10_hasbase.cf
Feb 27 12:31:05.420 [2778089] dbg: config: using "/var/lib/spamassassin/3.004006/updates_spamassassin_org/10_hasbase.cf"
for included file

Delivery-date: Sun, 27 Feb 2022 12:36:49 +0100
Received: from mout.kundenserver.de ([212.227.126.134])
           ...
To: debian@decotrain.de
...
X-Spam-Threshold: 5
X-Spam-Score: 4.9
X-Spam-Score-Int: 49
X-Spam-Bar: ++++
X-Spam-Flag: NO
X-Delivered-To: debian@decotrain.de
X-Message-Age: 2
Subject: My Madchen does have more sex and dating

Again there is only ficken, Finanz and Potenz.


So the question is what rules are used by the spamd process?

Other "regular spam" is detected correct like:

X-Spam-Threshold: 5
X-Spam-Score: 9.4
X-Spam-Score-Int: 94
X-Spam-Bar: +++++++++
X-Spam-Flag: YES
X-Message-Age: 3
Subject: ***SPAM (9.4)***
_=?UTF-8?B?V2lyIGdyYXR1bGllcmVuX0lobmVuIHJlY2h0IGhlcnpsaWNoLlNpZV9nZWhvcmVuIHp1IGRlbl9BdXNlcndhaGx0ZW4gZnVyX2RpZV9UZXNsYS1VbWZyYWdlLg==?=_

<html>
<p align="center"><a


I am displaying the Spam-Score by modifying the subject.

Every other test is successful too.

So the question is how i can implement my rules practical, because my rules are parsed in a test but are not active.
How i can check what is used within sa-compile?

#1006439#26
Date:
2022-03-05 11:43:40 UTC
From:
To:
Hopefully the questions can be answered here:
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7961