Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

In computing, the mean time to failure keeps getting shorter.


computers / news.software.nntp / inn: both Perl and Python filtering at the same time

SubjectAuthor
* inn: both Perl and Python filtering at the same timeAdam W.
`* Re: inn: both Perl and Python filtering at the same timeJulien ÉLIE
 +- Re: inn: both Perl and Python filtering at the same timeAdam W.
 `* Re: inn: both Perl and Python filtering at the same timeAdam W.
  +* Re: inn: both Perl and Python filtering at the same timeRay Banana
  |`- Re: inn: both Perl and Python filtering at the same timeAdam W.
  +- Re: inn: both Perl and Python filtering at the same timeJulien ÉLIE
  `- Re: inn: both Perl and Python filtering at the same timeRuss Allbery

1
inn: both Perl and Python filtering at the same time

<uh70bm$hfd$1$arnold@news.chmurka.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2351&group=news.software.nntp#2351

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!news.chmurka.net!.POSTED.s.v.chmurka.net!not-for-mail
From: gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.)
Newsgroups: news.software.nntp
Subject: inn: both Perl and Python filtering at the same time
Date: Mon, 23 Oct 2023 23:41:42 -0000 (UTC)
Organization: news.chmurka.net
Message-ID: <uh70bm$hfd$1$arnold@news.chmurka.net>
NNTP-Posting-Host: s.v.chmurka.net
Injection-Date: Mon, 23 Oct 2023 23:41:42 -0000 (UTC)
Injection-Info: news.chmurka.net; posting-account="arnold"; posting-host="s.v.chmurka.net:172.24.44.20";
logging-data="17901"; mail-complaints-to="abuse-news.(at).chmurka.net"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.32-v7+ (armv7l))
Cancel-Lock: sha1:UzjKpax3z9pjA+wCYaP6RB3JuCg=
sha1:rlBvDccPXpXPsqCukMThNLCkUww= sha256:0Pf6Q+QVweWwgIyWqnAHvpaniE1xiBUhHLlJ1Oq0Bdk=
sha1:qUFQq/eiQawc9Q8tmfRtKuNyed4= sha256:ACom+2HJP2uesyEGPRrVoJ9aNKexUPvef9wEYb9wIDw=
 by: Adam W. - Mon, 23 Oct 2023 23:41 UTC

Hi.

I have cleanfeed running, and I'm generally happy with it.

I'd like to add another rule to reject some articles (fed via newsfeeds,
not posted by posters), but I don't know Perl well enough to write it. I
know Python though.

Is it possible to run both Perl (cleanfeed) and Python (my small script,
yet to be written) filters together? What's the rule then? Both filters
have to accept the article for it to be accepted by the server (so if at
least one rejects it, it will be rejected)?

I'd expect so, but I want to be sure before I start messing around...

Re: inn: both Perl and Python filtering at the same time

<uh86d5$r6ru$1@news.trigofacile.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2356&group=news.software.nntp#2356

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.trigofacile.com!.POSTED.san13-h02-176-143-2-105.dsl.sta.abo.bbox.fr!not-for-mail
From: iulius@nom-de-mon-site.com.invalid (Julien ÉLIE)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 12:31:01 +0200
Organization: Groupes francophones par TrigoFACILE
Message-ID: <uh86d5$r6ru$1@news.trigofacile.com>
References: <uh70bm$hfd$1$arnold@news.chmurka.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Oct 2023 10:31:01 -0000 (UTC)
Injection-Info: news.trigofacile.com; posting-account="julien"; posting-host="san13-h02-176-143-2-105.dsl.sta.abo.bbox.fr:176.143.2.105";
logging-data="891774"; mail-complaints-to="abuse@trigofacile.com"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:905oZQ/Pg3gMtnNDqZ4qK+76Xnw= sha256:pBVQcJqWMrhj4TIkn/u92is+tyLMZbemTYH2AneDgZI=
sha1:mvBcBwo969X7RMqAaKPhH8jYbSE= sha256:0hrZX7+3wOwtIpCMC3FEK2r6ADYyiwmL5nYJw2xd0L0=
In-Reply-To: <uh70bm$hfd$1$arnold@news.chmurka.net>
 by: Julien ÉLIE - Tue, 24 Oct 2023 10:31 UTC

Hi Adam,

> Is it possible to run both Perl (cleanfeed) and Python (my small script,
> yet to be written) filters together? What's the rule then? Both filters
> have to accept the article for it to be accepted by the server (so if at
> least one rejects it, it will be rejected)?

