You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whimsical.apache.org by sebb <se...@gmail.com> on 2016/03/23 23:25:30 UTC

Handling availid regex matching

I've been finding various different regexes being used for
extracting/matching ASF availids.

So it struck me it might be useful to define the RE string once in the
asf/whimsy library.

e.g. assuming the most restrictive useradd [1] rule:

AVAILID_RE = '[a-z_][a-z0-9_-]*[$]?'

However this is too general; we don't want to allow '$'  (not
currently used in any ids) and care needs to be taken with '-' because
of INFRA-11485 / INFRA-7390.single

Maybe we need two REs:
1) matching all possible existing ids; some of these contain hyphens;
some service accounts start with _

2) a stricter version for adding new accounts - e.g. we don't want to
allow hyphen because of INFRA-11485 and we probably don't want to
allow _ either

Possibly also define some methods if there seem to some common usages
once the constants are in place.

It would certainly be useful to have a single shared uidValid? method.

Thoughts?

[1] http://www.unix.com/man-page/linux/8/useradd/

Re: Handling availid regex matching

Posted by sebb <se...@gmail.com>.
On 23 March 2016 at 22:25, sebb <se...@gmail.com> wrote:
> I've been finding various different regexes being used for
> extracting/matching ASF availids.
>
> So it struck me it might be useful to define the RE string once in the
> asf/whimsy library.
>
> e.g. assuming the most restrictive useradd [1] rule:
>
> AVAILID_RE = '[a-z_][a-z0-9_-]*[$]?'
>
> However this is too general; we don't want to allow '$'  (not
> currently used in any ids) and care needs to be taken with '-' because
> of INFRA-11485 / INFRA-7390.single
>
> Maybe we need two REs:
> 1) matching all possible existing ids; some of these contain hyphens;
> some service accounts start with _

And some avalid ids contain underscore.
One availid even contains two consecutive hyphens (tony--)

>
> 2) a stricter version for adding new accounts - e.g. we don't want to
> allow hyphen because of INFRA-11485 and we probably don't want to
> allow _ either

Not sure about prohibiting underscore.

> Possibly also define some methods if there seem to some common usages
> once the constants are in place.
>
> It would certainly be useful to have a single shared uidValid? method.
>
> Thoughts?
>
> [1] http://www.unix.com/man-page/linux/8/useradd/