Skip to content

Commit

Permalink
Make serve acceptable path unit tests more careful.
Browse files Browse the repository at this point in the history
Tests used to trigger the wanted security exception merely by being
unquoted, that's not good enough.
  • Loading branch information
tv42 committed Mar 19, 2008
1 parent f7bcd55 commit f839f88
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions gitosis/test/test_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,38 @@ def test_bad_command():
eq(str(e), 'Unknown command denied')
assert isinstance(e, serve.ServingError)

def test_bad_unsafeArguments():
def test_bad_unsafeArguments_notQuoted():
cfg = RawConfigParser()
e = assert_raises(
serve.UnsafeArgumentsError,
serve.serve,
cfg=cfg,
user='jdoe',
command='git-upload-pack /evil/attack',
command="git-upload-pack foo",
)
eq(str(e), 'Arguments to command look dangerous')
assert isinstance(e, serve.ServingError)

def test_bad_unsafeArguments_absolute():
cfg = RawConfigParser()
e = assert_raises(
serve.UnsafeArgumentsError,
serve.serve,
cfg=cfg,
user='jdoe',
command="git-upload-pack '/evil/attack'",
)
eq(str(e), 'Arguments to command look dangerous')
assert isinstance(e, serve.ServingError)

def test_bad_unsafeArguments_badCharacters():
cfg = RawConfigParser()
e = assert_raises(
serve.UnsafeArgumentsError,
serve.serve,
cfg=cfg,
user='jdoe',
command="git-upload-pack 'ev!l'",
)
eq(str(e), 'Arguments to command look dangerous')
assert isinstance(e, serve.ServingError)
Expand All @@ -64,7 +88,7 @@ def test_bad_unsafeArguments_dotdot():
serve.serve,
cfg=cfg,
user='jdoe',
command='git-upload-pack something/../evil',
command="git-upload-pack 'something/../evil'",
)
eq(str(e), 'Arguments to command look dangerous')
assert isinstance(e, serve.ServingError)
Expand Down

0 comments on commit f839f88

Please sign in to comment.