Allow underscores, dots and dashes in SSH username local parts.
This commit is contained in:
parent
cbea1785d0
commit
b5e966c107
2 changed files with 28 additions and 1 deletions
|
@ -3,7 +3,7 @@ import logging
|
|||
|
||||
log = logging.getLogger('gitosis.ssh')
|
||||
|
||||
_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9]*(@[a-z][a-z0-9.-]*)?$')
|
||||
_ACCEPTABLE_USER_RE = re.compile(r'^[a-z][a-z0-9_.-]*(@[a-z][a-z0-9.-]*)?$')
|
||||
|
||||
def isSafeUsername(user):
|
||||
match = _ACCEPTABLE_USER_RE.match(user)
|
||||
|
|
|
@ -36,6 +36,33 @@ def test_ssh_extract_user_domain_dashes():
|
|||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fakeuser@ridiculously-long.example.com')
|
||||
eq(got, 'fakeuser@ridiculously-long.example.com')
|
||||
|
||||
def test_ssh_extract_user_underscore():
|
||||
got = init.ssh_extract_user(
|
||||
'ssh-somealgo '
|
||||
+'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake_user@example.com')
|
||||
eq(got, 'fake_user@example.com')
|
||||
|
||||
def test_ssh_extract_user_dot():
|
||||
got = init.ssh_extract_user(
|
||||
'ssh-somealgo '
|
||||
+'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u.ser@example.com')
|
||||
eq(got, 'fake.u.ser@example.com')
|
||||
|
||||
def test_ssh_extract_user_dash():
|
||||
got = init.ssh_extract_user(
|
||||
'ssh-somealgo '
|
||||
+'0123456789ABCDEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
|
||||
+'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= fake.u-ser@example.com')
|
||||
eq(got, 'fake.u-ser@example.com')
|
||||
|
||||
def test_ssh_extract_user_no_at():
|
||||
got = init.ssh_extract_user(
|
||||
'ssh-somealgo '
|
||||
|
|
Loading…
Reference in a new issue