Thread View: news.software.nntp
9 messages
9 total messages
Started by Grant Taylor
Sat, 29 Aug 2020 03:08
Cleanfeed and arbitrary headers.
Author: Grant Taylor
Date: Sat, 29 Aug 2020 03:08
Date: Sat, 29 Aug 2020 03:08
13 lines
1421 bytes
1421 bytes
Is there a way to check the contents of arbitrary headers with Cleanfeed? I'm seeing quite a bit of spam originating from Google Groups (surprise surprise). The thing is that there are about 20 different "posting-account" IDs in "Injection-Info:" headers. I would very much like to be able to filter these posting-accounts much like bad_from or bad_body contents. -- Grant. . . . unix || die
Re: Cleanfeed and arbitrary headers.
Author: yamo'
Date: Sat, 29 Aug 2020 09:04
Date: Sat, 29 Aug 2020 09:04
29 lines
1731 bytes
1731 bytes
Hi,
Grant Taylor a tapoté le 29/08/2020 05:08:
> Is there a way to check the contents of arbitrary headers with Cleanfeed?
>
> I'm seeing quite a bit of spam originating from Google Groups (surprise
> surprise). The thing is that there are about 20 different
> "posting-account" IDs in "Injection-Info:" headers. I would very much
> like to be able to filter these posting-accounts much like bad_from or
> bad_body contents.
You can edit your cleanfeed.local
sub local_filter_last {
if ($hdr{Injection-Info} =~ /what you want|another spam/i/) {
saveart('badhosts', 'Bad Injection-Info');
return reject('filtre local', 'Spammeur habituel');
};
};
--
Stéphane
Re: Cleanfeed and arbitrary headers.
Author: Grant Taylor
Date: Sat, 29 Aug 2020 16:04
Date: Sat, 29 Aug 2020 16:04
60 lines
2843 bytes
2843 bytes
On 8/29/20 3:04 AM, yamo' wrote:
> Hi,
Hi Stéphane,
> You can edit your cleanfeed.local
Okay.
That's definitely better than nothing. Though it does mean that I will
have to re-do this every time that I upgrade Cleanfeed, which admittedly
isn't that often.
I wonder if I can have this customization in a file that's included.
I'll have to go brush up on my Perl.
> sub local_filter_last {
> if ($hdr{Injection-Info} =~ /what you want|another spam/i/) {
I believe this is where I would list the multiple (sub)strings that I
wanted to match and reject based on. E.g. /posting-account=\w{32}/i/
I think that "\w" includes a-z A-Z 0-9 and underscore.
Though as I look at sample data, I may need to include hyphens.
I'd rather not write out this full set, but it may be needed until I
figure out a more concise way to do it.
[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]
> saveart('badhosts', 'Bad Injection-Info');
If I'm reading cleanfeed.pl correctly, saveart() saves (part of) the
article to a local file. Is that strictly required? Or can I
eventually forego that step by remarking that line?
> return reject('filtre local', 'Spammeur habituel');
It looks like I might want to use something like the following:
return reject('Messages from <bla> posting-account are banned.',
'Banned posting-account');
It would be really nice if I could fill <bla> with the actual value.
> };
> };
Presuming I'm understanding what needs to be done and that I can make it
work, I may try to add a bad_injection_info file and get it to be read
like bad_from and co.
Thank you again Stéphane.
--
Grant. . . .
unix || die
Re: Cleanfeed and arbitrary headers.
Author: Thomas Hochstein
Date: Sun, 30 Aug 2020 13:27
Date: Sun, 30 Aug 2020 13:27
14 lines
1478 bytes
1478 bytes
Grant Taylor wrote: > That's definitely better than nothing. Though it does mean that I will > have to re-do this every time that I upgrade Cleanfeed, which admittedly > isn't that often. I don't think so. cleanfeed.local is a local file; the Cleanfeed distribution just has a sample file included, so your cleanfeed.local file is kept. (That's the reason to add all configuration and code changes to cleanfeed.local only.) -thh
Re: Cleanfeed and arbitrary headers.
Author: U.ee
Date: Sun, 30 Aug 2020 17:43
Date: Sun, 30 Aug 2020 17:43
74 lines
3317 bytes
3317 bytes
Hi, Grant!
On 29.08.20 19:04, Grant Taylor wrote:
>
>> You can edit your cleanfeed.local
>
> Okay.
>
> That's definitely better than nothing. Though it does mean that I will
> have to re-do this every time that I upgrade Cleanfeed, which admittedly
> isn't that often.
cleanfeed.local should not overwritten, it's meant for local
customisation - hopefully you got your cleanfeed.local from renaming
package provided cleanfeed.local.sample
>
> I wonder if I can have this customization in a file that's included.
> I'll have to go brush up on my Perl.
>
>> sub local_filter_last {
>> Â Â Â if ($hdr{Injection-Info} =~ /what you want|another spam/i/) {
>
> I believe this is where I would list the multiple (sub)strings that I
> wanted to match and reject based on. E.g. /posting-account=\w{32}/i/
>
> I think that "\w" includes a-z A-Z 0-9 and underscore.
Indeed, \w is alphanumerics + underscore.
There are some nuances, but probably not important:
https://perldoc.perl.org/perlrecharclass.html
>
> Though as I look at sample data, I may need to include hyphens.
>
> I'd rather not write out this full set, but it may be needed until I
> figure out a more concise way to do it.
>
> Â Â [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]
>
>> Â Â Â Â Â Â Â Â saveart('badhosts', 'Bad Injection-Info');
>
> If I'm reading cleanfeed.pl correctly, saveart() saves (part of) the
> article to a local file. Is that strictly required? Or can I
> eventually forego that step by remarking that line?
no, you don't need saveart. That is nice though for validation (what you
catch).
>
>> Â Â Â Â Â Â Â Â return reject('filtre local', 'Spammeur habituel');
>
> It looks like I might want to use something like the following:
>
> Â Â return reject('Messages from <bla> posting-account are banned.',
> 'Banned posting-account');
>
> It would be really nice if I could fill <bla> with the actual value.
>
>> Â Â Â Â };
>> };
>
You can put variable in your message, but then you need double quotes
(") instead single quotes (').
Extracting needed variable is another thing though.
If your perl is rusty (and who writes perl everyday), then looking
filter/cleanfeed (main script, probably linked by filter_innd.pl) gives
you some ideas.
Bets regards
U.ee
Re: Cleanfeed and arbitrary headers.
Author: Matija Nalis
Date: Sun, 30 Aug 2020 20:04
Date: Sun, 30 Aug 2020 20:04
28 lines
1982 bytes
1982 bytes
On Sat, 29 Aug 2020 10:04:20 -0600, Grant Taylor <gtaylor@tnetconsulting.net> wrote:
> I think that "\w" includes a-z A-Z 0-9 and underscore.
> Though as I look at sample data, I may need to include hyphens.
>
> I'd rather not write out this full set, but it may be needed until I
> figure out a more concise way to do it.
>
> [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-]
[\w-] is much shorter and as good in perl. Note that '-' must be last in
'[]', otherwise it will be treated as range (like for example '[a-zA-Z0-9]')
perlre(1) man page goes into more detail...
> It looks like I might want to use something like the following:
>
> return reject('Messages from <bla> posting-account are banned.',
> 'Banned posting-account');
>
> It would be really nice if I could fill <bla> with the actual value.
return reject("Messages from $ACC posting-account are banned.", 'Banned posting-account');
That is, change ' to " and then you can do variable substitution inside
("$ACC" in example above, to which you need to assign value first, of course)
--
Opinions above are GNU-copylefted.
Re: Cleanfeed and arbitrary headers.
Author: Aioe
Date: Tue, 01 Sep 2020 21:27
Date: Tue, 01 Sep 2020 21:27
32 lines
2473 bytes
2473 bytes
Il Fri, 28 Aug 2020 21:08:25 -0600, Grant Taylor ha scritto:
> Is there a way to check the contents of arbitrary headers with
> Cleanfeed?
no, there is no way
look at https://www.eyrie.org/~eagle/software/inn/docs/hook-perl.html
---------------------------------------------------------------------------
filter_art() has access to a global hash named %hdr, which contains all
of the standard headers present in the article and their values. The
standard headers are:
Also-Control, Approved, Archive, Archived-At, Bytes, Cancel-Key,
Cancel-Lock,
Comments, Content-Base, Content-Disposition,
Content-Transfer-Encoding,
Content-Type, Control, Date, Date-Received, Distribution, Expires,
Face, Followup-To, From, In-Reply-To, Injection-Date, Injection-Info,
Jabber-ID, Keywords, Lines, List-ID, Message-ID, MIME-Version,
Newsgroups,
NNTP-Posting-Date, NNTP-Posting-Host, NNTP-Posting-Path,
Organization, Original-Sender, Originator,
Path, Posted, Posting-Version, Received, References, Relay-Version,
Reply-To, Sender, Subject, Summary, Supersedes, User-Agent,
X-Auth, X-Auth-Sender, X-Canceled-By, X-Cancelled-By, X-Complaints-To,
X-Face, X-HTTP-UserAgent, X-HTTP-Via, X-Mailer, X-Modbot, X-Modtrace,
X-Newsposter, X-Newsreader, X-No-Archive, X-Original-Message-ID,
X-Original-NNTP-Posting-Host, X-Original-Trace, X-Originating-IP,
X-PGP-Key, X-PGP-Sig, X-Poster-Trace, X-Postfilter, X-Proxy-User,
X-Submissions-To, X-Trace, X-Usenet-Provider, X-User-ID, Xref.
---------------------------------------------------------------------------
Re: Cleanfeed and arbitrary headers.
Author: Russ Allbery
Date: Tue, 01 Sep 2020 22:00
Date: Tue, 01 Sep 2020 22:00
25 lines
1896 bytes
1896 bytes
Aioe <estasi@aioe.org> writes:
> Il Fri, 28 Aug 2020 21:08:25 -0600, Grant Taylor ha scritto:
>> Is there a way to check the contents of arbitrary headers with
>> Cleanfeed?
> no, there is no way
> look at https://www.eyrie.org/~eagle/software/inn/docs/hook-perl.html
The background on this is that innd goes out of its way to not parse the
entirety of the headers, and instead only parses a specific set of headers
that (originally) may affect its decisions or may be justification for
rejecting an article. That header parsing table predates the filtering
hooks, but it was convenient to use the same parsing for filtering. Then,
over time, we've added additional headers that innd doesn't care about,
just to expose them to filters.
This is all kind of silly in that we wouldn't design it this way if we
were writing it from scratch today. It's more of a historical wart.
--
Russ Allbery (eagle@eyrie.org) <https://www.eyrie.org/~eagle/>
Please post questions rather than mailing me directly.
<https://www.eyrie.org/~eagle/faqs/questions.html> explains why.
Re: Cleanfeed and arbitrary headers.
Author: Julien ÉLIE
Date: Wed, 02 Sep 2020 20:54
Date: Wed, 02 Sep 2020 20:54
14 lines
1586 bytes
1586 bytes
Hi Grant,
> I would very much like to be able to filter these posting-accounts
> much like bad_from or bad_body contents.
The good news, as Paolo and Russ said, is that $hdr{'Injection-Info'}
contains what you are looking for.
All wide-spread / known header fields (in IANA registry) can be looked
into with Perl or Python filter hooks.
--
Julien ÉLIE
« César, c'est un Jules tout de même ! » (Astérix)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads