Thread View: news.software.nntp
12 messages
12 total messages
Started by D. Stussy
Wed, 25 Jun 2008 07:09
Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Wed, 25 Jun 2008 07:09
Date: Wed, 25 Jun 2008 07:09
31 lines
2457 bytes
2457 bytes
I'm seeing some messages with bogus group names with "&" and "@" in them.
I've also seen ";" being used as a separator instead of ",". Has anyone
else written a group name filter (a regex expression) patch?
Based on the valid names at isc.org -- with one modification (allowing a
digit as the first character), I think the appropriate expression should be
something close to:
[a-z0-9]([-a-z0-9._+]*[-a-z0-9_+])*
I don't like having a dash ("-") or an underscore ("_") as the last
character, but isc.org's page says that's valid. There are programming
groups that end with plus ("+"), so those should be accepted. I think this
also properly kills any double or multiple dot values (i.e. any string that
has two or more consecutive periods). Except for groups that use [A-Z],
will this reject any valid group? Is that a regex format acceptable to
perl?
I note that there are things that it won't check for:
- A fully numeric name component.
- The length requirement of any component.
- The number of components.
- Invalid components such as "all" or "ctl".
...But it's not meant to check for everything.
As far as any patch goes, there's also one option I'd like as a
consideration: Whether an article with an invalid group name should be
accepted (altered to post only to its valid groups, if any) or outright
rejected (i.e. not posted to any groups).
Re: Cleanfeed - Any rules for invalid group names?
Author: Julien ÉLIE
Date: Wed, 25 Jun 2008 19:13
Date: Wed, 25 Jun 2008 19:13
83 lines
4726 bytes
4726 bytes
Hi D. Stussy,
> I'm seeing some messages with bogus group names with "&" and "@" in them.
> I've also seen ";" being used as a separator instead of ",". Has anyone
> else written a group name filter (a regex expression) patch?
>
> Based on the valid names at isc.org -- with one modification (allowing a
> digit as the first character), I think the appropriate expression should be
> something close to:
>
> [a-z0-9]([-a-z0-9._+]*[-a-z0-9_+])*
Do you really want a regexp in order to achieve that?
Otherwise, you can see what newgroup.pl does in INN:
# Check the group name. This is partially derived from C News.
# Some checks are commented out if I think they're too strict or
# language-dependent. Your mileage may vary.
sub checkgroupname {
local $_ = shift;
# whole-name checking
return 'Empty group name' if /^$/;
return 'Whitespace in group name' if /\s/;
return 'Unsafe group name' if /[\`\/:;]/;
return 'Bad dots in group name' if /^\./ or /\.$/ or /\.\./;
# return 'Group name does not begin/end with alphanumeric'
# if (/^[a-zA-Z0-9].+[a-zA-Z0-9]$/;
return 'Group name begins in control., junk. or to.' if /^(?:control|junk|to)\./;
# return 'Group name too long' if length $_ > 128;
my @components = split(/\./);
# prevent alt.a.b.c.d.e.f.g.w.x.y.z...
return 'Too many components' if $#components > 9;
# per-component checking
for (my $i = 0; $i <= $#components; $i++) {
local $_ = $components[$i];
return 'all-numeric name component' if /^[0-9]+$/;
# return 'name component starts with non-alphanumeric' if /^[a-zA-Z0-9]/;
# return 'name component does not contain letter' if not /[a-zA-Z]/;
return "`all' or `ctl' used as name component" if /^(?:all|ctl)$/;
# return 'name component longer than 30 characters' if length $_ > 30;
# return 'uppercase letter(s) in name' if /[A-Z]/;
return 'illegal character(s) in name' if /[^a-z0-9+_\-.]/;
# sigh, c++ etc must be allowed
return 'repeated punctuation in name' if /--|__|\+\+./;
# return 'repeated component(s) in name' if ($i + 2 <= $#components
# and $_ eq $components[$i + 1] and $_ eq $components[$i + 2]);
}
return '';
}
> I note that there are things that it won't check for:
> - A fully numeric name component.
> - The length requirement of any component.
> - The number of components.
> - Invalid components such as "all" or "ctl".
> ...But it's not meant to check for everything.
Done in the function above :)
> As far as any patch goes, there's also one option I'd like as a
> consideration: Whether an article with an invalid group name should be
> accepted (altered to post only to its valid groups, if any) or outright
> rejected (i.e. not posted to any groups).
I think it should be accepted. It is the default behaviour of news server,
I assume. If you post to "news.software.nntp,unknown.group" and if your
news server has the first one, I believe it should be posted to it.
(as for the "junk" newsgroup when you do not have news.software.nntp,
I do not think it useful for readers)
--
Julien ÉLIE
« Quel prodige ! Rien qu'en vous voyant, les pirates
refusent le combat et coulent leur propre navire ! » (Astérix)
Re: Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Thu, 26 Jun 2008 20:14
Date: Thu, 26 Jun 2008 20:14
49 lines
3686 bytes
3686 bytes
"Julien ÉLIE" <iulius@nom-de-mon-site.com.invalid> wrote in message news:g3u5cn$5qt$1@news.trigofacile.com... > > I'm seeing some messages with bogus group names with "&" and "@" in them. > > I've also seen ";" being used as a separator instead of ",". Has anyone > > else written a group name filter (a regex expression) patch? > > > > Based on the valid names at isc.org -- with one modification (allowing a > > digit as the first character), I think the appropriate expression should be > > something close to: > > > > [a-z0-9]([-a-z0-9._+]*[-a-z0-9_+])* > > Do you really want a regexp in order to achieve that? > Otherwise, you can see what newgroup.pl does in INN: Newgroup.pl only filters control messages, not those locally input via ctlinnd. (See below) I don't need to check for "everything." > > As far as any patch goes, there's also one option I'd like as a > > consideration: Whether an article with an invalid group name should be > > accepted (altered to post only to its valid groups, if any) or outright > > rejected (i.e. not posted to any groups). > > I think it should be accepted. It is the default behaviour of news server, > I assume. If you post to "news.software.nntp,unknown.group" and if your > news server has the first one, I believe it should be posted to it. > (as for the "junk" newsgroup when you do not have news.software.nntp, > I do not think it useful for readers) I thought about this, and decided that I was thinking about the wrong point in the transaction - for what I want to do. However, I also feel that a "437 Invalid Group Name" may be better than "437 No Such Group," so I thought of cleanfeed first. Lastly, noting that articles to bad group names are basically spam, that's why I was thinking of discarding messages that had them and NOT accepting them into the valid groups listed. So that might occasionally discard a non-spammy message with a misspelled group, but don't most news readers warn about non-listed groups before/when posting anyway? What I need is an expression that can filter the "unwanted.log" file output - as that's really where I'd be using it. I'd like to separate my unwanted list into two (or more) lists: Groups with valid names and those without. (A third category is the "semi-valid" category: leading digit or capital letters.) So, do I have the "guts" of the regex correctly stated (which will have a leading "^" and trailing "$" added when implemented)?
Re: Cleanfeed - Any rules for invalid group names?
Author: Peter J Ross
Date: Wed, 02 Jul 2008 17:07
Date: Wed, 02 Jul 2008 17:07
110 lines
4195 bytes
4195 bytes
In news.software.nntp on Wed, 25 Jun 2008 00:09:39 -0700, D. Stussy
<spam@bde-arc.ampr.org> wrote:
> Based on the valid names at isc.org -- with one modification (allowing a
> digit as the first character), I think the appropriate expression should be
> something close to:
>
> [a-z0-9]([-a-z0-9._+]*[-a-z0-9_+])*
Try this.
[a-z0-9][a-z0-9_+-]*(\.([a-z0-9][a-z0-9_+-])*)*
> I don't like having a dash ("-") or an underscore ("_") as the last
> character, but isc.org's page says that's valid. There are programming
> groups that end with plus ("+"), so those should be accepted. I think this
> also properly kills any double or multiple dot values (i.e. any string that
> has two or more consecutive periods).
Yours doesn't; mine should.
> Except for groups that use [A-Z],
You could use "(?i)" to switch off case-sensitivity.
> will this reject any valid group?
I don't think so.
> Is that a regex format acceptable to perl?
It's acceptable PCRE.
> I note that there are things that it won't check for:
> - A fully numeric name component.
> - The length requirement of any component.
> - The number of components.
> - Invalid components such as "all" or "ctl".
> ...But it's not meant to check for everything.
I have a few PCREs that I use to check for those errors (and others)
here: <http://pjr.lasnobberia.net/usenet/validator>. Some of this
snippet of PHP might be adaptable for your purposes:
#v+
if (preg_match ('/\s/', $groupName)) {
$fault = TRUE;
echo $errorWhiteSpace;
}
if (! preg_match ('/\./', $groupName)) {
$fault = TRUE;
echo $errorNoDots;
}
if (preg_match ('/^\./', $groupName)) {
$fault = TRUE;
echo $errorStartDots;
}
if (preg_match ('/\.\./', $groupName)) {
$fault = TRUE;
echo $errorConsecDots;
}
if (preg_match ('/\.$/', $groupName)) {
$fault = TRUE;
echo $errorEndDots;
}
if (preg_match ('/^(control|to|example)\./', $groupName)) {
$fault = TRUE;
echo $errorForbiddenHierarchy;
}
if (preg_match ('/\.(all|ctl)(\.|$)/', $groupName)) {
$fault = TRUE;
echo $errorAllCtl;
}
if (preg_match ('/^[^a-z]/', $groupName)) {
$fault = TRUE;
echo $errorStartLetter;
}
if (preg_match ('/[^a-z0-9._+\s-]/', $groupName)) {
$fault = TRUE;
echo $errorInvalidChars;
}
if (preg_match ('/(^|\.)[0-9]+($|\.)/', $groupName)) {
$fault = TRUE;
echo $errorOnlyDigits;
}
if (preg_match ('/(^|\.)[+_-]/', $groupName)) {
$fault = TRUE;
echo $errorPlusMin;
}
if (preg_match ('/_/', $groupName)) {
if (preg_match('/^(comp|humanities|misc|news|rec|sci|soc|talk)\./', $groupName)) {
$fault = TRUE;
echo $errorUnderscore;
}
}
foreach ($groupNameComponents as $value) {
if (strlen($value) > 30) {
$fault = TRUE;
echo $errorLongComponent;
}
}
#v-
--
PJR :-)
<http://pjr.lasnobberia.net/>
<http://slrn-doc.sourceforge.net/>
Re: Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Thu, 03 Jul 2008 21:32
Date: Thu, 03 Jul 2008 21:32
21 lines
1776 bytes
1776 bytes
"Peter J Ross" <pjr@example.invalid> wrote in message
news:slrng6ndff.5jv.pjr@pjr.motzarella.org...
> ...
> Try this.
>
> [a-z0-9][a-z0-9_+-]*(\.([a-z0-9][a-z0-9_+-])*)*
OK. I like that better. However, I think that requires any component to
have at least two characters. I think you have a misplaced inner left
parenthesis.
[a-z0-9][-a-z0-9_\+]*(\.[a-z0-9][-a-z0-9_\+]*)*
Doesn't the dash have to appear first (so it's not a "broken range") and
doesn't the plus sign need to be escaped?
ISC's rules (which forbid a leading digit in a NG name) would be:
[a-z][-a-z0-9_\+]*(\.[a-z0-9][-a-z0-9_\+]*)*
Re: Cleanfeed - Any rules for invalid group names?
Author: Peter J Ross
Date: Fri, 04 Jul 2008 14:55
Date: Fri, 04 Jul 2008 14:55
37 lines
2478 bytes
2478 bytes
In news.software.nntp on Thu, 3 Jul 2008 14:32:54 -0700, D. Stussy <spam@bde-arc.ampr.org> wrote: > "Peter J Ross" <pjr@example.invalid> wrote in message > news:slrng6ndff.5jv.pjr@pjr.motzarella.org... >> ... >> Try this. >> >> [a-z0-9][a-z0-9_+-]*(\.([a-z0-9][a-z0-9_+-])*)* > > OK. I like that better. However, I think that requires any component to > have at least two characters. I think you have a misplaced inner left > parenthesis. Oops! > [a-z0-9][-a-z0-9_\+]*(\.[a-z0-9][-a-z0-9_\+]*)* You're matching a literal backslash there. > Doesn't the dash have to appear first (so it's not a "broken range") "If a minus character is required in a class, it must be escaped with a backslash or appear in a position where it cannot be interpreted as indicating a range, typically as the first or last character in the class." - man 3 pcrepattern ^^^^^^^ > and doesn't the plus sign need to be escaped? Not in a character class. -- PJR :-) <http://pjr.lasnobberia.net/> <http://slrn-doc.sourceforge.net/>
Re: Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Fri, 04 Jul 2008 21:16
Date: Fri, 04 Jul 2008 21:16
38 lines
2433 bytes
2433 bytes
"Peter J Ross" <pjr@example.invalid> wrote in message
news:slrng6sef9.5k8.pjr@pjr.motzarella.org...
> In news.software.nntp on Thu, 3 Jul 2008 14:32:54 -0700, D. Stussy
> <spam@bde-arc.ampr.org> wrote:
> > "Peter J Ross" <pjr@example.invalid> wrote in message
> > news:slrng6ndff.5jv.pjr@pjr.motzarella.org...
> >> ...
> >> Try this.
> >>
> >> [a-z0-9][a-z0-9_+-]*(\.([a-z0-9][a-z0-9_+-])*)*
> >
> > OK. I like that better. However, I think that requires any component
to
> > have at least two characters. I think you have a misplaced inner left
> > parenthesis.
>
> Oops!
>
> > [a-z0-9][-a-z0-9_\+]*(\.[a-z0-9][-a-z0-9_\+]*)*
>
> You're matching a literal backslash there.
>
> > Doesn't the dash have to appear first (so it's not a "broken range")
>
> "If a minus character is required in a class, it must be escaped with
> a backslash or appear in a position where it cannot be interpreted as
> indicating a range, typically as the first or last character in the
> class." - man 3 pcrepattern ^^^^^^^
>
> > and doesn't the plus sign need to be escaped?
>
> Not in a character class.
OK, so do you agree with (ISC strict version):
[a-z][a-z0-9_+-]*(\.[a-z0-9][a-z0-9_+-]*)*
Re: Cleanfeed - Any rules for invalid group names?
Author: Peter J Ross
Date: Fri, 04 Jul 2008 23:55
Date: Fri, 04 Jul 2008 23:55
19 lines
1945 bytes
1945 bytes
In news.software.nntp on Fri, 4 Jul 2008 14:16:41 -0700, D. Stussy <spam@bde-arc.ampr.org> wrote: > OK, so do you agree with (ISC strict version): > > [a-z][a-z0-9_+-]*(\.[a-z0-9][a-z0-9_+-]*)* That seems good to me. I assume you're aware of the "pcretest" utility that comes with pcre. This thread would have been shorter if either of us had used it. $ man 1 pcretest -- PJR :-) <http://pjr.lasnobberia.net/> <http://slrn-doc.sourceforge.net/>
Re: Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Sat, 05 Jul 2008 05:51
Date: Sat, 05 Jul 2008 05:51
20 lines
1961 bytes
1961 bytes
"Peter J Ross" <pjr@example.invalid> wrote in message news:slrng6te3f.5j4.pjr@pjr.motzarella.org... > In news.software.nntp on Fri, 4 Jul 2008 14:16:41 -0700, D. Stussy > <spam@bde-arc.ampr.org> wrote: > > > OK, so do you agree with (ISC strict version): > > > > [a-z][a-z0-9_+-]*(\.[a-z0-9][a-z0-9_+-]*)* > > That seems good to me. > > I assume you're aware of the "pcretest" utility that comes with pcre. > This thread would have been shorter if either of us had used it. > > $ man 1 pcretest I don't use perl. It hadn't been invented by the time I got my CS degree. C wasn't even in common usage yet - just still a plaything then.
Re: Cleanfeed - Any rules for invalid group names?
Author: Szymon Sokół
Date: Sat, 05 Jul 2008 09:45
Date: Sat, 05 Jul 2008 09:45
15 lines
2423 bytes
2423 bytes
On Fri, 4 Jul 2008 22:51:57 -0700, D. Stussy wrote: > I don't use perl. It hadn't been invented by the time I got my CS degree. > C wasn't even in common usage yet - just still a plaything then. So what? I have used six different programming languages that were never part of my curriculum. And I have learned Perl some 10 years after getting my degree. Sorry for the off-topic posting, but this sort of attitude grates on my nerves. A sysadmin MUST be able and willing to learn new things. -- Szymon Sokół (SS316-RIPE) -- Network Manager B Computer Center, AGH - University of Science and Technology, Cracow, Poland O http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F Free speech includes the right not to listen, if not interested -- Heinlein H
Re: Cleanfeed - Any rules for invalid group names?
Author: D. Stussy
Date: Sun, 06 Jul 2008 04:20
Date: Sun, 06 Jul 2008 04:20
20 lines
2301 bytes
2301 bytes
"Szymon Sokó³" <szymon@bastard.operator.from.hell.pl> wrote in message news:hqnazxv4o0yu.dlg@falcon.sloth.hell.pl... > On Fri, 4 Jul 2008 22:51:57 -0700, D. Stussy wrote: > > I don't use perl. It hadn't been invented by the time I got my CS degree. > > C wasn't even in common usage yet - just still a plaything then. > > So what? I have used six different programming languages that were never > part of my curriculum. And I have learned Perl some 10 years after getting > my degree. Sorry for the off-topic posting, but this sort of attitude grates > on my nerves. A sysadmin MUST be able and willing to learn new things. Well, excuse me for never getting around to it - since I have had no direct involvement in needing to know it. In fact, the application where I'll be using the regex isn't written in perl either. My current primary job is NOT in the computer field. In fact, the last time I had a paid job in the field ended in 1987.
Re: Cleanfeed - Any rules for invalid group names?
Author: Szymon Sokół
Date: Sun, 06 Jul 2008 11:25
Date: Sun, 06 Jul 2008 11:25
32 lines
3398 bytes
3398 bytes
On Sat, 5 Jul 2008 21:20:10 -0700, D. Stussy wrote: > "Szymon Sokó³" <szymon@bastard.operator.from.hell.pl> wrote in message > news:hqnazxv4o0yu.dlg@falcon.sloth.hell.pl... >> On Fri, 4 Jul 2008 22:51:57 -0700, D. Stussy wrote: >>> I don't use perl. It hadn't been invented by the time I got my CS > degree. >>> C wasn't even in common usage yet - just still a plaything then. >> >> So what? I have used six different programming languages that were never >> part of my curriculum. And I have learned Perl some 10 years after getting >> my degree. Sorry for the off-topic posting, but this sort of attitude > grates >> on my nerves. A sysadmin MUST be able and willing to learn new things. > > Well, excuse me for never getting around to it - since I have had no direct > involvement in needing to know it. In fact, the application where I'll be > using the regex isn't written in perl either. My current primary job is NOT > in the computer field. In fact, the last time I had a paid job in the field > ended in 1987. Sorry if I have offended you. I do not claim that everyone should learn Perl (or any other skill, for that matter); I only objected to the implied suggestion that you haven't learned Perl *because* it wasn't taught when you were a student. If all of us knew only what we were taught at the university, it would have been really hard to have any work done. -- Szymon Sokół (SS316-RIPE) -- Network Manager B Computer Center, AGH - University of Science and Technology, Cracow, Poland O http://home.agh.edu.pl/szymon/ PGP key id: RSA: 0x2ABE016B, DSS: 0xF9289982 F Free speech includes the right not to listen, if not interested -- Heinlein H
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