Yes you can run both filters. They both have to accept the article.
The Python script (filter_innd.py) is run, then the Perl one
(filter_innd.pl, which corresponds to cleanfeed) .

% ctlinnd python y
ctlinnd: Python filter already enabled
% ctlinnd perl y
ctlinnd: Perl filter already enabled

to ensure they are enabled.

--
Julien ÉLIE

« C'est la goutte qui fait déborder l'amphore ! » (Assurancetourix)

Re: inn: both Perl and Python filtering at the same time

<uh88o9$vah$1$arnold@news.chmurka.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2358&group=news.software.nntp#2358

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!news.bbs.nz!nntp.terraraq.uk!news.chmurka.net!.POSTED.s.v.chmurka.net!not-for-mail
From: gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 11:11:05 -0000 (UTC)
Organization: news.chmurka.net
Message-ID: <uh88o9$vah$1$arnold@news.chmurka.net>
References: <uh70bm$hfd$1$arnold@news.chmurka.net> <uh86d5$r6ru$1@news.trigofacile.com>
NNTP-Posting-Host: s.v.chmurka.net
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Oct 2023 11:11:05 -0000 (UTC)
Injection-Info: news.chmurka.net; posting-account="arnold"; posting-host="s.v.chmurka.net:172.24.44.20";
logging-data="32081"; mail-complaints-to="abuse-news.(at).chmurka.net"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.32-v7+ (armv7l))
Cancel-Lock: sha1:BTHXlT3PUcJN9LE7iy9oW8GRk5o=
sha1:/3zC0VJ/SqXS8jHlXmWvE0gu07A= sha256:b3L9Jgw1/0X9CfFpXu8W4JXUctyNo4a6nlvTp0bsjXM=
sha1:svqKprDAp126yU+6DWoQCalZEhE= sha256:EortR3DYlfTcu+e7qHWvNF6R2U6ctazNPa/Xtff/MLc=
 by: Adam W. - Tue, 24 Oct 2023 11:11 UTC

Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

> Yes you can run both filters. They both have to accept the article.
> The Python script (filter_innd.py) is run, then the Perl one
> (filter_innd.pl, which corresponds to cleanfeed) .

Thanks Julien!

Re: inn: both Perl and Python filtering at the same time

<uh89ms$vah$3$arnold@news.chmurka.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2359&group=news.software.nntp#2359

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!news.chmurka.net!.POSTED.s.v.chmurka.net!not-for-mail
From: gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 11:27:24 -0000 (UTC)
Organization: news.chmurka.net
Message-ID: <uh89ms$vah$3$arnold@news.chmurka.net>
References: <uh70bm$hfd$1$arnold@news.chmurka.net> <uh86d5$r6ru$1@news.trigofacile.com>
NNTP-Posting-Host: s.v.chmurka.net
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Oct 2023 11:27:24 -0000 (UTC)
Injection-Info: news.chmurka.net; posting-account="arnold"; posting-host="s.v.chmurka.net:172.24.44.20";
logging-data="32081"; mail-complaints-to="abuse-news.(at).chmurka.net"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.32-v7+ (armv7l))
Cancel-Lock: sha1:GoxZjC87d/TkMQtJPfZuaRLQTOU=
sha1:JcPg2EppOgPgWMUY4x5+eU8Csp8= sha256:eSteCwgNBHrqm113Z1/6mcyqAupNDxmCXoPg3cWlEJY=
sha1:g2WTmFQNCdbcTGPTbkwiMN8VyzA= sha256:3dMnOHX+H1Pj0PD+yll3pqVGR8Mvxz1mkSQ5MVu/vG8=
 by: Adam W. - Tue, 24 Oct 2023 11:27 UTC

Julien ÉLIE <iulius@nom-de-mon-site.com.invalid> wrote:

> Yes you can run both filters. They both have to accept the article.
> The Python script (filter_innd.py) is run, then the Perl one
> (filter_innd.pl, which corresponds to cleanfeed) .

One more thing. Is it possible to redirect an article using a Python
filter? I'd want to edit some headers:

- move Newsgroups to X-Original-Newsgroups
- create new Newsgroups (to direct post to another group)
- maybe modify Subject (to add original group(s) name to it)

And then accept the article.

The goal is to have a local hierarchy where all these spams are posted, so
they can be reviewed (by me and by my users, if they want to).

If it's not possible, then at least I'd like to save the article to a file
before rejecting it (and post-process and repost it later, in the same way
I did with NoCeM-cancelled posts). Is it possible from within a filter?

Thanks!

Re: inn: both Perl and Python filtering at the same time

