From users-return-123920-archive-asf-public=cust-asf.ponee.io@spamassassin.apache.org Tue Mar 16 01:57:19 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id BED19180642 for ; Tue, 16 Mar 2021 02:57:19 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id 7A9A3435DD for ; Tue, 16 Mar 2021 01:57:12 +0000 (UTC) Received: (qmail 45888 invoked by uid 500); 16 Mar 2021 01:57:11 -0000 Mailing-List: contact users-help@spamassassin.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@spamassassin.apache.org Received: (qmail 45875 invoked by uid 99); 16 Mar 2021 01:57:11 -0000 Received: from mailrelay1-he-de.apache.org (HELO mailrelay1-he-de.apache.org) (116.203.21.61) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Mar 2021 01:57:11 +0000 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by mailrelay1-he-de.apache.org (ASF Mail Server at mailrelay1-he-de.apache.org) with ESMTPSA id EF6E43E8AB for ; Tue, 16 Mar 2021 01:57:09 +0000 (UTC) Received: by mail-qk1-f178.google.com with SMTP id l132so33806911qke.7 for ; Mon, 15 Mar 2021 18:57:09 -0700 (PDT) X-Gm-Message-State: AOAM532+oaoFIf7bazduozXcJP8DAAxXUujYLrl9bNc1Ii/2vUooOF/6 hD2jGP6XnEvZndZI0TvYq57yIOTEhCPYuni2AEk9vA== X-Google-Smtp-Source: ABdhPJw64tpW2n+Owj3oxluL0+OukHP7uBXBax/dp8xaFIhl7Ixxi0YkrdwEu1pDH6eeRPbehW0zmPtZ/g5aH21xOh8= X-Received: by 2002:a37:6491:: with SMTP id y139mr28082180qkb.483.1615859828736; Mon, 15 Mar 2021 18:57:08 -0700 (PDT) MIME-Version: 1.0 References: <1182ae89-3734-642-e2a4-8fb5fc65f93f@prime.gushi.org> <730DA3E0-C66E-4080-86C3-57CD418A624B@prime.gushi.org> <7C60D974-5DCF-4A32-A21C-C02B65D79A7C@prime.gushi.org> In-Reply-To: <7C60D974-5DCF-4A32-A21C-C02B65D79A7C@prime.gushi.org> From: "Kevin A. McGrail" Date: Mon, 15 Mar 2021 21:56:57 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Rule tag for _USERNAME_? To: Dan Mahoney Cc: SA Mailing list Content-Type: multipart/alternative; boundary="000000000000195d1805bd9daf4b" --000000000000195d1805bd9daf4b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Oooh, Intriguing. Keep me in the loop! -- Kevin A. McGrail Member, Apache Software Foundation Chair Emeritus Apache SpamAssassin Project https://www.linkedin.com/in/kmcgrail - 703.798.0171 On Mon, Mar 15, 2021 at 1:37 AM Dan Mahoney wrote: > > > On Mar 14, 2021, at 9:45 PM, Kevin A. McGrail wrote= : > > Well, SpamAssMilter *must* be capturing the data from spamc and creating > that header. If you look at the cpp, it's building it. You could change > the Milter to create a header called X-ImaMilter and use any data you wan= t. > > > No argument there. My point was that it=E2=80=99s not just checking it f= or > =E2=80=99normal=E2=80=99 spamassassin output (i.e. sanitizing the header = returned to see if > it matches any standard. I can put anything i want in that header and > (modulo length) it will transit through to my MTA=E2=80=99s logs. > > But it looks like signal_user_changed sets self->{username} in spamd so i= f > you want, try this small patch for PerMsgStatus and lmk. I tested it > locally and it works. It would need more documentation and cleanup to ad= d > it but it's safe as a proof of concept: > > Index: lib/Mail/SpamAssassin/PerMsgStatus.pm > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- lib/Mail/SpamAssassin/PerMsgStatus.pm (revision 1884910) > +++ lib/Mail/SpamAssassin/PerMsgStatus.pm (working copy) > @@ -257,6 +257,11 @@ > my $pms =3D shift; > $pms->{main}->timer_report(); > }, > + > + USERNAME =3D> sub { > + my $pms =3D shift; > + $pms->{main}->{username}; > + }, > > ADDEDHEADERHAM =3D> sub { > my $pms =3D shift; > > > I=E2=80=99ll give that a try in the next day. I=E2=80=99ve been down the= rabbit hole on a > different project. People in this community will likely notice my effort= s > tho. > > Thanks Kevin > > -Dan > > > > > On Sun, Mar 14, 2021 at 7:10 AM Dan Mahoney wrote: > >> >> >> On Mar 13, 2021, at 7:51 PM, Kevin A. McGrail >> wrote: >> >> Hi Dan, >> >> Milters are the glue that change the email. SpamAssassin is just giving >> data back to the milter. >> >> I believe you will find that X-Spam-Status header is being built by >> spamass-milter not by spamassasin. You need to change the milter code t= o >> keep track of the user and add it to the X-Spam-Status line in the >> spamass-milter.cpp >> >> >> That=E2=80=99s not true. >> >> While it=E2=80=99s true that we=E2=80=99ve had issues getting spamass-mi= lter to allow >> headers OTHER than the standard spamassassin ones through, I can pack th= e >> info I want in to the X-Spam-Status header. Here=E2=80=99s an example o= f a recent >> mail: >> >> X-Spam-Status: No, score=3D2.5 required=3D5.0 tests=3DDCC_CHECK=3D1.1, >> DCC_REPUT_95_98=3D0.7,DKIM_INVALID=3D0.1,DKIM_SIGNED=3D0.1, >> HAS_UNSUBSCRIBE=3D0.01,HTML_IMAGE_RATIO_04=3D0.001,HTML_MESSAGE=3D0.001= , >> ISC_UNDISCLOSED=3D0.01,KAM_DMARC_STATUS=3D0.01,KAM_EU=3D0.5, >> SPF_HELO_NONE=3D0.001,SPF_PASS=3D-0.001 autolearn=3Ddisabled version=3D= 3.4.4 >> Lang=3Dfr ASN=3DAS3292 USER=3D_USERNAME_ >> >> This comes from SA's local.cf: >> >> local.cf:add_header all Status _YESNO_, score=3D_SCORE_ required=3D_REQD= _ >> tests=3D_TESTSSCORES_ autolearn=3D_AUTOLEARN_ version=3D_VERSION_ >> Lang=3D_LANGUAGES_ ASN=3D_ASN_ USER=3D_USERNAME_ >> local.cf:add_header all Language _LANGUAGES_ (this one doesn=E2=80=99t s= how up) >> >> See where I have _USERNAME_ being passed through as a bareword? I would >> like to have the LHS/RHS of whatever email address was used to pull up >> userprefs in that field. >> >> -Dan >> >> >> Regards, >> KAM >> --. >> Kevin A. McGrail >> Member, Apache Software Foundation >> Chair Emeritus Apache SpamAssassin Project >> https://www.linkedin.com/in/kmcgrail - 703.798.0171 >> >> >> On Fri, Jan 15, 2021 at 5:31 PM Dan Mahoney (Gushi) >> wrote: >> >>> All, >>> >>> For dumb reasons, we at the day job are using spamass-milter, which >>> doesn't seem to let SpamAssassin add any extra X-Spam-Foo: message tag= s >>> beyond stock (I have a github issue open on this, which seems to be >>> where a fork is being maintained). >>> >>> However, in order to work around this, I've added more tags to the >>> X-Spam-Status tag locally. Which is useful because it also lets me gre= p >>> my maillogs for those things. >>> >>> What I can't find, and it feels like it should be a thing, is the >>> *username* for the tag. That is to say, the username that's being used >>> to >>> find the user-prefs (in our case, with spamd, it's just %u, we don't >>> have >>> the user/domain stuff set up). >>> >>> This *feels* like something a quick .pm file should be able to add >>> rather >>> than having to modify spamassassin core (and in fact, the tokens for >>> username, mailbox and domain *are* available for the bayes_sql_query, >>> but >>> for some reason aren't exposed as tags that can be used in the report >>> header. Which feels somehow deliberate.) >>> >>> Would this be easy to do? >>> >>> It would also mean I could easily glean per-user/per-rule-hit reporting >>> from my maillogs with a simple grep, rather than having to >>> cross-correlate >>> the mta logs from the spamd ones. This feels like a win. >>> >>> -Dan >>> >>> -- >>> >>> >>> --------Dan Mahoney-------- >>> Techie, Sysadmin, WebGeek >>> Gushi on efnet/undernet IRC >>> FB: fb.com/DanielMahoneyIV >>> LI: linkedin.com/in/gushi >>> Site: http://www.gushi.org >>> --------------------------- >>> >>> >> > --000000000000195d1805bd9daf4b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Oooh, Intriguing.=C2=A0 Keep me in the lo= op!
= --
Kevin A. McGrail
Member, Apache Software Founda= tion
Chair Emeritus Apach= e SpamAssassin Project
https://ww= w.linkedin.com/in/kmcgrail=C2=A0- 703.798.0171
=


On Mon, Mar 15, 2021 at 1:37 AM Dan Mahoney <danm@prime.gushi.org> wrote:


On Mar 14, 2021, at 9:= 45 PM, Kevin A. McGrail <kmcgrail@apache.org> wrote:

Well, SpamAssMilter *must* be capturing the data from s= pamc and creating that header.=C2=A0 If you look at the cpp, it's build= ing=C2=A0it.=C2=A0 You could change the Milter to create a header called X-= ImaMilter and use any data you want.
No argument there.=C2=A0 My point was that it=E2=80=99s not jus= t checking it for =E2=80=99normal=E2=80=99 spamassassin output (i.e. saniti= zing the header returned to see if it matches any standard.=C2=A0 I can put= anything i want in that header and (modulo length) it will transit through= to my MTA=E2=80=99s logs.

But it looks like signal_use= r_changed sets self->{username} in spamd so if you want, try this small = patch for PerMsgStatus and lmk.=C2=A0 I tested it locally and it works.=C2= =A0 It would need more documentation and cleanup to add it but it's saf= e as a proof of concept:

Index: lib/Mail/SpamAssas= sin/PerMsgStatus.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
--- lib/Mail/SpamAssassin/PerMsgStatus.pm =C2=A0 =C2=A0 =C2=A0 (revisio= n 1884910)
+++ lib/Mail/SpamAssassin/PerMsgStatus.pm =C2=A0 =C2=A0 =C2= =A0 (working copy)
@@ -257,6 +257,11 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0my= $pms =3D shift;
=C2=A0 =C2=A0 =C2=A0 =C2=A0$pms->{main}->timer_re= port();
=C2=A0 =C2=A0 =C2=A0},
+
+ =C2=A0 =C2=A0USERNAME =3D> = sub {
+ =C2=A0 =C2=A0 =C2=A0my $pms =3D shift;
+ =C2=A0 =C2=A0 =C2=A0= $pms->{main}->{username};
+ =C2=A0 =C2=A0},
=C2=A0
=C2=A0 = =C2=A0 =C2=A0ADDEDHEADERHAM =3D> sub {
=C2=A0 =C2=A0 =C2=A0 =C2=A0my = $pms =3D shift;

I=E2=80=99ll give that a try in the next day.=C2=A0 I=E2=80=99ve been do= wn the rabbit hole on a different project.=C2=A0 People in this community w= ill likely notice my efforts tho.

Thanks Kevin

-Dan




On Sun, Mar 14, 2021 at 7:10 AM Dan Mahoney <danm@prime.gushi.org> wrote:


On Mar 13, 2021, at 7:51 PM, Kevin A. McGrail &= lt;kmcgrail@apache= .org> wrote:

Hi Dan,=

Milters are the glue that change the email.=C2=A0 SpamA= ssassin is just giving data back to the milter.=C2=A0=C2=A0

<= div>I believe you will find that X-Spam-Status header is being built by spa= mass-milter not by spamassasin.=C2=A0 You need to change the milter code to= keep track of the user and add it to the X-Spam-Status line in the spamass= -milter.cpp

T= hat=E2=80=99s not true.

While it=E2=80=99s true th= at we=E2=80=99ve had issues getting spamass-milter to allow headers OTHER t= han the standard spamassassin ones through, I can pack the info I want in t= o the X-Spam-Status header.=C2=A0 Here=E2=80=99s an example of a recent mai= l:

X-Spam-Status: No, score=3D2.5 required=3D= 5.0 tests=3DDCC_CHECK=3D1.1,
=C2=A0DCC_REPUT_95_98=3D0.7,DKIM_INV= ALID=3D0.1,DKIM_SIGNED=3D0.1,
=C2=A0HAS_UNSUBSCRIBE=3D0.01,HTML_I= MAGE_RATIO_04=3D0.001,HTML_MESSAGE=3D0.001,
=C2=A0ISC_UNDISCLOSED= =3D0.01,KAM_DMARC_STATUS=3D0.01,KAM_EU=3D0.5,
=C2=A0SPF_HELO_NONE= =3D0.001,SPF_PASS=3D-0.001 autolearn=3Ddisabled version=3D3.4.4
= =C2=A0Lang=3Dfr ASN=3DAS3292 USER=3D_USERNAME_

Thi= s comes from SA's local.= cf:=C2=A0

local.cf:add_header all Status = _YESNO_, score=3D_SCORE_ required=3D_REQD_ tests=3D_TESTSSCORES_ autolearn= =3D_AUTOLEARN_ version=3D_VERSION_ Lang=3D_LANGUAGES_ ASN=3D_ASN_ USER=3D_U= SERNAME_
local.cf:add_header all Language _LANGUAGES_ (this one d= oesn=E2=80=99t show up)

See where I have _USERNAME= _ being passed through as a bareword?=C2=A0 I would like to have the LHS/RH= S of whatever email address was used to pull up userprefs in that field.

-Dan

=

Regards,KAM
--.
Kevin= A. McGrail
Member, Apach= e Software Foundation
Cha= ir Emeritus Apache SpamAssassin Project
https://www.linkedin.com/in/kmcgrail=C2=A0- 703.798.0171<= /div>

=

= On Fri, Jan 15, 2021 at 5:31 PM Dan Mahoney (Gushi) <danm@prime.gushi.org> wrote:<= br>
All,

For dumb reasons, we at the day job are using spamass-milter, which
doesn't seem to let SpamAssassin add any extra X-Spam-Foo:=C2=A0 messag= e tags
beyond stock (I have a github issue open on this, which seems to be
where a fork is being maintained).

However, in order to work around this, I've added more tags to the
X-Spam-Status tag locally.=C2=A0 Which is useful because it also lets me gr= ep
my maillogs for those things.

What I can't find, and it feels like it should be a thing, is the
*username* for the tag.=C2=A0 That is to say, the username that's being= used to
find the user-prefs (in our case, with spamd, it's just %u, we don'= t have
the user/domain stuff set up).

This *feels* like something a quick .pm file should be able to add rather <= br> than having to modify spamassassin core (and in fact, the tokens for
username, mailbox and domain *are* available for the bayes_sql_query, but <= br> for some reason aren't exposed as tags that can be used in the report <= br> header.=C2=A0 Which feels somehow deliberate.)

Would this be easy to do?

It would also mean I could easily glean per-user/per-rule-hit reporting from my maillogs with a simple grep, rather than having to cross-correlate =
the mta logs from the spamd ones.=C2=A0 This feels like a win.

-Dan

--


--------Dan Mahoney--------
Techie,=C2=A0 Sysadmin,=C2=A0 WebGeek
Gushi on efnet/undernet IRC
FB:=C2=A0 fb.com/DanielMahoneyIV
LI:=C2=A0 =C2=A0linkedin.com/in/gushi
Site:=C2=A0 http://www.gushi.org
---------------------------



--000000000000195d1805bd9daf4b--