rubygems-update 3.4.19 → 3.4.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +36 -0
- data/bundler/CHANGELOG.md +29 -0
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/bundler/lib/bundler/cli/info.rb +1 -1
- data/bundler/lib/bundler/cli/update.rb +1 -0
- data/bundler/lib/bundler/fetcher/base.rb +2 -2
- data/bundler/lib/bundler/fetcher/compact_index.rb +1 -5
- data/bundler/lib/bundler/fetcher/dependency.rb +1 -1
- data/bundler/lib/bundler/fetcher.rb +31 -30
- data/bundler/lib/bundler/index.rb +62 -31
- data/bundler/lib/bundler/installer/standalone.rb +8 -1
- data/bundler/lib/bundler/lockfile_parser.rb +3 -15
- data/bundler/lib/bundler/man/gemfile.5 +11 -0
- data/bundler/lib/bundler/man/gemfile.5.ronn +5 -0
- data/bundler/lib/bundler/plugin.rb +1 -1
- data/bundler/lib/bundler/resolver.rb +18 -3
- data/bundler/lib/bundler/retry.rb +1 -1
- data/bundler/lib/bundler/ruby_dsl.rb +23 -2
- data/bundler/lib/bundler/self_manager.rb +2 -0
- data/bundler/lib/bundler/settings.rb +37 -13
- data/bundler/lib/bundler/source/git/git_proxy.rb +14 -2
- data/bundler/lib/bundler/source/rubygems.rb +22 -25
- data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +1 -1
- data/bundler/lib/bundler/version.rb +1 -1
- data/lib/rubygems/available_set.rb +1 -1
- data/lib/rubygems/basic_specification.rb +2 -2
- data/lib/rubygems/command.rb +16 -19
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/dependency_command.rb +3 -4
- data/lib/rubygems/commands/owner_command.rb +8 -10
- data/lib/rubygems/commands/uninstall_command.rb +6 -7
- data/lib/rubygems/commands/unpack_command.rb +4 -6
- data/lib/rubygems/config_file.rb +1 -1
- data/lib/rubygems/core_ext/kernel_gem.rb +1 -1
- data/lib/rubygems/core_ext/kernel_warn.rb +4 -5
- data/lib/rubygems/dependency_installer.rb +8 -12
- data/lib/rubygems/deprecate.rb +2 -2
- data/lib/rubygems/gemcutter_utilities.rb +2 -2
- data/lib/rubygems/installer.rb +9 -11
- data/lib/rubygems/name_tuple.rb +1 -1
- data/lib/rubygems/package/tar_reader/entry.rb +18 -20
- data/lib/rubygems/package/tar_reader.rb +0 -5
- data/lib/rubygems/package.rb +10 -4
- data/lib/rubygems/query_utils.rb +1 -1
- data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
- data/lib/rubygems/resolver/activation_request.rb +2 -4
- data/lib/rubygems/resolver/installed_specification.rb +1 -1
- data/lib/rubygems/resolver/local_specification.rb +1 -1
- data/lib/rubygems/s3_uri_signer.rb +1 -1
- data/lib/rubygems/security/trust_dir.rb +4 -6
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/source/local.rb +34 -37
- data/lib/rubygems/source.rb +2 -2
- data/lib/rubygems/source_list.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +29 -33
- data/lib/rubygems/specification.rb +34 -26
- data/lib/rubygems/specification_policy.rb +33 -32
- data/lib/rubygems/stub_specification.rb +13 -10
- data/lib/rubygems/uninstaller.rb +1 -1
- data/lib/rubygems/user_interaction.rb +2 -2
- data/lib/rubygems/util/licenses.rb +115 -0
- data/lib/rubygems/validator.rb +5 -7
- data/lib/rubygems.rb +5 -7
- data/rubygems-update.gemspec +1 -1
- data/test/rubygems/helper.rb +17 -19
- data/test/rubygems/test_gem.rb +4 -4
- data/test/rubygems/test_gem_commands_build_command.rb +2 -1
- data/test/rubygems/test_gem_commands_stale_command.rb +1 -1
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock +28 -12
- data/test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml +1 -1
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock +16 -14
- data/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml +1 -1
- data/test/rubygems/test_gem_indexer.rb +1 -1
- data/test/rubygems/test_gem_package.rb +117 -2
- data/test/rubygems/test_gem_package_tar_header.rb +7 -7
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +53 -1
- data/test/rubygems/test_gem_package_tar_writer.rb +13 -13
- data/test/rubygems/test_gem_remote_fetcher.rb +21 -25
- data/test/rubygems/test_gem_requirement.rb +1 -1
- data/test/rubygems/test_gem_specification.rb +42 -6
- data/test/rubygems/test_gem_update_suggestion.rb +14 -20
- data/test/rubygems/test_require.rb +4 -6
- data/test/rubygems/utilities.rb +2 -2
- metadata +3 -3
data/test/rubygems/helper.rb
CHANGED
@@ -118,30 +118,28 @@ class Gem::TestCase < Test::Unit::TestCase
|
|
118
118
|
# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
|
119
119
|
def capture_subprocess_io
|
120
120
|
_synchronize do
|
121
|
-
|
122
|
-
require "tempfile"
|
121
|
+
require "tempfile"
|
123
122
|
|
124
|
-
|
123
|
+
captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
|
126
|
+
$stdout.reopen captured_stdout
|
127
|
+
$stderr.reopen captured_stderr
|
129
128
|
|
130
|
-
|
129
|
+
yield
|
131
130
|
|
132
|
-
|
133
|
-
|
131
|
+
$stdout.rewind
|
132
|
+
$stderr.rewind
|
134
133
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
134
|
+
return captured_stdout.read, captured_stderr.read
|
135
|
+
ensure
|
136
|
+
$stdout.reopen orig_stdout
|
137
|
+
$stderr.reopen orig_stderr
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
end
|
139
|
+
orig_stdout.close
|
140
|
+
orig_stderr.close
|
141
|
+
captured_stdout.close!
|
142
|
+
captured_stderr.close!
|
145
143
|
end
|
146
144
|
end
|
147
145
|
|
@@ -935,7 +933,7 @@ class Gem::TestCase < Test::Unit::TestCase
|
|
935
933
|
@a1 = quick_gem "a", "1" do |s|
|
936
934
|
s.files = %w[lib/code.rb]
|
937
935
|
s.require_paths = %w[lib]
|
938
|
-
s.date = Gem::Specification::TODAY -
|
936
|
+
s.date = Gem::Specification::TODAY - 86_400
|
939
937
|
s.homepage = "http://a.example.com"
|
940
938
|
s.email = %w[example@example.com example2@example.com]
|
941
939
|
s.authors = %w[Example Example2]
|
data/test/rubygems/test_gem.rb
CHANGED
@@ -1053,7 +1053,7 @@ class TestGem < Gem::TestCase
|
|
1053
1053
|
end
|
1054
1054
|
|
1055
1055
|
def test_self_ruby_version_with_non_mri_implementations
|
1056
|
-
util_set_RUBY_VERSION "2.5.0", 0,
|
1056
|
+
util_set_RUBY_VERSION "2.5.0", 0, 60_928, "jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]"
|
1057
1057
|
|
1058
1058
|
assert_equal Gem::Version.new("2.5.0"), Gem.ruby_version
|
1059
1059
|
ensure
|
@@ -1061,7 +1061,7 @@ class TestGem < Gem::TestCase
|
|
1061
1061
|
end
|
1062
1062
|
|
1063
1063
|
def test_self_ruby_version_with_svn_prerelease
|
1064
|
-
util_set_RUBY_VERSION "2.6.0", -1,
|
1064
|
+
util_set_RUBY_VERSION "2.6.0", -1, 63_539, "ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]"
|
1065
1065
|
|
1066
1066
|
assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version
|
1067
1067
|
ensure
|
@@ -1077,7 +1077,7 @@ class TestGem < Gem::TestCase
|
|
1077
1077
|
end
|
1078
1078
|
|
1079
1079
|
def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility
|
1080
|
-
util_set_RUBY_VERSION "2.6.0", -1,
|
1080
|
+
util_set_RUBY_VERSION "2.6.0", -1, 63_539, "weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]", "weirdjruby", "9.2.0.0"
|
1081
1081
|
|
1082
1082
|
assert_equal Gem::Version.new("2.6.0.preview2"), Gem.ruby_version
|
1083
1083
|
ensure
|
@@ -1085,7 +1085,7 @@ class TestGem < Gem::TestCase
|
|
1085
1085
|
end
|
1086
1086
|
|
1087
1087
|
def test_self_ruby_version_with_svn_trunk
|
1088
|
-
util_set_RUBY_VERSION "1.9.2", -1,
|
1088
|
+
util_set_RUBY_VERSION "1.9.2", -1, 23_493, "ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]"
|
1089
1089
|
|
1090
1090
|
assert_equal Gem::Version.new("1.9.2.dev"), Gem.ruby_version
|
1091
1091
|
ensure
|
@@ -199,7 +199,8 @@ class TestGemCommandsBuildCommand < Gem::TestCase
|
|
199
199
|
|
200
200
|
error = @ui.error.split "\n"
|
201
201
|
assert_equal "WARNING: licenses is empty, but is recommended. Use a license identifier from", error.shift
|
202
|
-
assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license
|
202
|
+
assert_equal "http://spdx.org/licenses or 'Nonstandard' for a nonstandard license,", error.shift
|
203
|
+
assert_equal "or set it to nil if you don't want to specify a license.", error.shift
|
203
204
|
assert_equal "WARNING: See https://guides.rubygems.org/specification-reference/ for help", error.shift
|
204
205
|
assert_equal [], error
|
205
206
|
|
@@ -29,7 +29,7 @@ class TestGemCommandsStaleCommand < Gem::TestCase
|
|
29
29
|
|
30
30
|
filename = File.join(foo_bar.full_gem_path, file)
|
31
31
|
FileUtils.mkdir_p File.dirname filename
|
32
|
-
FileUtils.touch(filename, :mtime => Time.now -
|
32
|
+
FileUtils.touch(filename, :mtime => Time.now - 86_400)
|
33
33
|
end
|
34
34
|
|
35
35
|
use_ui @stub_ui do
|
@@ -13,9 +13,9 @@ dependencies = [
|
|
13
13
|
|
14
14
|
[[package]]
|
15
15
|
name = "bindgen"
|
16
|
-
version = "0.
|
16
|
+
version = "0.66.1"
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "
|
18
|
+
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
19
19
|
dependencies = [
|
20
20
|
"bitflags",
|
21
21
|
"cexpr",
|
@@ -28,13 +28,14 @@ dependencies = [
|
|
28
28
|
"regex",
|
29
29
|
"rustc-hash",
|
30
30
|
"shlex",
|
31
|
+
"syn",
|
31
32
|
]
|
32
33
|
|
33
34
|
[[package]]
|
34
35
|
name = "bitflags"
|
35
|
-
version = "
|
36
|
+
version = "2.3.3"
|
36
37
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
37
|
-
checksum = "
|
38
|
+
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
|
38
39
|
|
39
40
|
[[package]]
|
40
41
|
name = "cexpr"
|
@@ -133,40 +134,44 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|
133
134
|
|
134
135
|
[[package]]
|
135
136
|
name = "proc-macro2"
|
136
|
-
version = "1.0.
|
137
|
+
version = "1.0.66"
|
137
138
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
138
|
-
checksum = "
|
139
|
+
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
139
140
|
dependencies = [
|
140
141
|
"unicode-ident",
|
141
142
|
]
|
142
143
|
|
143
144
|
[[package]]
|
144
145
|
name = "quote"
|
145
|
-
version = "1.0.
|
146
|
+
version = "1.0.32"
|
146
147
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
147
|
-
checksum = "
|
148
|
+
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
|
148
149
|
dependencies = [
|
149
150
|
"proc-macro2",
|
150
151
|
]
|
151
152
|
|
152
153
|
[[package]]
|
153
154
|
name = "rb-sys"
|
154
|
-
version = "0.9.
|
155
|
+
version = "0.9.81"
|
155
156
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
156
|
-
checksum = "
|
157
|
+
checksum = "a57240b308b155b09dce81e32829966a99f52d1088b45957e4283e526c5317a1"
|
157
158
|
dependencies = [
|
158
159
|
"rb-sys-build",
|
159
160
|
]
|
160
161
|
|
161
162
|
[[package]]
|
162
163
|
name = "rb-sys-build"
|
163
|
-
version = "0.9.
|
164
|
+
version = "0.9.81"
|
164
165
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
165
|
-
checksum = "
|
166
|
+
checksum = "f24ce877a4c5d07f06f6aa6fec3ac95e4b357b9f73b0f5445d8cbb7266d410e8"
|
166
167
|
dependencies = [
|
167
168
|
"bindgen",
|
169
|
+
"lazy_static",
|
170
|
+
"proc-macro2",
|
171
|
+
"quote",
|
168
172
|
"regex",
|
169
173
|
"shell-words",
|
174
|
+
"syn",
|
170
175
|
]
|
171
176
|
|
172
177
|
[[package]]
|
@@ -204,6 +209,17 @@ version = "1.1.0"
|
|
204
209
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
205
210
|
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
206
211
|
|
212
|
+
[[package]]
|
213
|
+
name = "syn"
|
214
|
+
version = "2.0.28"
|
215
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
216
|
+
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
|
217
|
+
dependencies = [
|
218
|
+
"proc-macro2",
|
219
|
+
"quote",
|
220
|
+
"unicode-ident",
|
221
|
+
]
|
222
|
+
|
207
223
|
[[package]]
|
208
224
|
name = "unicode-ident"
|
209
225
|
version = "1.0.5"
|
@@ -13,9 +13,9 @@ dependencies = [
|
|
13
13
|
|
14
14
|
[[package]]
|
15
15
|
name = "bindgen"
|
16
|
-
version = "0.
|
16
|
+
version = "0.66.1"
|
17
17
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
18
|
-
checksum = "
|
18
|
+
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
19
19
|
dependencies = [
|
20
20
|
"bitflags",
|
21
21
|
"cexpr",
|
@@ -28,13 +28,14 @@ dependencies = [
|
|
28
28
|
"regex",
|
29
29
|
"rustc-hash",
|
30
30
|
"shlex",
|
31
|
+
"syn",
|
31
32
|
]
|
32
33
|
|
33
34
|
[[package]]
|
34
35
|
name = "bitflags"
|
35
|
-
version = "
|
36
|
+
version = "2.3.3"
|
36
37
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
37
|
-
checksum = "
|
38
|
+
checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42"
|
38
39
|
|
39
40
|
[[package]]
|
40
41
|
name = "cexpr"
|
@@ -126,39 +127,40 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
|
126
127
|
|
127
128
|
[[package]]
|
128
129
|
name = "proc-macro2"
|
129
|
-
version = "1.0.
|
130
|
+
version = "1.0.66"
|
130
131
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
131
|
-
checksum = "
|
132
|
+
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
132
133
|
dependencies = [
|
133
134
|
"unicode-ident",
|
134
135
|
]
|
135
136
|
|
136
137
|
[[package]]
|
137
138
|
name = "quote"
|
138
|
-
version = "1.0.
|
139
|
+
version = "1.0.32"
|
139
140
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
140
|
-
checksum = "
|
141
|
+
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965"
|
141
142
|
dependencies = [
|
142
143
|
"proc-macro2",
|
143
144
|
]
|
144
145
|
|
145
146
|
[[package]]
|
146
147
|
name = "rb-sys"
|
147
|
-
version = "0.9.
|
148
|
+
version = "0.9.81"
|
148
149
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
149
|
-
checksum = "
|
150
|
+
checksum = "a57240b308b155b09dce81e32829966a99f52d1088b45957e4283e526c5317a1"
|
150
151
|
dependencies = [
|
151
152
|
"rb-sys-build",
|
152
153
|
]
|
153
154
|
|
154
155
|
[[package]]
|
155
156
|
name = "rb-sys-build"
|
156
|
-
version = "0.9.
|
157
|
+
version = "0.9.81"
|
157
158
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
158
|
-
checksum = "
|
159
|
+
checksum = "f24ce877a4c5d07f06f6aa6fec3ac95e4b357b9f73b0f5445d8cbb7266d410e8"
|
159
160
|
dependencies = [
|
160
161
|
"bindgen",
|
161
162
|
"lazy_static",
|
163
|
+
"proc-macro2",
|
162
164
|
"quote",
|
163
165
|
"regex",
|
164
166
|
"shell-words",
|
@@ -209,9 +211,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
|
209
211
|
|
210
212
|
[[package]]
|
211
213
|
name = "syn"
|
212
|
-
version = "
|
214
|
+
version = "2.0.28"
|
213
215
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
214
|
-
checksum = "
|
216
|
+
checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567"
|
215
217
|
dependencies = [
|
216
218
|
"proc-macro2",
|
217
219
|
"quote",
|
@@ -573,6 +573,32 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|
573
573
|
File.read(extracted)
|
574
574
|
end
|
575
575
|
|
576
|
+
def test_extract_symlink_into_symlink_dir
|
577
|
+
package = Gem::Package.new @gem
|
578
|
+
tgz_io = util_tar_gz do |tar|
|
579
|
+
tar.mkdir "lib", 0o755
|
580
|
+
tar.add_symlink "lib/link", "./inside.rb", 0o644
|
581
|
+
tar.add_file "lib/inside.rb", 0o644 do |io|
|
582
|
+
io.write "hi"
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
destination_subdir = File.join @destination, "subdir"
|
587
|
+
FileUtils.mkdir_p destination_subdir
|
588
|
+
|
589
|
+
destination_linkdir = File.join @destination, "linkdir"
|
590
|
+
File.symlink(destination_subdir, destination_linkdir)
|
591
|
+
|
592
|
+
package.extract_tar_gz tgz_io, destination_linkdir
|
593
|
+
|
594
|
+
extracted = File.join destination_subdir, "lib/link"
|
595
|
+
assert_path_exist extracted
|
596
|
+
assert_equal "./inside.rb",
|
597
|
+
File.readlink(extracted)
|
598
|
+
assert_equal "hi",
|
599
|
+
File.read(extracted)
|
600
|
+
end
|
601
|
+
|
576
602
|
def test_extract_tar_gz_symlink_broken_relative_path
|
577
603
|
package = Gem::Package.new @gem
|
578
604
|
package.verify
|
@@ -642,8 +668,8 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|
642
668
|
pend "TMPDIR seems too long to add it as symlink into tar" if destination_user_dir.size > 90
|
643
669
|
|
644
670
|
tgz_io = util_tar_gz do |tar|
|
645
|
-
tar.add_symlink "link", destination_user_dir,
|
646
|
-
tar.add_symlink "link/dir", ".",
|
671
|
+
tar.add_symlink "link", destination_user_dir, 16_877
|
672
|
+
tar.add_symlink "link/dir", ".", 16_877
|
647
673
|
end
|
648
674
|
|
649
675
|
expected_exceptions = win_platform? ? [Gem::Package::SymlinkError, Errno::EACCES] : [Gem::Package::SymlinkError]
|
@@ -943,6 +969,95 @@ class TestGemPackage < Gem::Package::TarTestCase
|
|
943
969
|
tf.close!
|
944
970
|
end
|
945
971
|
|
972
|
+
def test_verify_corrupt_tar_metadata_entry
|
973
|
+
gem = tar_file_header("metadata.gz", "", 0, 999, Time.now)
|
974
|
+
|
975
|
+
File.open "corrupt.gem", "wb" do |io|
|
976
|
+
io.write gem
|
977
|
+
end
|
978
|
+
|
979
|
+
package = Gem::Package.new "corrupt.gem"
|
980
|
+
|
981
|
+
e = nil
|
982
|
+
out_err = capture_output do
|
983
|
+
e = assert_raise Gem::Package::FormatError do
|
984
|
+
package.verify
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
|
989
|
+
assert_equal(["", "Exception while verifying corrupt.gem\n"], out_err)
|
990
|
+
end
|
991
|
+
|
992
|
+
def test_verify_corrupt_tar_checksums_entry
|
993
|
+
gem = tar_file_header("checksums.yaml.gz", "", 0, 100, Time.now)
|
994
|
+
|
995
|
+
File.open "corrupt.gem", "wb" do |io|
|
996
|
+
io.write gem
|
997
|
+
end
|
998
|
+
|
999
|
+
package = Gem::Package.new "corrupt.gem"
|
1000
|
+
|
1001
|
+
e = assert_raise Gem::Package::FormatError do
|
1002
|
+
package.verify
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
assert_equal "not in gzip format in corrupt.gem", e.message
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
def test_verify_corrupt_tar_data_entry
|
1009
|
+
gem = tar_file_header("data.tar.gz", "", 0, 100, Time.now)
|
1010
|
+
|
1011
|
+
File.open "corrupt.gem", "wb" do |io|
|
1012
|
+
io.write gem
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
package = Gem::Package.new "corrupt.gem"
|
1016
|
+
|
1017
|
+
e = nil
|
1018
|
+
out_err = capture_output do
|
1019
|
+
e = assert_raise Gem::Package::FormatError do
|
1020
|
+
package.verify
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
|
1025
|
+
assert_equal(["", "Exception while verifying corrupt.gem\n"], out_err)
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
def test_corrupt_data_tar_gz
|
1029
|
+
data_tgz = util_gzip tar_file_header("lib/code.rb", "", 0, 100, Time.now)
|
1030
|
+
metadata_gz = util_gzip @spec.to_yaml
|
1031
|
+
|
1032
|
+
gem = util_tar do |tar|
|
1033
|
+
tar.add_file "data.tar.gz", 0o444 do |io|
|
1034
|
+
io.write data_tgz
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
tar.add_file "metadata.gz", 0o644 do |io|
|
1038
|
+
io.write metadata_gz
|
1039
|
+
end
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
File.open "corrupt.gem", "wb" do |io|
|
1043
|
+
io.write gem.string
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
package = Gem::Package.new "corrupt.gem"
|
1047
|
+
|
1048
|
+
e = assert_raise Gem::Package::FormatError do
|
1049
|
+
package.contents
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
|
1053
|
+
|
1054
|
+
e = assert_raise Gem::Package::FormatError do
|
1055
|
+
package.extract_files @destination
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
assert_match(/(EOFError|end of file reached) in corrupt.gem/i, e.message)
|
1059
|
+
end
|
1060
|
+
|
946
1061
|
def test_verify_empty
|
947
1062
|
FileUtils.touch "empty.gem"
|
948
1063
|
|
@@ -11,9 +11,9 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
|
|
11
11
|
:name => "x",
|
12
12
|
:mode => 0644,
|
13
13
|
:uid => 1000,
|
14
|
-
:gid =>
|
14
|
+
:gid => 10_000,
|
15
15
|
:size => 100,
|
16
|
-
:mtime =>
|
16
|
+
:mtime => 12_345,
|
17
17
|
:typeflag => "0",
|
18
18
|
:linkname => "link",
|
19
19
|
:uname => "user",
|
@@ -40,12 +40,12 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
|
|
40
40
|
assert_equal "", @tar_header.checksum, "checksum"
|
41
41
|
assert_equal 1, @tar_header.devmajor, "devmajor"
|
42
42
|
assert_equal 2, @tar_header.devminor, "devminor"
|
43
|
-
assert_equal
|
43
|
+
assert_equal 10_000, @tar_header.gid, "gid"
|
44
44
|
assert_equal "group", @tar_header.gname, "gname"
|
45
45
|
assert_equal "link", @tar_header.linkname, "linkname"
|
46
46
|
assert_equal "ustar", @tar_header.magic, "magic"
|
47
47
|
assert_equal 0644, @tar_header.mode, "mode"
|
48
|
-
assert_equal
|
48
|
+
assert_equal 12_345, @tar_header.mtime, "mtime"
|
49
49
|
assert_equal "x", @tar_header.name, "name"
|
50
50
|
assert_equal "y", @tar_header.prefix, "prefix"
|
51
51
|
assert_equal 100, @tar_header.size, "size"
|
@@ -195,13 +195,13 @@ tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
|
195
195
|
|
196
196
|
tar_header = Gem::Package::TarHeader.from stream
|
197
197
|
|
198
|
-
assert_equal
|
199
|
-
assert_equal
|
198
|
+
assert_equal 1_991_400_094, tar_header.uid
|
199
|
+
assert_equal 1_991_400_094, tar_header.gid
|
200
200
|
|
201
201
|
assert_equal "GeoIP2-City_20190528/", tar_header.name
|
202
202
|
assert_equal 0755, tar_header.mode
|
203
203
|
assert_equal 0, tar_header.size
|
204
|
-
assert_equal
|
204
|
+
assert_equal 1_559_064_640, tar_header.mtime
|
205
205
|
assert_equal 6932, tar_header.checksum
|
206
206
|
end
|
207
207
|
|
@@ -177,10 +177,15 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
|
|
177
177
|
assert_equal @contents[100..-1], @entry.read
|
178
178
|
end
|
179
179
|
|
180
|
-
def
|
180
|
+
def test_readpartial
|
181
181
|
assert_equal @contents[0...100], @entry.readpartial(100)
|
182
182
|
end
|
183
183
|
|
184
|
+
def test_readpartial_to_eof
|
185
|
+
assert_equal @contents, @entry.readpartial(4096)
|
186
|
+
assert @entry.eof?
|
187
|
+
end
|
188
|
+
|
184
189
|
def test_read_partial_buffer
|
185
190
|
buffer = "".b
|
186
191
|
@entry.readpartial(100, buffer)
|
@@ -189,11 +194,42 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
|
|
189
194
|
|
190
195
|
def test_readpartial_past_eof
|
191
196
|
@entry.readpartial(@contents.size)
|
197
|
+
assert @entry.eof?
|
192
198
|
assert_raise(EOFError) do
|
193
199
|
@entry.readpartial(1)
|
194
200
|
end
|
195
201
|
end
|
196
202
|
|
203
|
+
def test_read_corrupted_tar
|
204
|
+
corrupt_tar = String.new
|
205
|
+
corrupt_tar << tar_file_header("lib/foo", "", 0, 100, Time.now)
|
206
|
+
corrupt_tar << tar_file_contents("")
|
207
|
+
corrupt_entry = util_entry corrupt_tar
|
208
|
+
|
209
|
+
assert_equal "", corrupt_entry.read(0)
|
210
|
+
assert_equal "", corrupt_entry.read, "IO.read without len should return empty string (even though it's at an unpexpected EOF)"
|
211
|
+
|
212
|
+
corrupt_entry.rewind
|
213
|
+
|
214
|
+
assert_nil corrupt_entry.read(100), "IO.read with len should return nil as per IO.read docs"
|
215
|
+
ensure
|
216
|
+
close_util_entry(corrupt_entry) if corrupt_entry
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_readpartial_corrupted_tar
|
220
|
+
corrupt_tar = String.new
|
221
|
+
corrupt_tar << tar_file_header("lib/foo", "", 0, 100, Time.now)
|
222
|
+
corrupt_tar << tar_file_contents("")
|
223
|
+
|
224
|
+
corrupt_entry = util_entry corrupt_tar
|
225
|
+
|
226
|
+
assert_raise EOFError do
|
227
|
+
corrupt_entry.readpartial(100)
|
228
|
+
end
|
229
|
+
ensure
|
230
|
+
close_util_entry(corrupt_entry) if corrupt_entry
|
231
|
+
end
|
232
|
+
|
197
233
|
def test_rewind
|
198
234
|
char = @entry.getc
|
199
235
|
|
@@ -295,4 +331,20 @@ class TestGemPackageTarReaderEntry < Gem::Package::TarTestCase
|
|
295
331
|
assert_equal contents2.size, entry.pos
|
296
332
|
end
|
297
333
|
end
|
334
|
+
|
335
|
+
def test_seek_in_gzip_io_corrupted
|
336
|
+
@tar << tar_file_header("lib/bar", "", 0, 100, Time.now)
|
337
|
+
@tar << tar_file_contents("")
|
338
|
+
|
339
|
+
tgz = util_gzip(@tar)
|
340
|
+
|
341
|
+
Zlib::GzipReader.wrap StringIO.new(tgz) do |gzio|
|
342
|
+
util_entry(gzio).close # skip the first entry so io.pos is not 0
|
343
|
+
entry = util_entry(gzio)
|
344
|
+
|
345
|
+
assert_raise EOFError do
|
346
|
+
entry.seek(50)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
298
350
|
end
|