mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/rubygems/command_manager.rb: Removed string concatenation
syntax. [Bug #6265] * lib/rubygems/commands/install_command.rb: ditto * lib/rubygems/commands/uninstall_command.rb: ditto * lib/rubygems/indexer.rb: ditto * lib/rubygems/security/policy.rb: ditto * lib/rubygems/security.rb: ditto * lib/rubygems/uninstaller.rb: ditto * test/rubygems/test_gem_commands_cert_command.rb: ditto * test/rubygems/test_gem_package.rb: ditto * test/rubygems/test_gem_security.rb: ditto * test/rubygems/test_gem_security_policy.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									afae107a4c
								
							
						
					
					
						commit
						80ba379c24
					
				
					 12 changed files with 48 additions and 35 deletions
				
			
		
							
								
								
									
										15
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								ChangeLog
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,3 +1,18 @@
 | 
			
		|||
Thu Dec  6 14:26:22 2012  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/rubygems/command_manager.rb:  Removed string concatenation
 | 
			
		||||
	  syntax.  [Bug #6265]
 | 
			
		||||
	* lib/rubygems/commands/install_command.rb:  ditto
 | 
			
		||||
	* lib/rubygems/commands/uninstall_command.rb:  ditto
 | 
			
		||||
	* lib/rubygems/indexer.rb:  ditto
 | 
			
		||||
	* lib/rubygems/security/policy.rb:  ditto
 | 
			
		||||
	* lib/rubygems/security.rb:  ditto
 | 
			
		||||
	* lib/rubygems/uninstaller.rb:  ditto
 | 
			
		||||
	* test/rubygems/test_gem_commands_cert_command.rb:  ditto
 | 
			
		||||
	* test/rubygems/test_gem_package.rb:  ditto
 | 
			
		||||
	* test/rubygems/test_gem_security.rb:  ditto
 | 
			
		||||
	* test/rubygems/test_gem_security_policy.rb:  ditto
 | 
			
		||||
 | 
			
		||||
Thu Dec  6 14:10:08 2012  Eric Hodel  <drbrain@segment7.net>
 | 
			
		||||
 | 
			
		||||
	* lib/rubygems/package.rb:  Set rubygems_version before validation.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -176,8 +176,7 @@ class Gem::CommandManager
 | 
			
		|||
 | 
			
		||||
    if possibilities.size > 1 then
 | 
			
		||||
      raise Gem::CommandLineError,
 | 
			
		||||
            "Ambiguous command #{cmd_name} " \
 | 
			
		||||
            "matches [#{possibilities.join(', ')}]"
 | 
			
		||||
            "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
 | 
			
		||||
    elsif possibilities.empty? then
 | 
			
		||||
      raise Gem::CommandLineError, "Unknown command #{cmd_name}"
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,7 +48,7 @@ class Gem::Commands::InstallCommand < Gem::Command
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def defaults_str # :nodoc:
 | 
			
		||||
    "--both --version '#{Gem::Requirement.default}' --document --no-force\n" \
 | 
			
		||||
    "--both --version '#{Gem::Requirement.default}' --document --no-force\n" +
 | 
			
		||||
    "--install-dir #{Gem.dir}"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -76,8 +76,8 @@ class Gem::Commands::UninstallCommand < Gem::Command
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def defaults_str # :nodoc:
 | 
			
		||||
    "--version '#{Gem::Requirement.default}' --no-force " \
 | 
			
		||||
    "--install-dir #{Gem.dir}\n" \
 | 
			
		||||
    "--version '#{Gem::Requirement.default}' --no-force " +
 | 
			
		||||
    "--install-dir #{Gem.dir}\n" +
 | 
			
		||||
    "--user-install"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
 | 
			
		|||
        Gem::Uninstaller.new(gem_name, options).uninstall
 | 
			
		||||
      rescue Gem::GemNotInHomeException => e
 | 
			
		||||
        spec = e.spec
 | 
			
		||||
        alert("In order to remove #{spec.name}, please execute:\n" \
 | 
			
		||||
        alert("In order to remove #{spec.name}, please execute:\n" +
 | 
			
		||||
              "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,8 +54,8 @@ class Gem::Indexer
 | 
			
		|||
    require 'zlib'
 | 
			
		||||
 | 
			
		||||
    unless defined?(Builder::XChar) then
 | 
			
		||||
      raise "Gem::Indexer requires that the XML Builder library be installed:" \
 | 
			
		||||
           "\n\tgem install builder"
 | 
			
		||||
      raise "Gem::Indexer requires that the XML Builder library be installed:" +
 | 
			
		||||
            "\n\tgem install builder"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    options = { :build_modern => true }.merge options
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -463,7 +463,7 @@ module Gem::Security
 | 
			
		|||
  def self.re_sign expired_certificate, private_key, age = ONE_YEAR,
 | 
			
		||||
                   extensions = EXTENSIONS
 | 
			
		||||
    raise Gem::Security::Exception,
 | 
			
		||||
          "incorrect signing key for re-signing " \
 | 
			
		||||
          "incorrect signing key for re-signing " +
 | 
			
		||||
          "#{expired_certificate.subject}" unless
 | 
			
		||||
      expired_certificate.public_key.to_pem == private_key.public_key.to_pem
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -473,7 +473,7 @@ module Gem::Security
 | 
			
		|||
      issuer  = alt_name_or_x509_entry expired_certificate, :issuer
 | 
			
		||||
 | 
			
		||||
      raise Gem::Security::Exception,
 | 
			
		||||
            "#{subject} is not self-signed, contact #{issuer} " \
 | 
			
		||||
            "#{subject} is not self-signed, contact #{issuer} " +
 | 
			
		||||
            "to obtain a valid certificate"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ class Gem::Security::Policy
 | 
			
		|||
    root = chain.first
 | 
			
		||||
 | 
			
		||||
    raise Gem::Security::Exception,
 | 
			
		||||
          "root certificate #{root.subject} is not self-signed " \
 | 
			
		||||
          "root certificate #{root.subject} is not self-signed " +
 | 
			
		||||
          "(issuer #{root.issuer})" if
 | 
			
		||||
      root.issuer.to_s != root.subject.to_s # HACK to_s is for ruby 1.8
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -144,7 +144,7 @@ class Gem::Security::Policy
 | 
			
		|||
    cert_dgst = digester.digest pkey_str
 | 
			
		||||
 | 
			
		||||
    raise Gem::Security::Exception,
 | 
			
		||||
          "trusted root certificate #{root.subject} checksum " \
 | 
			
		||||
          "trusted root certificate #{root.subject} checksum " +
 | 
			
		||||
          "does not match signing root certificate checksum" unless
 | 
			
		||||
      save_dgst == cert_dgst
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +152,7 @@ class Gem::Security::Policy
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def inspect # :nodoc:
 | 
			
		||||
    "[Policy: %s - data: %p signer: %p chain: %p root: %p " \
 | 
			
		||||
    "[Policy: %s - data: %p signer: %p chain: %p root: %p " +
 | 
			
		||||
      "signed-only: %p trusted-only: %p]" % [
 | 
			
		||||
      @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
 | 
			
		||||
      @only_signed, @only_trusted,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -178,8 +178,8 @@ class Gem::Uninstaller
 | 
			
		|||
    executables = executables.map { |exec| formatted_program_filename exec }
 | 
			
		||||
 | 
			
		||||
    remove = if @force_executables.nil? then
 | 
			
		||||
               ask_yes_no("Remove executables:\n" \
 | 
			
		||||
                          "\t#{executables.join ', '}\n\n" \
 | 
			
		||||
               ask_yes_no("Remove executables:\n" +
 | 
			
		||||
                          "\t#{executables.join ', '}\n\n" +
 | 
			
		||||
                          "in addition to the gem?",
 | 
			
		||||
                          true)
 | 
			
		||||
             else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -441,8 +441,7 @@ ERROR:  --private-key not specified and ~/.gem/gem-private_key.pem does not exis
 | 
			
		|||
      @cmd.handle_options %W[--certificate #{nonexistent}]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "invalid argument: " \
 | 
			
		||||
                 "--certificate #{nonexistent}: does not exist",
 | 
			
		||||
    assert_equal "invalid argument: --certificate #{nonexistent}: does not exist",
 | 
			
		||||
                 e.message
 | 
			
		||||
 | 
			
		||||
    bad = File.join @tempdir, 'bad'
 | 
			
		||||
| 
						 | 
				
			
			@ -452,7 +451,7 @@ ERROR:  --private-key not specified and ~/.gem/gem-private_key.pem does not exis
 | 
			
		|||
      @cmd.handle_options %W[--certificate #{bad}]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "invalid argument: " \
 | 
			
		||||
    assert_equal "invalid argument: " +
 | 
			
		||||
                 "--certificate #{bad}: invalid X509 certificate",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -463,7 +462,7 @@ ERROR:  --private-key not specified and ~/.gem/gem-private_key.pem does not exis
 | 
			
		|||
      @cmd.handle_options %W[--private-key #{nonexistent}]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "invalid argument: " \
 | 
			
		||||
    assert_equal "invalid argument: " +
 | 
			
		||||
                 "--private-key #{nonexistent}: does not exist",
 | 
			
		||||
                 e.message
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -481,7 +480,7 @@ ERROR:  --private-key not specified and ~/.gem/gem-private_key.pem does not exis
 | 
			
		|||
      @cmd.handle_options %W[--private-key #{PUBLIC_KEY_FILE}]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "invalid argument: " \
 | 
			
		||||
    assert_equal "invalid argument: " +
 | 
			
		||||
                 "--private-key #{PUBLIC_KEY_FILE}: private key not found",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -302,7 +302,7 @@ class TestGemPackage < Gem::Package::TarTestCase
 | 
			
		|||
      package.extract_tar_gz tgz_io, @destination
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal("installing into parent path /absolute.rb of " \
 | 
			
		||||
    assert_equal("installing into parent path /absolute.rb of " +
 | 
			
		||||
                 "#{@destination} is not allowed", e.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -325,7 +325,7 @@ class TestGemPackage < Gem::Package::TarTestCase
 | 
			
		|||
      package.install_location '/absolute.rb', @destination
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal("installing into parent path /absolute.rb of " \
 | 
			
		||||
    assert_equal("installing into parent path /absolute.rb of " +
 | 
			
		||||
                 "#{@destination} is not allowed", e.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -338,7 +338,7 @@ class TestGemPackage < Gem::Package::TarTestCase
 | 
			
		|||
 | 
			
		||||
    parent = File.expand_path File.join @destination, "../relative.rb"
 | 
			
		||||
 | 
			
		||||
    assert_equal("installing into parent path #{parent} of " \
 | 
			
		||||
    assert_equal("installing into parent path #{parent} of " +
 | 
			
		||||
                 "#{@destination} is not allowed", e.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,7 +129,7 @@ class TestGemSecurity < Gem::TestCase
 | 
			
		|||
      Gem::Security.re_sign CHILD_CERT, CHILD_KEY
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "#{ALTERNATE_CERT.subject} is not self-signed, contact " \
 | 
			
		||||
    assert_equal "#{ALTERNATE_CERT.subject} is not self-signed, contact " +
 | 
			
		||||
                 "#{ALTERNATE_CERT.issuer} to obtain a valid certificate",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +139,7 @@ class TestGemSecurity < Gem::TestCase
 | 
			
		|||
      Gem::Security.re_sign ALTERNATE_CERT, PRIVATE_KEY
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "incorrect signing key for re-signing " \
 | 
			
		||||
    assert_equal "incorrect signing key for re-signing " +
 | 
			
		||||
                 "#{ALTERNATE_CERT.subject}",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,8 +91,8 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @chain.check_chain chain, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "invalid signing chain: " \
 | 
			
		||||
                 "certificate #{INVALIDCHILD_CERT.subject} " \
 | 
			
		||||
    assert_equal "invalid signing chain: " +
 | 
			
		||||
                 "certificate #{INVALIDCHILD_CERT.subject} " +
 | 
			
		||||
                 "was not issued by #{CHILD_CERT.subject}", e.message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @low.check_cert EXPIRED_CERT, nil, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "certificate #{EXPIRED_CERT.subject} " \
 | 
			
		||||
    assert_equal "certificate #{EXPIRED_CERT.subject} " +
 | 
			
		||||
                 "not valid after #{EXPIRED_CERT.not_after}",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -115,7 +115,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @low.check_cert FUTURE_CERT, nil, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "certificate #{FUTURE_CERT.subject} " \
 | 
			
		||||
    assert_equal "certificate #{FUTURE_CERT.subject} " +
 | 
			
		||||
                 "not valid before #{FUTURE_CERT.not_before}",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +125,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @low.check_cert INVALID_ISSUER_CERT, PUBLIC_CERT, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "certificate #{INVALID_ISSUER_CERT.subject} " \
 | 
			
		||||
    assert_equal "certificate #{INVALID_ISSUER_CERT.subject} " +
 | 
			
		||||
                 "was not issued by #{PUBLIC_CERT.subject}",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @almost_no.check_key(PUBLIC_CERT, ALTERNATE_KEY)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "certificate #{PUBLIC_CERT.subject} " \
 | 
			
		||||
    assert_equal "certificate #{PUBLIC_CERT.subject} " +
 | 
			
		||||
                 "does not match the signing key", e.message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -160,7 +160,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @chain.check_root chain, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "certificate #{INVALID_SIGNER_CERT.subject} " \
 | 
			
		||||
    assert_equal "certificate #{INVALID_SIGNER_CERT.subject} " +
 | 
			
		||||
                 "was not issued by #{INVALID_SIGNER_CERT.issuer}",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @chain.check_root chain, Time.now
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "root certificate #{INVALID_ISSUER_CERT.subject} " \
 | 
			
		||||
    assert_equal "root certificate #{INVALID_ISSUER_CERT.subject} " +
 | 
			
		||||
                 "is not self-signed (issuer #{INVALID_ISSUER_CERT.issuer})",
 | 
			
		||||
                 e.message
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -196,7 +196,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @high.check_trust [WRONG_KEY_CERT], @sha1, @trust_dir
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "trusted root certificate #{PUBLIC_CERT.subject} checksum " \
 | 
			
		||||
    assert_equal "trusted root certificate #{PUBLIC_CERT.subject} checksum " +
 | 
			
		||||
                 "does not match signing root certificate checksum", e.message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -213,7 +213,7 @@ class TestGemSecurityPolicy < Gem::TestCase
 | 
			
		|||
      @high.check_trust [PUBLIC_CERT, CHILD_CERT], @sha1, @trust_dir
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    assert_equal "root cert #{PUBLIC_CERT.subject} is not trusted " \
 | 
			
		||||
    assert_equal "root cert #{PUBLIC_CERT.subject} is not trusted " +
 | 
			
		||||
                 "(root of signing cert #{CHILD_CERT.subject})", e.message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue