diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-05 03:32:58 +0000 |
commit | 08f8cfe14e0f8937e3bcf8a22becdc5ce60b920e (patch) | |
tree | 30977064b5f93f9ac5b01b2a676f6d6ffdcec652 /test/rubygems/test_gem_package.rb | |
parent | 593505ac6f802d2b5bff469425b7c76b65cc9b10 (diff) |
Merge RubyGems upstream: 56c0bbb69e4506bda7ef7f447dfec5db820df20b
It fixed the multiple vulnerabilities.
https://blog.rubygems.org/2019/03/05/security-advisories-2019-03.html
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_package.rb')
-rw-r--r-- | test/rubygems/test_gem_package.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index 17e288998f..c7a83319a0 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -544,6 +544,40 @@ class TestGemPackage < Gem::Package::TarTestCase end end + def test_extract_symlink_parent_doesnt_delete_user_dir + package = Gem::Package.new @gem + + # Extract into a subdirectory of @destination; if this test fails it writes + # a file outside destination_subdir, but we want the file to remain inside + # @destination so it will be cleaned up. + destination_subdir = File.join @destination, 'subdir' + FileUtils.mkdir_p destination_subdir + + destination_user_dir = File.join @destination, 'user' + destination_user_subdir = File.join destination_user_dir, 'dir' + FileUtils.mkdir_p destination_user_subdir + + tgz_io = util_tar_gz do |tar| + tar.add_symlink 'link', destination_user_dir, 16877 + tar.add_symlink 'link/dir', '.', 16877 + end + + e = assert_raises(Gem::Package::PathError, Errno::EACCES) do + package.extract_tar_gz tgz_io, destination_subdir + end + + assert_path_exists destination_user_subdir + + if Gem::Package::PathError === e + assert_equal("installing into parent path #{destination_user_subdir} of " + + "#{destination_subdir} is not allowed", e.message) + elsif win_platform? + skip "symlink - must be admin with no UAC on Windows" + else + raise e + end + end + def test_extract_tar_gz_directory package = Gem::Package.new @gem |