rubygems-update 2.6.11 → 2.6.14

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubygems-update might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3145b3347290a8137e8aafa35a0c28e7a2df9cf50129a35f8e99c4e37dfbad9
4
- data.tar.gz: e9c34d66185f10c358e6bfb47d1a55828f3433d16eb1c1dddb127c36fcab297d
3
+ metadata.gz: 57912bb77dd87dcd42c101212129e693553e4d31b01e3475f423d69606d054f2
4
+ data.tar.gz: 6c57e3463ebe2e2dec90d8c99ba48212622faac0cdfc7bb90ab91d1299a2af97
5
5
  SHA512:
6
- metadata.gz: 9e27f2aa64535ebc313e5ede961eccb6b671ee65d42730ab84b200df57a3f819ef5f379d9c5041ee80d6127d8fad2a03c9661ecf1042fe712f9767178d883e43
7
- data.tar.gz: 19aeb548def6a0b6a274e5281f1b840a8de35d026c31ff4d9bb1f827808b58758f6a1fe9d72688a8c02043cecae13912c5894832a27889ebbe0f8974190c1208
6
+ metadata.gz: ea7514aa2ffa01b8d84c0834933fdd8f8682bbbb272faaf8980c398e0fdce05131225132449ae51aab1852905a82bab8cf2e88a94f7fef83c442791735e37c4e
7
+ data.tar.gz: c2b993fac57b622ad7f95622e5724c79f0c82f612c88d7f94c2db7be01d9eb2c93bdcaabc59b3adbd4cb530e4ccc4ebdcacc31e97ce2b2d4cf65af6c3d54c79d
@@ -1,5 +1,50 @@
1
1
  # coding: UTF-8
2
2
 
3
+ === 2.6.14 / 2017-10-09
4
+
5
+ Security fixes:
6
+
7
+ * Whitelist classes and symbols that are in loaded YAML.
8
+ See CVE-2017-0903 for full details.
9
+ Fix by Aaron Patterson.
10
+
11
+ === 2.6.13 / 2017-08-27
12
+
13
+ Security fixes:
14
+
15
+ * Fix a DNS request hijacking vulnerability.
16
+ Fix by Samuel Giddins.
17
+ * Fix an ANSI escape sequence vulnerability.
18
+ Fix by Evan Phoenix.
19
+ * Fix a DOS vulernerability in the `query` command.
20
+ Fix by Samuel Giddins.
21
+ * Fix a vulnerability in the gem installer that allowed
22
+ a malicious gem to overwrite arbitrary files.
23
+ Fix by Samuel Giddins.
24
+
25
+ === 2.6.12 / 2017-04-30
26
+
27
+ Bug fixes:
28
+
29
+ * Fix test_self_find_files_with_gemfile to sort expected files. Pull
30
+ request #1880 by Kazuaki Matsuo.
31
+ * Fix issue for MinGW / MSYS2 builds and testing. Pull request #1879 by
32
+ MSP-Greg.
33
+ * Fix gem open to open highest version number rather than lowest. Pull
34
+ request #1877 by Tim Pope.
35
+ * Add a test for requiring a default spec as installed by the ruby
36
+ installer. Pull request #1899 by Samuel Giddins.
37
+ * Fix broken --exact parameter to gem command. Pull request #1873 by Jason
38
+ Frey.
39
+ * [Installer] Generate backwards-compatible binstubs. Pull request #1904
40
+ by Samuel Giddins.
41
+ * Fix pre-existing source recognition on add action. Pull request #1883 by
42
+ Jonathan Claudius.
43
+ * Prevent negative IDs in output of #inspect. Pull request #1908 by Vít
44
+ Ondruch.
45
+ * Allow Gem.finish_resolve to respect already-activated specs. Pull
46
+ request #1910 by Samuel Giddins.
47
+
3
48
  === 2.6.11 / 2017-03-16
4
49
 
5
50
  Bug fixes:
@@ -387,6 +387,7 @@ lib/rubygems/resolver/specification.rb
387
387
  lib/rubygems/resolver/stats.rb
388
388
  lib/rubygems/resolver/vendor_set.rb
389
389
  lib/rubygems/resolver/vendor_specification.rb
390
+ lib/rubygems/safe_yaml.rb
390
391
  lib/rubygems/security.rb
391
392
  lib/rubygems/security/policies.rb
392
393
  lib/rubygems/security/policy.rb
@@ -10,7 +10,7 @@ require 'rbconfig'
10
10
  require 'thread'
