From 80ba379c242ce1d92005403423717cf0f74a74db Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 6 Dec 2012 05:26:46 +0000 Subject: [PATCH] * 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 --- ChangeLog | 15 ++++++++++++++ lib/rubygems/command_manager.rb | 3 +-- lib/rubygems/commands/install_command.rb | 2 +- lib/rubygems/commands/uninstall_command.rb | 6 +++--- lib/rubygems/indexer.rb | 4 ++-- lib/rubygems/security.rb | 4 ++-- lib/rubygems/security/policy.rb | 6 +++--- lib/rubygems/uninstaller.rb | 4 ++-- .../test_gem_commands_cert_command.rb | 9 ++++----- test/rubygems/test_gem_package.rb | 6 +++--- test/rubygems/test_gem_security.rb | 4 ++-- test/rubygems/test_gem_security_policy.rb | 20 +++++++++---------- 12 files changed, 48 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbfd6d5a46..0b5094d169 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Thu Dec 6 14:26:22 2012 Eric Hodel + + * 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 * lib/rubygems/package.rb: Set rubygems_version before validation. diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index e39c509ef9..2af582177d 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -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 diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 883526c2a5..0b58fa665e 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -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 diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 736574ddff..56aa8ee57f 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -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 diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index 77282f27ef..85c90f7d78 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -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 diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb index bec30e9238..2485729488 100644 --- a/lib/rubygems/security.rb +++ b/lib/rubygems/security.rb @@ -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 diff --git a/lib/rubygems/security/policy.rb b/lib/rubygems/security/policy.rb index d22b7ce5bd..c34b7605c3 100644 --- a/lib/rubygems/security/policy.rb +++ b/lib/rubygems/security/policy.rb @@ -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, diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index b1500b0748..77b312177d 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -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 diff --git a/test/rubygems/test_gem_commands_cert_command.rb b/test/rubygems/test_gem_commands_cert_command.rb index d0af46728e..4adbec5e66 100644 --- a/test/rubygems/test_gem_commands_cert_command.rb +++ b/test/rubygems/test_gem_commands_cert_command.rb @@ -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 diff --git a/test/rubygems/test_gem_package.rb b/test/rubygems/test_gem_package.rb index a9ac053a5c..9a60d97af9 100644 --- a/test/rubygems/test_gem_package.rb +++ b/test/rubygems/test_gem_package.rb @@ -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 diff --git a/test/rubygems/test_gem_security.rb b/test/rubygems/test_gem_security.rb index 7e75548c0f..718b381874 100644 --- a/test/rubygems/test_gem_security.rb +++ b/test/rubygems/test_gem_security.rb @@ -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 diff --git a/test/rubygems/test_gem_security_policy.rb b/test/rubygems/test_gem_security_policy.rb index 4b9978c430..22f5375dbf 100644 --- a/test/rubygems/test_gem_security_policy.rb +++ b/test/rubygems/test_gem_security_policy.rb @@ -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