Skip to content

Commit 2aa8652

Browse files
committed
Add tests for path traversal errors
1 parent 633b2aa commit 2aa8652

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/test_git.rb

+12
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ def test_fs_read
8383
assert_equal 'bar', @git.fs_read('foo')
8484
end
8585

86+
def test_fs_read_path_traversal
87+
assert_raise RuntimeError do
88+
@git.fs_read('../foo')
89+
end
90+
end
91+
8692
def test_fs_write
8793
f = stub
8894
f.expects(:write).with('baz')
@@ -91,6 +97,12 @@ def test_fs_write
9197
@git.fs_write('foo/bar', 'baz')
9298
end
9399

100+
def test_fs_write_path_traversal
101+
assert_raise RuntimeError do
102+
@git.fs_read('../foo/bar')
103+
end
104+
end
105+
94106
def test_fs_delete
95107
FileUtils.expects(:rm_rf).with(File.join(@git.git_dir, 'foo'))
96108
@git.fs_delete('foo')

0 commit comments

Comments
 (0)