11
11
 
12
12
  module Gem
13
- VERSION = "2.6.11"
13
+ VERSION = "2.6.14"
14
14
  end
15
15
 
16
16
  # Must be first since it unloads the prelude from 1.9.2
@@ -234,6 +234,7 @@ module Gem
234
234
 
235
235
  def self.finish_resolve(request_set=Gem::RequestSet.new)
236
236
  request_set.import Gem::Specification.unresolved_deps.values
237
+ request_set.import Gem.loaded_specs.values.map {|s| Gem::Dependency.new(s.name, s.version) }
237
238
 
238
239
  request_set.resolve_current.each do |s|
239
240
  s.full_spec.activate
@@ -674,7 +675,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
674
675
 
675
676
  unless test_syck
676
677
  begin
677
- gem 'psych', '>= 1.2.1'
678
+ gem 'psych', '>= 2.0.0'
678
679
  rescue Gem::LoadError
679
680
  # It's OK if the user does not have the psych gem installed. We will
680
681
  # attempt to require the stdlib version
@@ -698,6 +699,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
698
699
  end
699
700
 
700
701
  require 'yaml'
702
+ require 'rubygems/safe_yaml'
701
703
 
702
704
  # If we're supposed to be using syck, then we may have to force
703
705
  # activate it via the YAML::ENGINE API.
@@ -72,7 +72,7 @@ class Gem::Commands::OpenCommand < Gem::Command
72
72
  end
73
73
 
74
74
  def spec_for name
75
- spec = Gem::Specification.find_all_by_name(name, @version).last
75
+ spec = Gem::Specification.find_all_by_name(name, @version).first
76
76
 
77
77
  return spec if spec
78
78
 
@@ -86,7 +86,7 @@ is too hard to use.
86
86
  name = Array(options[:name])
87
87
  else
88
88
  args = options[:args].to_a
