rubygems-update 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +53 -0
- data/Manifest.txt +3 -1
- data/Rakefile +7 -5
- data/bundler/lib/bundler/build_metadata.rb +1 -1
- data/lib/rubygems.rb +6 -12
- data/lib/rubygems/commands/environment_command.rb +0 -3
- data/lib/rubygems/commands/push_command.rb +2 -0
- data/lib/rubygems/commands/uninstall_command.rb +16 -6
- data/lib/rubygems/commands/which_command.rb +1 -3
- data/lib/rubygems/defaults.rb +1 -8
- data/lib/rubygems/dependency_installer.rb +1 -2
- data/lib/rubygems/exceptions.rb +0 -4
- data/lib/rubygems/gemcutter_utilities.rb +9 -5
- data/lib/rubygems/installer.rb +1 -1
- data/lib/rubygems/installer_test_case.rb +2 -2
- data/lib/rubygems/package/tar_header.rb +11 -2
- data/lib/rubygems/remote_fetcher.rb +15 -54
- data/lib/rubygems/request.rb +1 -1
- data/lib/rubygems/request_set/gem_dependency_api.rb +3 -5
- data/lib/rubygems/s3_uri_signer.rb +175 -0
- data/lib/rubygems/security_option.rb +0 -1
- data/lib/rubygems/specification.rb +0 -1
- data/lib/rubygems/stub_specification.rb +1 -2
- data/lib/rubygems/test_case.rb +8 -4
- data/lib/rubygems/util.rb +12 -0
- data/rubygems-update.gemspec +1 -1
- data/test/rubygems/test_gem.rb +6 -3
- data/test/rubygems/test_gem_commands_environment_command.rb +0 -11
- data/test/rubygems/test_gem_commands_push_command.rb +15 -0
- data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -1
- data/test/rubygems/test_gem_indexer.rb +8 -8
- data/test/rubygems/test_gem_installer.rb +48 -17
- data/test/rubygems/test_gem_package_tar_header.rb +41 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +133 -14
- data/test/rubygems/test_gem_request.rb +4 -4
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +20 -30
- data/test/rubygems/test_gem_util.rb +8 -0
- data/util/cops/deprecations.rb +52 -0
- data/util/create_certs.sh +27 -0
- metadata +5 -3
- data/lib/rubygems/compatibility.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5841a757f2af5f047fd0da572963997ffd46bfc18fc22d6d1356ce29ab7fcfd9
|
4
|
+
data.tar.gz: 6b933f8b2706cf2ad447769a932971c6d32d56fc76ad3a840879e240f10fb6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3aa3c4d54466215f5e335789651920860379d22ec38a254a5dffc520b71b659708fda86c8a635c93f83b722fa2baaf9909224bbe18c066a57ae5e4f753d2455
|
7
|
+
data.tar.gz: 2999d7ec4984243c1112017c05533c5881a58c4224078397e40c8da08af3bf6ede8ac45686602c937645969c30b865a9be3f6b7608c6b7a34c3c2aa935458268
|
data/History.txt
CHANGED
@@ -1,5 +1,58 @@
|
|
1
1
|
# coding: UTF-8
|
2
2
|
|
3
|
+
=== 3.0.5 / 2019-08-16
|
4
|
+
|
5
|
+
Minor enhancements:
|
6
|
+
|
7
|
+
* Use env var to configure api key on push. Pull request #2559 by Luis
|
8
|
+
Sagastume.
|
9
|
+
* Unswallow uninstall error. Pull request #2707 by David Rodríguez.
|
10
|
+
* Expose windows path normalization utility. Pull request #2767 by David
|
11
|
+
Rodríguez.
|
12
|
+
* Clean which command. Pull request #2801 by Luis Sagastume.
|
13
|
+
* Upgrading S3 source signature to AWS SigV4. Pull request #2807 by
|
14
|
+
Alexander Pakulov.
|
15
|
+
* Remove missleading comment, no reason to move Gem.host to Gem::Util.
|
16
|
+
Pull request #2811 by Luis Sagastume.
|
17
|
+
* Drop support for 'gem env packageversion'. Pull request #2813 by Luis
|
18
|
+
Sagastume.
|
19
|
+
* Take into account just git tracked files in update_manifest rake task.
|
20
|
+
Pull request #2816 by Luis Sagastume.
|
21
|
+
* Remove TODO comment, there's no Gem::Dirs constant. Pull request #2819
|
22
|
+
by Luis Sagastume.
|
23
|
+
* Remove unused 'raise' from test_case. Pull request #2820 by Luis
|
24
|
+
Sagastume.
|
25
|
+
* Move TODO comment to an information comment. Pull request #2821 by Luis
|
26
|
+
Sagastume.
|
27
|
+
* Use File#open instead of Kernel#open in stub_specification.rb. Pull
|
28
|
+
request #2834 by Luis Sagastume.
|
29
|
+
* Make error code a gemcutter_utilities a constant. Pull request #2844 by
|
30
|
+
Luis Sagastume.
|
31
|
+
* Remove FIXME comment related to PathSupport. Pull request #2854 by Luis
|
32
|
+
Sagastume.
|
33
|
+
* Use gsub with Hash. Pull request #2860 by Kazuhiro NISHIYAMA.
|
34
|
+
* Use the standard RUBY_ENGINE_VERSION instead of JRUBY_VERSION. Pull
|
35
|
+
request #2864 by Benoit Daloze.
|
36
|
+
* Do not mutate uri.query during s3 signature creation. Pull request #2874
|
37
|
+
by Alexander Pakulov.
|
38
|
+
* Fixup #2844. Pull request #2878 by SHIBATA Hiroshi.
|
39
|
+
|
40
|
+
Bug fixes:
|
41
|
+
|
42
|
+
* Fix intermittent test error on Appveyor & Travis. Pull request #2568 by
|
43
|
+
MSP-Greg.
|
44
|
+
* Extend timeout on assert_self_install_permissions. Pull request #2605 by
|
45
|
+
SHIBATA Hiroshi.
|
46
|
+
* Better folder assertions. Pull request #2644 by David Rodríguez.
|
47
|
+
* Fix default gem executable installation when folder is not `bin/`. Pull
|
48
|
+
request #2649 by David Rodríguez.
|
49
|
+
* Fix gem uninstall behavior. Pull request #2663 by Luis Sagastume.
|
50
|
+
* Fix for large values in UID/GID fields in tar archives. Pull request
|
51
|
+
#2780 by Alexey Shein.
|
52
|
+
* Fixed task order for release. Pull request #2792 by SHIBATA Hiroshi.
|
53
|
+
* Ignore GEMRC variable for test suite. Pull request #2837 by SHIBATA
|
54
|
+
Hiroshi.
|
55
|
+
|
3
56
|
=== 3.0.4 / 2019-06-14
|
4
57
|
|
5
58
|
Minor enhancements:
|
data/Manifest.txt
CHANGED
@@ -307,7 +307,6 @@ lib/rubygems/commands/unpack_command.rb
|
|
307
307
|
lib/rubygems/commands/update_command.rb
|
308
308
|
lib/rubygems/commands/which_command.rb
|
309
309
|
lib/rubygems/commands/yank_command.rb
|
310
|
-
lib/rubygems/compatibility.rb
|
311
310
|
lib/rubygems/config_file.rb
|
312
311
|
lib/rubygems/core_ext/kernel_gem.rb
|
313
312
|
lib/rubygems/core_ext/kernel_require.rb
|
@@ -413,6 +412,7 @@ lib/rubygems/resolver/specification.rb
|
|
413
412
|
lib/rubygems/resolver/stats.rb
|
414
413
|
lib/rubygems/resolver/vendor_set.rb
|
415
414
|
lib/rubygems/resolver/vendor_specification.rb
|
415
|
+
lib/rubygems/s3_uri_signer.rb
|
416
416
|
lib/rubygems/safe_yaml.rb
|
417
417
|
lib/rubygems/security.rb
|
418
418
|
lib/rubygems/security/policies.rb
|
@@ -639,7 +639,9 @@ test/rubygems/wrong_key_cert.pem
|
|
639
639
|
test/rubygems/wrong_key_cert_32.pem
|
640
640
|
util/CL2notes
|
641
641
|
util/ci
|
642
|
+
util/cops/deprecations.rb
|
642
643
|
util/create_certs.rb
|
644
|
+
util/create_certs.sh
|
643
645
|
util/create_encrypted_key.rb
|
644
646
|
util/generate_spdx_license_list.rb
|
645
647
|
util/patch_with_prs.rb
|
data/Rakefile
CHANGED
@@ -79,7 +79,7 @@ end
|
|
79
79
|
# --------------------------------------------------------------------
|
80
80
|
# Creating a release
|
81
81
|
|
82
|
-
task :prerelease => %w[clobber test bundler:build_metadata check_deprecations
|
82
|
+
task :prerelease => %w[clobber test bundler:build_metadata check_deprecations]
|
83
83
|
task :postrelease => %w[bundler:build_metadata:clean upload guides:publish blog:publish]
|
84
84
|
|
85
85
|
desc "Check for deprecated methods with expired deprecation horizon"
|
@@ -93,9 +93,10 @@ end
|
|
93
93
|
|
94
94
|
desc "Release rubygems-#{v}"
|
95
95
|
task :release => :prerelease do
|
96
|
+
Rake::Task["package"].invoke
|
96
97
|
sh "gem push pkg/rubygems-update-#{v}.gem"
|
98
|
+
Rake::Task["postrelease"].invoke
|
97
99
|
end
|
98
|
-
Rake::Task["release"].enhance(["postrelease"])
|
99
100
|
|
100
101
|
Gem::PackageTask.new(spec) {}
|
101
102
|
|
@@ -362,9 +363,10 @@ end
|
|
362
363
|
desc "Update the manifest to reflect what's on disk"
|
363
364
|
task :update_manifest do
|
364
365
|
files = []
|
365
|
-
|
366
|
-
|
367
|
-
|
366
|
+
exclude = %r[\.git|\./bundler/(?!lib|man|exe|[^/]+\.md|bundler.gemspec)]ox
|
367
|
+
tracked_files = `git ls-files --recurse-submodules`.split("\n").map {|f| "./#{f}" }
|
368
|
+
|
369
|
+
tracked_files.each do |path|
|
368
370
|
next unless File.file?(path)
|
369
371
|
next if path =~ exclude
|
370
372
|
files << path[2..-1]
|
data/lib/rubygems.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
require 'rbconfig'
|
10
10
|
|
11
11
|
module Gem
|
12
|
-
VERSION = "3.0.
|
12
|
+
VERSION = "3.0.5".freeze
|
13
13
|
end
|
14
14
|
|
15
15
|
# Must be first since it unloads the prelude from 1.9.2
|
@@ -568,8 +568,6 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
568
568
|
#++
|
569
569
|
#--
|
570
570
|
#
|
571
|
-
# FIXME move to pathsupport
|
572
|
-
#
|
573
571
|
#++
|
574
572
|
|
575
573
|
def self.find_home
|
@@ -642,14 +640,12 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
|
|
642
640
|
# <tt>https://rubygems.org</tt>.
|
643
641
|
|
644
642
|
def self.host
|
645
|
-
# TODO: move to utils
|
646
643
|
@host ||= Gem::DEFAULT_HOST
|
647
644
|
end
|
648
645
|
|
649
646
|
## Set the default RubyGems API host.
|
650
647
|
|
651
648
|
def self.host=(host)
|
652
|
-
# TODO: move to utils
|
653
649
|
@host = host
|
654
650
|
end
|
655
651
|
|
@@ -1377,14 +1373,12 @@ begin
|
|
1377
1373
|
rescue LoadError
|
1378
1374
|
end
|
1379
1375
|
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
# Defaults the Ruby implementation wants to provide for RubyGems
|
1376
|
+
begin
|
1377
|
+
##
|
1378
|
+
# Defaults the Ruby implementation wants to provide for RubyGems
|
1384
1379
|
|
1385
|
-
|
1386
|
-
|
1387
|
-
end
|
1380
|
+
require "rubygems/defaults/#{RUBY_ENGINE}"
|
1381
|
+
rescue LoadError
|
1388
1382
|
end
|
1389
1383
|
|
1390
1384
|
##
|
@@ -9,7 +9,6 @@ class Gem::Commands::EnvironmentCommand < Gem::Command
|
|
9
9
|
|
10
10
|
def arguments # :nodoc:
|
11
11
|
args = <<-EOF
|
12
|
-
packageversion display the package version
|
13
12
|
gemdir display the path where gems are installed
|
14
13
|
gempath display path used to search for gems
|
15
14
|
version display the gem format version
|
@@ -76,8 +75,6 @@ lib/rubygems/defaults/operating_system.rb
|
|
76
75
|
arg = options[:args][0]
|
77
76
|
out <<
|
78
77
|
case arg
|
79
|
-
when /^packageversion/ then
|
80
|
-
Gem::RubyGemsPackageVersion
|
81
78
|
when /^version/ then
|
82
79
|
Gem::VERSION
|
83
80
|
when /^gemdir/, /^gemhome/, /^home/, /^GEM_HOME/ then
|
@@ -15,6 +15,8 @@ https://rubygems.org) and adds it to the index.
|
|
15
15
|
|
16
16
|
The gem can be removed from the index and deleted from the server using the yank
|
17
17
|
command. For further discussion see the help for the yank command.
|
18
|
+
|
19
|
+
The push command will use ~/.gem/credentials to authenticate to a server, but you can use the RubyGems environment variable GEM_HOST_API_KEY to set the api key to authenticate.
|
18
20
|
EOF
|
19
21
|
end
|
20
22
|
|
@@ -148,10 +148,13 @@ that is a dependency of an existing gem. You can use the
|
|
148
148
|
|
149
149
|
def uninstall_specific
|
150
150
|
deplist = Gem::DependencyList.new
|
151
|
+
original_gem_version = {}
|
151
152
|
|
152
153
|
get_all_gem_names_and_versions.each do |name, version|
|
153
|
-
|
154
|
-
|
154
|
+
original_gem_version[name] = version || options[:version]
|
155
|
+
|
156
|
+
gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
|
157
|
+
|
155
158
|
say("Gem '#{name}' is not installed") if gem_specs.empty?
|
156
159
|
gem_specs.each do |spec|
|
157
160
|
deplist.add spec
|
@@ -160,16 +163,23 @@ that is a dependency of an existing gem. You can use the
|
|
160
163
|
|
161
164
|
deps = deplist.strongly_connected_components.flatten.reverse
|
162
165
|
|
166
|
+
gems_to_uninstall = {}
|
167
|
+
|
163
168
|
deps.each do |dep|
|
164
|
-
|
165
|
-
|
169
|
+
unless gems_to_uninstall[dep.name]
|
170
|
+
gems_to_uninstall[dep.name] = true
|
171
|
+
|
172
|
+
unless original_gem_version[dep.name] == Gem::Requirement.default
|
173
|
+
options[:version] = dep.version
|
174
|
+
end
|
175
|
+
|
176
|
+
uninstall_gem(dep.name)
|
177
|
+
end
|
166
178
|
end
|
167
179
|
end
|
168
180
|
|
169
181
|
def uninstall_gem(gem_name)
|
170
182
|
uninstall(gem_name)
|
171
|
-
rescue Gem::InstallError
|
172
|
-
nil
|
173
183
|
rescue Gem::GemNotInHomeException => e
|
174
184
|
spec = e.spec
|
175
185
|
alert("In order to remove #{spec.name}, please execute:\n" +
|
@@ -52,13 +52,11 @@ requiring to see why it does not behave as you expect.
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
# TODO: this is totally redundant and stupid
|
56
55
|
paths = find_paths arg, dirs
|
57
56
|
|
58
57
|
if paths.empty?
|
59
58
|
alert_error "Can't find Ruby library file or shared library #{arg}"
|
60
|
-
|
61
|
-
found &&= false
|
59
|
+
found = false
|
62
60
|
else
|
63
61
|
say paths
|
64
62
|
end
|
data/lib/rubygems/defaults.rb
CHANGED
@@ -122,15 +122,8 @@ module Gem
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
##
|
126
|
-
# A wrapper around RUBY_ENGINE const that may not be defined
|
127
|
-
|
128
125
|
def self.ruby_engine
|
129
|
-
|
130
|
-
RUBY_ENGINE
|
131
|
-
else
|
132
|
-
'ruby'
|
133
|
-
end
|
126
|
+
RUBY_ENGINE
|
134
127
|
end
|
135
128
|
|
136
129
|
##
|
@@ -213,9 +213,8 @@ class Gem::DependencyInstaller
|
|
213
213
|
|
214
214
|
if consider_remote?
|
215
215
|
begin
|
216
|
-
#
|
216
|
+
# This is pulled from #spec_for_dependency to allow
|
217
217
|
# us to filter tuples before fetching specs.
|
218
|
-
#
|
219
218
|
tuples, errors = Gem::SpecFetcher.fetcher.search_for_dependency dep
|
220
219
|
|
221
220
|
if best_only && !tuples.empty?
|
data/lib/rubygems/exceptions.rb
CHANGED
@@ -7,6 +7,8 @@ require 'rubygems/text'
|
|
7
7
|
|
8
8
|
module Gem::GemcutterUtilities
|
9
9
|
|
10
|
+
ERROR_CODE = 1
|
11
|
+
|
10
12
|
include Gem::Text
|
11
13
|
|
12
14
|
# TODO: move to Gem::Command
|
@@ -41,7 +43,9 @@ module Gem::GemcutterUtilities
|
|
41
43
|
# The API key from the command options or from the user's configuration.
|
42
44
|
|
43
45
|
def api_key
|
44
|
-
if
|
46
|
+
if ENV["GEM_HOST_API_KEY"]
|
47
|
+
ENV["GEM_HOST_API_KEY"]
|
48
|
+
elsif options[:key]
|
45
49
|
verify_api_key options[:key]
|
46
50
|
elsif Gem.configuration.api_keys.key?(host)
|
47
51
|
Gem.configuration.api_keys[host]
|
@@ -79,7 +83,7 @@ module Gem::GemcutterUtilities
|
|
79
83
|
self.host = host if host
|
80
84
|
unless self.host
|
81
85
|
alert_error "You must specify a gem server"
|
82
|
-
terminate_interaction
|
86
|
+
terminate_interaction(ERROR_CODE)
|
83
87
|
end
|
84
88
|
|
85
89
|
if allowed_push_host
|
@@ -88,7 +92,7 @@ module Gem::GemcutterUtilities
|
|
88
92
|
|
89
93
|
unless (host_uri.scheme == allowed_host_uri.scheme) && (host_uri.host == allowed_host_uri.host)
|
90
94
|
alert_error "#{self.host.inspect} is not allowed by the gemspec, which only allows #{allowed_push_host.inspect}"
|
91
|
-
terminate_interaction
|
95
|
+
terminate_interaction(ERROR_CODE)
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
@@ -148,7 +152,7 @@ module Gem::GemcutterUtilities
|
|
148
152
|
Gem.configuration.api_keys[key]
|
149
153
|
else
|
150
154
|
alert_error "No such API key. Please add it to your configuration (done automatically on initial `gem push`)."
|
151
|
-
terminate_interaction
|
155
|
+
terminate_interaction(ERROR_CODE)
|
152
156
|
end
|
153
157
|
end
|
154
158
|
|
@@ -172,7 +176,7 @@ module Gem::GemcutterUtilities
|
|
172
176
|
message = "#{error_prefix}: #{message}" if error_prefix
|
173
177
|
|
174
178
|
say clean_text(message)
|
175
|
-
terminate_interaction
|
179
|
+
terminate_interaction(ERROR_CODE)
|
176
180
|
end
|
177
181
|
end
|
178
182
|
|
data/lib/rubygems/installer.rb
CHANGED
@@ -119,9 +119,9 @@ class Gem::InstallerTestCase < Gem::TestCase
|
|
119
119
|
# The executable is also written to the bin dir in @tmpdir and the installed
|
120
120
|
# gem directory for +spec+.
|
121
121
|
|
122
|
-
def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby")
|
122
|
+
def util_make_exec(spec = @spec, shebang = "#!/usr/bin/ruby", bindir = "bin")
|
123
123
|
spec.executables = %w[executable]
|
124
|
-
spec.
|
124
|
+
spec.bindir = bindir
|
125
125
|
|
126
126
|
exec_path = spec.bin_file "executable"
|
127
127
|
write_file exec_path do |io|
|
@@ -107,8 +107,8 @@ class Gem::Package::TarHeader
|
|
107
107
|
|
108
108
|
new :name => fields.shift,
|
109
109
|
:mode => strict_oct(fields.shift),
|
110
|
-
:uid =>
|
111
|
-
:gid =>
|
110
|
+
:uid => oct_or_256based(fields.shift),
|
111
|
+
:gid => oct_or_256based(fields.shift),
|
112
112
|
:size => strict_oct(fields.shift),
|
113
113
|
:mtime => strict_oct(fields.shift),
|
114
114
|
:checksum => strict_oct(fields.shift),
|
@@ -130,6 +130,15 @@ class Gem::Package::TarHeader
|
|
130
130
|
raise ArgumentError, "#{str.inspect} is not an octal string"
|
131
131
|
end
|
132
132
|
|
133
|
+
def self.oct_or_256based(str)
|
134
|
+
# \x80 flags a positive 256-based number
|
135
|
+
# \ff flags a negative 256-based number
|
136
|
+
# In case we have a match, parse it as a signed binary value
|
137
|
+
# in big-endian order, except that the high-order bit is ignored.
|
138
|
+
return str.unpack('N2').last if str =~ /\A[\x80\xff]/n
|
139
|
+
strict_oct(str)
|
140
|
+
end
|
141
|
+
|
133
142
|
##
|
134
143
|
# Creates a new TarHeader using +vals+
|
135
144
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rubygems/request'
|
4
|
+
require 'rubygems/request/connection_pools'
|
5
|
+
require 'rubygems/s3_uri_signer'
|
4
6
|
require 'rubygems/uri_formatter'
|
5
7
|
require 'rubygems/user_interaction'
|
6
|
-
require 'rubygems/request/connection_pools'
|
7
8
|
require 'resolv'
|
8
9
|
|
9
10
|
##
|
@@ -173,7 +174,7 @@ class Gem::RemoteFetcher
|
|
173
174
|
path = source_uri.path
|
174
175
|
path = File.dirname(path) if File.extname(path) == '.gem'
|
175
176
|
|
176
|
-
remote_gem_path = correct_for_windows_path(File.join(path, 'gems', gem_file_name))
|
177
|
+
remote_gem_path = Gem::Util.correct_for_windows_path(File.join(path, 'gems', gem_file_name))
|
177
178
|
|
178
179
|
FileUtils.cp(remote_gem_path, local_gem_path)
|
179
180
|
rescue Errno::EACCES
|
@@ -210,7 +211,7 @@ class Gem::RemoteFetcher
|
|
210
211
|
# File Fetcher. Dispatched by +fetch_path+. Use it instead.
|
211
212
|
|
212
213
|
def fetch_file(uri, *_)
|
213
|
-
Gem.read_binary correct_for_windows_path uri.path
|
214
|
+
Gem.read_binary Gem::Util.correct_for_windows_path uri.path
|
214
215
|
end
|
215
216
|
|
216
217
|
##
|
@@ -275,7 +276,7 @@ class Gem::RemoteFetcher
|
|
275
276
|
rescue Timeout::Error
|
276
277
|
raise UnknownHostError.new('timed out', uri.to_s)
|
277
278
|
rescue IOError, SocketError, SystemCallError,
|
278
|
-
|
279
|
+
*(OpenSSL::SSL::SSLError if defined?(OpenSSL)) => e
|
279
280
|
if e.message =~ /getaddrinfo/
|
280
281
|
raise UnknownHostError.new('no such name', uri.to_s)
|
281
282
|
else
|
@@ -284,10 +285,19 @@ class Gem::RemoteFetcher
|
|
284
285
|
end
|
285
286
|
|
286
287
|
def fetch_s3(uri, mtime = nil, head = false)
|
287
|
-
|
288
|
+
begin
|
289
|
+
public_uri = s3_uri_signer(uri).sign
|
290
|
+
rescue Gem::S3URISigner::ConfigurationError, Gem::S3URISigner::InstanceProfileError => e
|
291
|
+
raise FetchError.new(e.message, "s3://#{uri.host}")
|
292
|
+
end
|
288
293
|
fetch_https public_uri, mtime, head
|
289
294
|
end
|
290
295
|
|
296
|
+
# we have our own signing code here to avoid a dependency on the aws-sdk gem
|
297
|
+
def s3_uri_signer(uri)
|
298
|
+
Gem::S3URISigner.new(uri)
|
299
|
+
end
|
300
|
+
|
291
301
|
##
|
292
302
|
# Downloads +uri+ to +path+ if necessary. If no path is given, it just
|
293
303
|
# passes the data.
|
@@ -317,14 +327,6 @@ class Gem::RemoteFetcher
|
|
317
327
|
response['content-length'].to_i
|
318
328
|
end
|
319
329
|
|
320
|
-
def correct_for_windows_path(path)
|
321
|
-
if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':'
|
322
|
-
path[1..-1]
|
323
|
-
else
|
324
|
-
path
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
330
|
##
|
329
331
|
# Performs a Net::HTTP request of type +request_class+ on +uri+ returning
|
330
332
|
# a Net::HTTP response object. request maintains a table of persistent
|
@@ -349,31 +351,6 @@ class Gem::RemoteFetcher
|
|
349
351
|
@pools.each_value {|pool| pool.close_all}
|
350
352
|
end
|
351
353
|
|
352
|
-
protected
|
353
|
-
|
354
|
-
# we have our own signing code here to avoid a dependency on the aws-sdk gem
|
355
|
-
# fortunately, a simple GET request isn't too complex to sign properly
|
356
|
-
def sign_s3_url(uri, expiration = nil)
|
357
|
-
require 'base64'
|
358
|
-
require 'openssl'
|
359
|
-
|
360
|
-
id, secret = s3_source_auth uri
|
361
|
-
|
362
|
-
expiration ||= s3_expiration
|
363
|
-
canonical_path = "/#{uri.host}#{uri.path}"
|
364
|
-
payload = "GET\n\n\n#{expiration}\n#{canonical_path}"
|
365
|
-
digest = OpenSSL::HMAC.digest('sha1', secret, payload)
|
366
|
-
# URI.escape is deprecated, and there isn't yet a replacement that does quite what we want
|
367
|
-
signature = Base64.encode64(digest).gsub("\n", '').gsub(/[\+\/=]/) { |c| BASE64_URI_TRANSLATE[c] }
|
368
|
-
URI.parse("https://#{uri.host}.s3.amazonaws.com#{uri.path}?AWSAccessKeyId=#{id}&Expires=#{expiration}&Signature=#{signature}")
|
369
|
-
end
|
370
|
-
|
371
|
-
def s3_expiration
|
372
|
-
(Time.now + 3600).to_i # one hour from now
|
373
|
-
end
|
374
|
-
|
375
|
-
BASE64_URI_TRANSLATE = { '+' => '%2B', '/' => '%2F', '=' => '%3D' }.freeze
|
376
|
-
|
377
354
|
private
|
378
355
|
|
379
356
|
def proxy_for(proxy, uri)
|
@@ -386,20 +363,4 @@ class Gem::RemoteFetcher
|
|
386
363
|
end
|
387
364
|
end
|
388
365
|
|
389
|
-
def s3_source_auth(uri)
|
390
|
-
return [uri.user, uri.password] if uri.user && uri.password
|
391
|
-
|
392
|
-
s3_source = Gem.configuration[:s3_source] || Gem.configuration['s3_source']
|
393
|
-
host = uri.host
|
394
|
-
raise FetchError.new("no s3_source key exists in .gemrc", "s3://#{host}") unless s3_source
|
395
|
-
|
396
|
-
auth = s3_source[host] || s3_source[host.to_sym]
|
397
|
-
raise FetchError.new("no key for host #{host} in s3_source in .gemrc", "s3://#{host}") unless auth
|
398
|
-
|
399
|
-
id = auth[:id] || auth['id']
|
400
|
-
secret = auth[:secret] || auth['secret']
|
401
|
-
raise FetchError.new("s3_source for #{host} missing id or secret", "s3://#{host}") unless id and secret
|
402
|
-
|
403
|
-
[id, secret]
|
404
|
-
end
|
405
366
|
end
|