[前][次][番号順一覧][スレッド一覧]

ruby-changes:39538

From: nagachika <ko1@a...>
Date: Mon, 17 Aug 2015 23:20:51 +0900 (JST)
Subject: [ruby-changes:39538] nagachika:r51619 (ruby_2_2): merge revision(s) 50829: [Backport #11248]

nagachika	2015-08-17 23:20:34 +0900 (Mon, 17 Aug 2015)

  New Revision: 51619

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51619

  Log:
    merge revision(s) 50829: [Backport #11248]
    
    * lib/rubygems.rb: bump version to 2.4.5.1. this version fixed
      CVE-2015-3900.
    
    * lib/rubygems/remote_fetcher.rb: ditto.
    
    * test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/lib/rubygems/remote_fetcher.rb
    branches/ruby_2_2/lib/rubygems.rb
    branches/ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 51618)
+++ ruby_2_2/ChangeLog	(revision 51619)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Mon Aug 17 23:07:47 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* lib/rubygems.rb: bump version to 2.4.5.1. this version fixed
+	  CVE-2015-3900.
+	* lib/rubygems/remote_fetcher.rb: ditto.
+	* test/rubygems/test_gem_remote_fetcher.rb: added testcase for CVE-2015-3900
+
 Mon Aug 17 23:00:56 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/win32/lib/win32/registry.rb (API#SetValue): data size should
Index: ruby_2_2/lib/rubygems/remote_fetcher.rb
===================================================================
--- ruby_2_2/lib/rubygems/remote_fetcher.rb	(revision 51618)
+++ ruby_2_2/lib/rubygems/remote_fetcher.rb	(revision 51619)
@@ -94,7 +94,13 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/rubygems/remote_fetcher.rb#L94
     rescue Resolv::ResolvError
       uri
     else
-      URI.parse "#{uri.scheme}://#{res.target}#{uri.path}"
+      target = res.target.to_s.strip
+
+      if /\.#{Regexp.quote(host)}\z/ =~ target
+        return URI.parse "#{uri.scheme}://#{target}#{uri.path}"
+      end
+
+      uri
     end
   end
 
Index: ruby_2_2/lib/rubygems.rb
===================================================================
--- ruby_2_2/lib/rubygems.rb	(revision 51618)
+++ ruby_2_2/lib/rubygems.rb	(revision 51619)
@@ -9,7 +9,7 @@ require 'rbconfig' https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/rubygems.rb#L9
 require 'thread'
 
 module Gem
-  VERSION = '2.4.5'
+  VERSION = '2.4.5.1'
 end
 
 # Must be first since it unloads the prelude from 1.9.2
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 51618)
+++ ruby_2_2/version.h	(revision 51619)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.3"
 #define RUBY_RELEASE_DATE "2015-08-17"
-#define RUBY_PATCHLEVEL 170
+#define RUBY_PATCHLEVEL 171
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 8
Index: ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb	(revision 51618)
+++ ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb	(revision 51619)
@@ -167,6 +167,21 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb#L167
   end
 
   def test_api_endpoint
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "gems.example.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values
     uri = URI.parse "http://gems.example.com/foo"
     target = MiniTest::Mock.new
     target.expect :target, "blah.com"
@@ -175,8 +190,37 @@ gems: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/rubygems/test_gem_remote_fetcher.rb#L190
     dns.expect :getresource, target, [String, Object]
 
     fetch = Gem::RemoteFetcher.new nil, dns
-    @fetcher = fetcher
-    assert_equal URI.parse("http://blah.com/foo"), fetch.api_endpoint(uri)
+    assert_equal URI.parse("http://gems.example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values_that_starts_with_original
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "example.combadguy.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
+
+    target.verify
+    dns.verify
+  end
+
+  def test_api_endpoint_ignores_trans_domain_values_that_end_with_original
+    uri = URI.parse "http://example.com/foo"
+    target = MiniTest::Mock.new
+    target.expect :target, "badexample.com"
+
+    dns = MiniTest::Mock.new
+    dns.expect :getresource, target, [String, Object]
+
+    fetch = Gem::RemoteFetcher.new nil, dns
+    assert_equal URI.parse("http://example.com/foo"), fetch.api_endpoint(uri)
 
     target.verify
     dns.verify

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r50829


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]