<8mfs209nuh.fsf@raybanana.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2360&group=news.software.nntp#2360

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!raybanana.eternal-september.org!.POSTED!not-for-mail
From: rayban@raybanana.net (Ray Banana)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 15:00:54 +0200
Organization: A noiseless patient spider
Lines: 29
Message-ID: <8mfs209nuh.fsf@raybanana.net>
References: <uh70bm$hfd$1$arnold@news.chmurka.net>
<uh86d5$r6ru$1@news.trigofacile.com>
<uh89ms$vah$3$arnold@news.chmurka.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: raybanana.eternal-september.org; posting-host="f900eee59e9a758277312e3a62184c00";
logging-data="4090337"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/K76wQT14B9jVR38Sg7nYB7AEE8wLruB8="
User-Agent: Plonkenlights
Cancel-Lock: sha1:mNR4ivo4LhAuImUT/f1mqvFcXjM=
sha1:SDwFAzP1t3UANXuAAqLI4dwgEMk=
X-Attribution: Ray Banana
 by: Ray Banana - Tue, 24 Oct 2023 13:00 UTC

Thus spake gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.)

> - move Newsgroups to X-Original-Newsgroups
> - create new Newsgroups (to direct post to another group)
> - maybe modify Subject (to add original group(s) name to it)

You should not modify an article in filter_innd.pl
Every time you modify a header in the filter, an innocent kitten dies
somewhere ;-)

> And then accept the article.
> The goal is to have a local hierarchy where all these spams are posted, so
> they can be reviewed (by me and by my users, if they want to).
>
> If it's not possible, then at least I'd like to save the article to a file
> before rejecting it (and post-process and repost it later, in the same way
> I did with NoCeM-cancelled posts). Is it possible from within a filter?

In general, don't do too much processing inside the filter, as it may bring
the INN daemon to a screeching halt, when the spam flood gets really
heavy.

Been there, done that, got little sleep.

--
Пу́тін — хуйло́
http://www.eternal-september.org

Re: inn: both Perl and Python filtering at the same time

<uh8n89$renl$1@news.trigofacile.com>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2361&group=news.software.nntp#2361

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.trigofacile.com!.POSTED.176-143-2-105.abo.bbox.fr!not-for-mail
From: iulius@nom-de-mon-site.com.invalid (Julien ÉLIE)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 17:18:33 +0200
Organization: Groupes francophones par TrigoFACILE
Message-ID: <uh8n89$renl$1@news.trigofacile.com>
References: <uh70bm$hfd$1$arnold@news.chmurka.net>
<uh86d5$r6ru$1@news.trigofacile.com> <uh89ms$vah$3$arnold@news.chmurka.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Oct 2023 15:18:33 -0000 (UTC)
Injection-Info: news.trigofacile.com; posting-account="julien"; posting-host="176-143-2-105.abo.bbox.fr:176.143.2.105";
logging-data="899829"; mail-complaints-to="abuse@trigofacile.com"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1xCncPWl4U2Y8g/bQmNrUqVd3bs= sha256:fddyWAXhdWCOS4ysyCDMIYnoTVcS/jolmobR72huAr8=
sha1:eFNuxvEMR/JtwsBunXeykUEOLCY= sha256:bdw1okisXf8shZjZ1LN8NrgyjwPQ/CAEbE6mpkBfuTU=
In-Reply-To: <uh89ms$vah$3$arnold@news.chmurka.net>
 by: Julien ÉLIE - Tue, 24 Oct 2023 15:18 UTC

Hi Adam,

> One more thing. Is it possible to redirect an article using a Python
> filter? I'd want to edit some headers:
>
> - move Newsgroups to X-Original-Newsgroups
> - create new Newsgroups (to direct post to another group)
> - maybe modify Subject (to add original group(s) name to it)
>
> And then accept the article.

As Ray Banana said, that's not possible.

> If it's not possible, then at least I'd like to save the article to a file
> before rejecting it (and post-process and repost it later, in the same way
> I did with NoCeM-cancelled posts). Is it possible from within a filter?

Yes, just before rejecting the article, just open a file and write (or
append) the article.

https://www.eyrie.org/~eagle/software/inn/docs/hook-python.html

Take all the header fields which are not empty from the art dictionary,
and then write art['__BODY__'] as the body.

Also, as said, it may eat CPU cycles and slow innd down. Worth trying
though, depending on how many articles you receive per second and how
fast your system is.

--
Julien ÉLIE

« Que l'on serve notre boisson nationale, le calva, dans des crânes de
vaincus ! » (Astérix)

Re: inn: both Perl and Python filtering at the same time