89
- name = options[:exact] ? args : args.map{|arg| /#{arg}/i }
89
+ name = options[:exact] ? args.map{|arg| /\A#{Regexp.escape(arg)}\Z/ } : args.map{|arg| /#{arg}/i }
90
90
  end
91
91
 
92
92
  prerelease = options[:prerelease]
@@ -226,7 +226,7 @@ is too hard to use.
226
226
  end
227
227
  end
228
228
 
229
- output << make_entry(matching_tuples, platforms)
229
+ output << clean_text(make_entry(matching_tuples, platforms))
230
230
  end
231
231
  end
232
232
 
@@ -353,7 +353,8 @@ is too hard to use.
353
353
  end
354
354
 
355
355
  def spec_summary entry, spec
356
- entry << "\n\n" << format_text(spec.summary, 68, 4)
356
+ summary = truncate_text(spec.summary, "the summary for #{spec.full_name}")
357
+ entry << "\n\n" << format_text(summary, 68, 4)
357
358
  end
358
359
 
359
360
  end
@@ -44,7 +44,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
44
44
  source = Gem::Source.new source_uri
45
45
 
46
46
  begin
47
- if Gem.sources.include? source_uri then
47
+ if Gem.sources.include? source then
48
48
  say "source #{source_uri} already present in the cache"
49
49
  else
50
50
  source.load_specs :released
@@ -345,7 +345,7 @@ if you believe they were disclosed to a third party.
345
345
  return {} unless filename and File.exist? filename
346
346
 
347
347
  begin
348
- content = YAML.load(File.read(filename))
348
+ content = Gem::SafeYAML.load(File.read(filename))
349
349
  unless content.kind_of? Hash
350
350
  warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
351
351
  return {}
@@ -104,7 +104,7 @@ class Gem::DependencyList
104
104
  end
105
105
 
106
106
  def inspect # :nodoc:
107
- "#<%s:0x%x %p>" % [self.class, object_id, map { |s| s.full_name }]
107
+ "%s %p>" % [super[0..-2], map { |s| s.full_name }]
108
108
  end
109
109
 
110
110
  ##
@@ -214,7 +214,7 @@ class Gem::Installer
214
214
 
215
215
  ruby_executable = true
216
216
  existing = io.read.slice(%r{
217
- ^(
217
+ ^\s*(
218
218
  gem \s |
219
219
  load \s Gem\.bin_path\( |
220
220
  load \s Gem\.activate_bin_path\(
@@ -697,10 +697,17 @@ class Gem::Installer
697
697
  unpack or File.writable?(gem_home)
698
698
  end
699
699
 
700
+ def verify_spec_name
701
+ return if spec.name =~ Gem::Specification::VALID_NAME_PATTERN
702
+ raise Gem::InstallError, "#{spec} has an invalid name"
703
+ end
704
+
700
705
  ##
701
706
  # Return the text for an application file.
702
707
 
703
708
  def app_script_text(bin_file_name)
709
+ # note that the `load` lines cannot be indented, as old RG versions match
710
+ # against the beginning of the line
704
711
  return <<-TEXT
705
712
  #{shebang bin_file_name}
706
713
  #
@@ -723,7 +730,12 @@ if ARGV.first
723
730
  end
724
731
  end
725
732
 
733
+ if Gem.respond_to?(:activate_bin_path)
726
734
  load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
735
+ else
736
+ gem #{spec.name.dump}, version
737
+ load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
738
+ end
727
739
  TEXT
728
740
  end
729
741
 
@@ -816,6 +828,8 @@ TEXT
816
828
 
817
829
  ensure_loadable_spec
818
830
 
831
+ verify_spec_name
832
+
819
833
  if options[:install_as_default]
820
834
  Gem.ensure_default_gem_subdirectories gem_home
821
835
  else
@@ -468,7 +468,7 @@ EOM
468
468
 
469
469
  @checksums = gem.seek 'checksums.yaml.gz' do |entry|
470
470
  Zlib::GzipReader.wrap entry do |gz_io|
471
- YAML.load gz_io.read
471
+ Gem::SafeYAML.safe_load gz_io.read
472
472
  end
473
473
  end
474
474
  end
@@ -101,7 +101,7 @@ class Gem::Package::Old < Gem::Package
101
101
  header << line
102
102
  end
103
103
 
104
- YAML.load header
104
+ Gem::SafeYAML.safe_load header
105
105
  end
106
106
 
107
107
  ##
@@ -112,7 +112,7 @@ class Gem::Platform
112
112
  end
113
113
 
114
114
  def inspect
115
- "#<%s:0x%x @cpu=%p, @os=%p, @version=%p>" % [self.class, object_id, *to_a]
115
+ "%s @cpu=%p, @os=%p, @version=%p>" % [super[0..-2], *to_a]
116
116
  end
117
117
 
118
118
  def to_a
@@ -110,7 +110,7 @@ class Gem::RemoteFetcher
110
110
  else
111
111
  target = res.target.to_s.strip
112
112
 
113
- if /\.#{Regexp.quote(host)}\z/ =~ target
113
+ if URI("http://" + target).host.end_with?(".#{host}")
114
114
  return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
115
115
  end
116
116
 
@@ -0,0 +1,48 @@
1
+ module Gem
2
+
3
+ ###
4
+ # This module is used for safely loading YAML specs from a gem. The
5
+ # `safe_load` method defined on this module is specifically designed for
6
+ # loading Gem specifications. For loading other YAML safely, please see
7
+ # Psych.safe_load
8
+
9
+ module SafeYAML
10
+ WHITELISTED_CLASSES = %w(
11
+ Symbol
12
+ Time
13
+ Date
14
+ Gem::Dependency
15
+ Gem::Platform
16
+ Gem::Requirement
17
+ Gem::Specification
18
+ Gem::Version
19
+ Gem::Version::Requirement
20
+ YAML::Syck::DefaultKey
21
+ Syck::DefaultKey
22
+ )
23
+
24
+ WHITELISTED_SYMBOLS = %w(
25
+ development
26
+ runtime
27
+ )
28
+
29
+ if ::YAML.respond_to? :safe_load
30
+ def self.safe_load input
31
+ ::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true)
32
+ end
33
+
34
+ def self.load input
35
+ ::YAML.safe_load(input, [::Symbol])
36
+ end
37
+ else
38
+ warn "YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0)."
39
+ def self.safe_load input, *args
40
+ ::YAML.load input
41
+ end
42
+
43
+ def self.load input
44
+ ::YAML.load input
45
+ end
46
+ end
47
+ end
48
+ end
@@ -455,7 +455,7 @@ module Gem::Security
455
455
 
456
456
  ##
457
457
  # Creates a new key pair of the specified +length+ and +algorithm+. The
458
- # default is a 2048 bit RSA key.
458
+ # default is a 3072 bit RSA key.
459
459
 
460
460
  def self.create_key length = KEY_LENGTH, algorithm = KEY_ALGORITHM
461
461
  algorithm.new length
@@ -657,7 +657,7 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
657
657
  "only_one_executable" => true,
658
658
  "full_name" => "rubygems-#{Gem::VERSION}",
659
659
  "has_deps" => false,
660
- "homepage" => "http://docs.rubygems.org/",
660
+ "homepage" => "http://guides.rubygems.org/",
661
661
  "name" => 'rubygems',
662
662
  "ri_installed" => true,
663
663
  "summary" => "RubyGems itself",
@@ -108,6 +108,8 @@ class Gem::Specification < Gem::BasicSpecification
108
108
 
109
109
  private_constant :LOAD_CACHE if defined? private_constant
110
110
 
111
+ VALID_NAME_PATTERN = /\A[a-zA-Z0-9\.\-\_]+\z/ # :nodoc:
112
+
111
113
  # :startdoc:
112
114
 
113
115
  ##
@@ -1099,7 +1101,7 @@ class Gem::Specification < Gem::BasicSpecification
1099
1101
  Gem.load_yaml
1100
1102
 
1101
1103
  input = normalize_yaml_input input
1102
- spec = YAML.load input
1104
+ spec = Gem::SafeYAML.safe_load input
1103
1105
 
1104
1106
  if spec && spec.class == FalseClass then
1105
1107
  raise Gem::EndOfYAMLException
@@ -2102,7 +2104,7 @@ class Gem::Specification < Gem::BasicSpecification
2102
2104
  if $DEBUG
2103
2105
  super
2104
2106
  else
2105
- "#<#{self.class}:0x#{__id__.to_s(16)} #{full_name}>"
2107
+ "#{super[0..-2]} #{full_name}>"
2106
2108
  end
2107
2109
  end
2108
2110
 
@@ -2668,9 +2670,15 @@ class Gem::Specification < Gem::BasicSpecification
2668
2670
  end
2669
2671
  end
2670
2672
 
2671
- unless String === name then
2673
+ if !name.is_a?(String) then
2674
+ raise Gem::InvalidSpecificationException,
2675
+ "invalid value for attribute name: \"#{name.inspect}\" must be a string"
2676
+ elsif name !~ /[a-zA-Z]/ then
2677
+ raise Gem::InvalidSpecificationException,
2678
+ "invalid value for attribute name: #{name.dump} must include at least one letter"
2679
+ elsif name !~ VALID_NAME_PATTERN then
2672
2680
  raise Gem::InvalidSpecificationException,
2673
- "invalid value for attribute name: \"#{name.inspect}\""
2681
+ "invalid value for attribute name: #{name.dump} can only include letters, numbers, dashes, and underscores"
2674
2682
  end
2675
2683
 
2676
2684
  if raw_require_paths.empty? then
@@ -484,7 +484,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
484
484
 
485
485
  system @git, 'add', gemspec
486
486
  system @git, 'commit', '-a', '-m', 'a non-empty commit message', '--quiet'
487
- head = Gem::Util.popen('git', 'rev-parse', 'master').strip
487
+ head = Gem::Util.popen(@git, 'rev-parse', 'master').strip
488
488
  end
489
489
 
490
490
  return name, git_spec.version, directory, head
@@ -1498,6 +1498,8 @@ end
1498
1498
  begin
1499
1499
  gem 'rdoc'
1500
1500
  require 'rdoc'
1501
+
1502
+ require 'rubygems/rdoc'
1501
1503
  rescue LoadError, Gem::LoadError
1502
1504
  end
1503
1505
 
@@ -1514,3 +1516,4 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
1514
1516
  pid = $$
1515
1517
  END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
1516
1518
  Gem.clear_paths
1519
+ Gem.loaded_specs.clear
@@ -6,13 +6,26 @@ require 'rubygems'
6
6
 
7
7
  module Gem::Text
8
8
 
9
+ ##
10
+ # Remove any non-printable characters and make the text suitable for
11
+ # printing.
12
+ def clean_text(text)
13
+ text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".".freeze)
14
+ end
15
+
16
+ def truncate_text(text, description, max_length = 100_000)
17
+ raise ArgumentError, "max_length must be positive" unless max_length > 0
18
+ return text if text.size <= max_length
19
+ "Truncating #{description} to #{max_length.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse} characters:\n" + text[0, max_length]
20
+ end
21
+
9
22
  ##
10
23
  # Wraps +text+ to +wrap+ characters and optionally indents by +indent+
11
24
  # characters
12
25
 
13
26
  def format_text(text, wrap, indent=0)
14
27
  result = []
15
- work = text.dup
28
+ work = clean_text(text)
16
29
 
17
30
  while work.length > wrap do
18
31
  if work =~ /^(.{0,#{wrap}})[ \n]/ then
@@ -75,6 +75,29 @@ class TestGem < Gem::TestCase
75
75
  end
76
76
  end
77
77
 
78
+ def test_self_finish_resolve_respects_loaded_specs
79
+ save_loaded_features do
80
+ a1 = new_spec "a", "1", "b" => "> 0"
81
+ b1 = new_spec "b", "1", "c" => ">= 1"
82
+ b2 = new_spec "b", "2", "c" => ">= 2"
83
+ c1 = new_spec "c", "1"
84
+ c2 = new_spec "c", "2"
85
+
86
+ install_specs c1, c2, b1, b2, a1
87
+
88
+ a1.activate
89
+ c1.activate
90
+
91
+ assert_equal %w(a-1 c-1), loaded_spec_names
92
+ assert_equal ["b (> 0)"], unresolved_names
93
+
94
+ Gem.finish_resolve
95
+
96
+ assert_equal %w(a-1 b-1 c-1), loaded_spec_names
97
+ assert_equal [], unresolved_names
98
+ end
99
+ end
100
+
78
101
  def test_self_install
79
102
  spec_fetcher do |f|
80
103
  f.gem 'a', 1
@@ -492,7 +515,7 @@ class TestGem < Gem::TestCase
492
515
  skip if RUBY_VERSION <= "1.8.7"
493
516
 
494
517
  cwd = File.expand_path("test/rubygems", @@project_dir)
495
- $LOAD_PATH.unshift cwd
518
+ actual_load_path = $LOAD_PATH.unshift(cwd).dup
496
519
 
497
520
  discover_path = File.join 'lib', 'sff', 'discover.rb'
498
521
 
@@ -518,12 +541,12 @@ class TestGem < Gem::TestCase
518
541
  expected = [
519
542
  File.expand_path('test/rubygems/sff/discover.rb', @@project_dir),
520
543
  File.join(foo1.full_gem_path, discover_path)
521
- ]
544
+ ].sort
522
545
 
523
- assert_equal expected, Gem.find_files('sff/discover')
524
- assert_equal expected, Gem.find_files('sff/**.rb'), '[ruby-core:31730]'
546
+ assert_equal expected, Gem.find_files('sff/discover').sort
547
+ assert_equal expected, Gem.find_files('sff/**.rb').sort, '[ruby-core:31730]'
525
548
  ensure
526
- assert_equal cwd, $LOAD_PATH.shift unless RUBY_VERSION <= "1.8.7"
549
+ assert_equal cwd, actual_load_path.shift unless RUBY_VERSION <= "1.8.7"
527
550
  end
528
551
 
529
552
  def test_self_find_latest_files
@@ -24,7 +24,8 @@ class TestGemCommandsOpenCommand < Gem::TestCase
24
24
  @cmd.options[:args] = %w[foo]
25
25
  @cmd.options[:editor] = "#{Gem.ruby} -e0 --"
26
26
 
27
- spec = gem 'foo'
27
+ gem 'foo', '1.0.0'
28
+ spec = gem 'foo', '1.0.1'
28
29
  mock = MiniTest::Mock.new
29
30
  mock.expect(:call, true, [spec.full_gem_path])
30
31
 
@@ -116,6 +116,86 @@ a (2)
116
116
  This is a lot of text. This is a lot of text. This is a lot of text.
117
117
  This is a lot of text.
118
118
 
119
+ pl (1)
120
+ Platform: i386-linux
121
+ Author: A User
122
+ Homepage: http://example.com
123
+
124
+ this is a summary
125
+ EOF
126
+
127
+ assert_equal expected, @ui.output
128
+ assert_equal '', @ui.error
129
+ end
130
+
131
+ def test_execute_details_cleans_text
132
+ spec_fetcher do |fetcher|
133
+ fetcher.spec 'a', 2 do |s|
134
+ s.summary = 'This is a lot of text. ' * 4
135
+ s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
136
+ s.homepage = "http://a.example.com/\x03"
137
+ end
138
+
139
+ fetcher.legacy_platform
140
+ end
141
+
142
+ @cmd.handle_options %w[-r -d]
143
+
144
+ use_ui @ui do
145
+ @cmd.execute
146
+ end
147
+
148
+ expected = <<-EOF
149
+
150
+ *** REMOTE GEMS ***
151
+
152
+ a (2)
153
+ Authors: Abraham Lincoln ., . Hirohito
154
+ Homepage: http://a.example.com/.
155
+
156
+ This is a lot of text. This is a lot of text. This is a lot of text.
157
+ This is a lot of text.
158
+
159
+ pl (1)
160
+ Platform: i386-linux
161
+ Author: A User
162
+ Homepage: http://example.com
163
+
164
+ this is a summary
165
+ EOF
166
+
167
+ assert_equal expected, @ui.output
168
+ assert_equal '', @ui.error
169
+ end
170
+
171
+ def test_execute_details_truncates_summary
172
+ spec_fetcher do |fetcher|
173
+ fetcher.spec 'a', 2 do |s|
174
+ s.summary = 'This is a lot of text. ' * 10_000
175
+ s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
176
+ s.homepage = "http://a.example.com/\x03"
177
+ end
178
+
179
+ fetcher.legacy_platform
180
+ end
181
+
182
+ @cmd.handle_options %w[-r -d]
183
+
184
+ use_ui @ui do
185
+ @cmd.execute
186
+ end
187
+
188
+ expected = <<-EOF
189
+
190
+ *** REMOTE GEMS ***
191
+
192
+ a (2)
193
+ Authors: Abraham Lincoln ., . Hirohito
194
+ Homepage: http://a.example.com/.
195
+
196
+ Truncating the summary for a-2 to 100,000 characters:
197
+ #{" This is a lot of text. This is a lot of text. This is a lot of text.\n" * 1449} This is a lot of te
198
+
119
199
  pl (1)
120
200
  Platform: i386-linux
121
201
  Author: A User
@@ -642,7 +722,7 @@ pl (1)
642
722
  assert_equal expected, @ui.output
643
723
  end
644
724
 
645
- def test_execute_exact
725
+ def test_execute_exact_remote
646
726
  spec_fetcher do |fetcher|
647
727
  fetcher.spec 'coolgem-omg', 3
648
728
  fetcher.spec 'coolgem', '4.2.1'
@@ -665,6 +745,60 @@ coolgem (4.2.1)
665
745
  assert_equal expected, @ui.output
666
746
  end
667
747
 
748
+ def test_execute_exact_local
749
+ spec_fetcher do |fetcher|
750
+ fetcher.spec 'coolgem-omg', 3
751
+ fetcher.spec 'coolgem', '4.2.1'
752
+ fetcher.spec 'wow_coolgem', 1
753
+ end
754
+
755
+ @cmd.handle_options %w[--exact coolgem]
756
+
757
+ use_ui @ui do
758
+ @cmd.execute
759
+ end
760
+
761
+ expected = <<-EOF
762
+
763
+ *** LOCAL GEMS ***
764
+
765
+ coolgem (4.2.1)
766
+ EOF
767
+
768
+ assert_equal expected, @ui.output
769
+ end
770
+
771
+ def test_execute_exact_multiple
772
+ spec_fetcher do |fetcher|
773
+ fetcher.spec 'coolgem-omg', 3
774
+ fetcher.spec 'coolgem', '4.2.1'
775
+ fetcher.spec 'wow_coolgem', 1
776
+
777
+ fetcher.spec 'othergem-omg', 3
778
+ fetcher.spec 'othergem', '1.2.3'
779
+ fetcher.spec 'wow_othergem', 1
780
+ end
781
+
782
+ @cmd.handle_options %w[--exact coolgem othergem]
783
+
784
+ use_ui @ui do
785
+ @cmd.execute
786
+ end
787
+
788
+ expected = <<-EOF
789
+
790
+ *** LOCAL GEMS ***
791
+
792
+ coolgem (4.2.1)
793
+
794
+ *** LOCAL GEMS ***
795
+
796
+ othergem (1.2.3)
797
+ EOF
798
+
799
+ assert_equal expected, @ui.output
800
+ end
801
+
668
802
  private
669
803
 
670
804
  def add_gems_to_fetcher
@@ -108,6 +108,58 @@ source #{@gem_repo} already present in the cache
108
108
  assert_equal '', @ui.error
109
109
  end
110
110
 
111
+ def test_execute_add_redundant_source_trailing_slash
112
+ # Remove pre-existing gem source (w/ slash)
113
+ repo_with_slash = "http://gems.example.com/"
114
+ @cmd.handle_options %W[--remove #{repo_with_slash}]
115
+ use_ui @ui do
116
+ @cmd.execute
117
+ end
118
+ source = Gem::Source.new repo_with_slash
119
+ assert_equal false, Gem.sources.include?(source)
120
+
121
+ expected = <<-EOF
122
+ #{repo_with_slash} removed from sources
123
+ EOF
124
+
125
+ assert_equal expected, @ui.output
126
+ assert_equal '', @ui.error
127
+
128
+ # Re-add pre-existing gem source (w/o slash)
129
+ repo_without_slash = "http://gems.example.com"
130
+ @cmd.handle_options %W[--add #{repo_without_slash}]
131
+ use_ui @ui do
132
+ @cmd.execute
133
+ end
134
+ source = Gem::Source.new repo_without_slash
135
+ assert_equal true, Gem.sources.include?(source)
136
+
137
+ expected = <<-EOF
138
+ http://gems.example.com/ removed from sources
139
+ http://gems.example.com added to sources
140
+ EOF
141
+
142
+ assert_equal expected, @ui.output
143
+ assert_equal '', @ui.error
144
+
145
+ # Re-add original gem source (w/ slash)
146
+ @cmd.handle_options %W[--add #{repo_with_slash}]
147
+ use_ui @ui do
148
+ @cmd.execute
149
+ end
150
+ source = Gem::Source.new repo_with_slash
151
+ assert_equal true, Gem.sources.include?(source)
152
+
153
+ expected = <<-EOF
154
+ http://gems.example.com/ removed from sources
155
+ http://gems.example.com added to sources
156
+ source http://gems.example.com/ already present in the cache
157
+ EOF
158
+
159
+ assert_equal expected, @ui.output
160
+ assert_equal '', @ui.error
161
+ end
162
+
111
163
  def test_execute_add_http_rubygems_org
112
164
  http_rubygems_org = 'http://rubygems.org'
113
165
 
@@ -62,7 +62,12 @@ if ARGV.first
62
62
  end
63
63
  end
64
64
 
65
+ if Gem.respond_to?(:activate_bin_path)
65
66
  load Gem.activate_bin_path('a', 'executable', version)
67
+ else
68
+ gem "a", version
69
+ load Gem.bin_path("a", "executable", version)
70
+ end
66
71
  EOF
67
72
 
68
73
  wrapper = @installer.app_script_text 'executable'
@@ -1443,6 +1448,26 @@ gem 'other', version
1443
1448
  end
1444
1449
  end
1445
1450
 
1451
+ def test_pre_install_checks_malicious_name
1452
+ spec = util_spec '../malicious', '1'
1453
+ def spec.full_name # so the spec is buildable
1454
+ "malicious-1"
1455
+ end
1456
+ def spec.validate; end
1457
+
1458
+ util_build_gem spec
1459
+
1460
+ gem = File.join(@gemhome, 'cache', spec.file_name)
1461
+
1462
+ use_ui @ui do
1463
+ @installer = Gem::Installer.at gem
1464
+ e = assert_raises Gem::InstallError do
1465
+ @installer.pre_install_checks
1466
+ end
1467
+ assert_equal '#<Gem::Specification name=../malicious version=1> has an invalid name', e.message
1468
+ end
1469
+ end
1470
+
1446
1471
  def test_shebang
1447
1472
  util_make_exec @spec, "#!/usr/bin/ruby"
1448
1473
 
@@ -241,6 +241,21 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
241
241
  dns.verify
242
242
  end
243
243
 
244
+ def test_api_endpoint_ignores_trans_domain_values_that_end_with_original_in_path
245
+ uri = URI.parse "http://example.com/foo"
246
+ target = MiniTest::Mock.new
247
+ target.expect :target, "evil.com/a.example.com"
248
+
249
+ dns = MiniTest::Mock.new
250
+ dns.expect :getresource, target, [String, Object]
251
+
252
+ fetch = Gem::RemoteFetcher.new nil, dns
253
+ assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
254
+
255
+ target.verify
256
+ dns.verify
257
+ end
258
+
244
259
  def test_api_endpoint_timeout_warning
245
260
  uri = URI.parse "http://gems.example.com/foo"
246
261
 
@@ -2985,7 +2985,37 @@ Did you mean 'Ruby'?
2985
2985
  @a1.validate
2986
2986
  end
2987
2987
 
2988
- assert_equal 'invalid value for attribute name: ":json"', e.message
2988
+ assert_equal 'invalid value for attribute name: ":json" must be a string', e.message
2989
+
2990
+ @a1.name = []
2991
+ e = assert_raises Gem::InvalidSpecificationException do
2992
+ @a1.validate
2993
+ end
2994
+ assert_equal "invalid value for attribute name: \"[]\" must be a string", e.message
2995
+
2996
+ @a1.name = ""
2997
+ e = assert_raises Gem::InvalidSpecificationException do
2998
+ @a1.validate
2999
+ end
3000
+ assert_equal "invalid value for attribute name: \"\" must include at least one letter", e.message
3001
+
3002
+ @a1.name = "12345"
3003
+ e = assert_raises Gem::InvalidSpecificationException do
3004
+ @a1.validate
3005
+ end
3006
+ assert_equal "invalid value for attribute name: \"12345\" must include at least one letter", e.message
3007
+
3008
+ @a1.name = "../malicious"
3009
+ e = assert_raises Gem::InvalidSpecificationException do
3010
+ @a1.validate
3011
+ end
3012
+ assert_equal "invalid value for attribute name: \"../malicious\" can only include letters, numbers, dashes, and underscores", e.message
3013
+
3014
+ @a1.name = "\ba\t"
3015
+ e = assert_raises Gem::InvalidSpecificationException do
3016
+ @a1.validate
3017
+ end
3018
+ assert_equal "invalid value for attribute name: \"\\ba\\t\" can only include letters, numbers, dashes, and underscores", e.message
2989
3019
  end
2990
3020
 
2991
3021
  def test_validate_non_nil
@@ -36,6 +36,10 @@ Without the wrapping, the text might not look good in the RSS feed.
36
36
  assert_equal expected, format_text(text, 78)
37
37
  end
38
38
 
39
+ def test_format_removes_nonprintable_characters
40
+ assert_equal "text with weird .. stuff .", format_text("text with weird \x1b\x02 stuff \x7f", 40)
41
+ end
42
+
39
43
  def test_min3
40
44
  assert_equal 1, min3(1, 1, 1)
41
45
  assert_equal 1, min3(1, 1, 2)
@@ -74,4 +78,11 @@ Without the wrapping, the text might not look good in the RSS feed.
74
78
  assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
75
79
  assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
76
80
  end
81
+
82
+ def test_truncate_text
83
+ assert_equal "abc", truncate_text("abc", "desc")
84
+ assert_equal "Truncating desc to 2 characters:\nab", truncate_text("abc", "desc", 2)
85
+ s = "ab" * 500_001
86
+ assert_equal "Truncating desc to 1,000,000 characters:\n#{s[0, 1_000_000]}", truncate_text(s, "desc", 1_000_000)
87
+ end
77
88
  end
@@ -301,6 +301,17 @@ class TestGemRequire < Gem::TestCase
301
301
  assert_equal %w(default-2.0.0.0), loaded_spec_names
302
302
  end
303
303
 
304
+ def test_realworld_default_gem
305
+ skip "no default gems on ruby < 2.0" unless RUBY_VERSION >= "2"
306
+ cmd = <<-RUBY
307
+ $stderr = $stdout
308
+ require "json"
309
+ puts Gem.loaded_specs["json"].default_gem?
310
+ RUBY
311
+ output = Gem::Util.popen(Gem.ruby, "-e", cmd).strip
312
+ assert_equal "true", output
313
+ end
314
+
304
315
  def test_default_gem_and_normal_gem
305
316
  default_gem_spec = new_default_spec("default", "2.0.0.0",
306
317
  nil, "default/gem.rb")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygems-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.11
4
+ version: 2.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-17 00:00:00.000000000 Z
13
+ date: 2017-10-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: builder
@@ -553,6 +553,7 @@ files:
553
553
  - lib/rubygems/resolver/stats.rb
554
554
  - lib/rubygems/resolver/vendor_set.rb
555
555
  - lib/rubygems/resolver/vendor_specification.rb
556
+ - lib/rubygems/safe_yaml.rb
556
557
  - lib/rubygems/security.rb
557
558
  - lib/rubygems/security/policies.rb
558
559
  - lib/rubygems/security/policy.rb
@@ -800,7 +801,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
800
801
  version: '0'
801
802
  requirements: []
802
803
  rubyforge_project:
803
- rubygems_version: 2.6.10
804
+ rubygems_version: 2.6.13
804
805
  signing_key:
805
806
  specification_version: 4
806
807
  summary: RubyGems is a package management framework for Ruby