<877cncujah.fsf@hope.eyrie.org>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2362&group=news.software.nntp#2362

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.killfile.org!news.eyrie.org!.POSTED!not-for-mail
From: eagle@eyrie.org (Russ Allbery)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Tue, 24 Oct 2023 08:33:42 -0700
Organization: The Eyrie
Message-ID: <877cncujah.fsf@hope.eyrie.org>
References: <uh70bm$hfd$1$arnold@news.chmurka.net>
<uh86d5$r6ru$1@news.trigofacile.com>
<uh89ms$vah$3$arnold@news.chmurka.net>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: hope.eyrie.org;
logging-data="10426"; mail-complaints-to="news@eyrie.org"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:z2c6iGHc91pimfJYbVC7VIMkjv4=
 by: Russ Allbery - Tue, 24 Oct 2023 15:33 UTC

gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.) writes:

> One more thing. Is it possible to redirect an article using a Python
> filter? I'd want to edit some headers:

> - move Newsgroups to X-Original-Newsgroups
> - create new Newsgroups (to direct post to another group)
> - maybe modify Subject (to add original group(s) name to it)

> And then accept the article.

> The goal is to have a local hierarchy where all these spams are posted, so
> they can be reviewed (by me and by my users, if they want to).

INN already has some built-in support for filing articles into the special
newsgroup junk regardless of what newsgroup it was actually posted to.
Currently, filters don't have any way of telling innd to file the filtered
article into junk, but that might be a useful feature to add.

That doesn't get you everything else you want, though, and it would put
them all in a single group, so it may not solve your problem (in which
case it might just be a feature without a use case).

We won't ever want to support modifying the headers of the article itself,
since the risk is too high that we'll accidentally propagate the modified
article back out on Usenet and make a mess.

--
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: inn: both Perl and Python filtering at the same time

<uhchej$csr$3$arnold@news.chmurka.net>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2364&group=news.software.nntp#2364

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!news.chmurka.net!.POSTED.s.v.chmurka.net!not-for-mail
From: gof-cut-this-news@cut-this-chmurka.net.invalid (Adam W.)
Newsgroups: news.software.nntp
Subject: Re: inn: both Perl and Python filtering at the same time
Date: Thu, 26 Oct 2023 02:04:03 -0000 (UTC)
Organization: news.chmurka.net
Message-ID: <uhchej$csr$3$arnold@news.chmurka.net>
References: <uh70bm$hfd$1$arnold@news.chmurka.net> <uh86d5$r6ru$1@news.trigofacile.com> <uh89ms$vah$3$arnold@news.chmurka.net> <8mfs209nuh.fsf@raybanana.net>
NNTP-Posting-Host: s.v.chmurka.net
Injection-Date: Thu, 26 Oct 2023 02:04:03 -0000 (UTC)
Injection-Info: news.chmurka.net; posting-account="arnold"; posting-host="s.v.chmurka.net:172.24.44.20";
logging-data="13211"; mail-complaints-to="abuse-news.(at).chmurka.net"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.32-v7+ (armv7l))
Cancel-Lock: sha1:Tsw4EHUN2YJsxa8Dk7uofUpDUe4=
sha1:IIgGg/lK3Wu0wA5CAGkXpfP8uNw= sha256:/h4yRD/odj89CD99J0hXem+pi2ImjAAcbhYbAWfy9mk=
sha1:dZLRGVG6yhzn3fsbOyCvdQXJ/RE= sha256:GzpdWSvxeTDcf7WklvdXVHCWguddPuV4aRAf3ias82M=
 by: Adam W. - Thu, 26 Oct 2023 02:04 UTC

Ray Banana <rayban@raybanana.net> wrote:

> You should not modify an article in filter_innd.pl
> Every time you modify a header in the filter, an innocent kitten dies
> somewhere ;-)

Oh no, save the kittens! :)

Thanks for your response (and all other responses). I wrote the filter and
I'm running it on the full feed. It saves rejected articles to files that
are later processed and end up being posted to chmurka.spam.*.thai (* is
the affected hierarchy). These groups are available on news.chmurka.net
without authentication (but chmurka.spam.* is stored in a 1 GiB CNFS, so
the retention might be short).

Here's the script (but I might change it later if something doesn't work
as it should). Suggestions are welcome:

http://www.chmurka.net/r/usenet/filter_innd.py.txt

Let's see how it works... if it does, I might as well start posting
NoCeMs with these articles.

> In general, don't do too much processing inside the filter, as it may bring
> the INN daemon to a screeching halt, when the spam flood gets really
> heavy.

Creating a file and writing to it counts as "too much", I guess... but
let's see.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor