1
0
Fork 0
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:
drbrain 2012-12-06 05:26:46 +00:00
parent afae107a4c
commit 80ba379c24
12 changed files with 48 additions and 35 deletions

View file

@ -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> Thu Dec 6 14:10:08 2012 Eric Hodel <drbrain@segment7.net>
* lib/rubygems/package.rb: Set rubygems_version before validation. * lib/rubygems/package.rb: Set rubygems_version before validation.

View file

@ -176,8 +176,7 @@ class Gem::CommandManager
if possibilities.size > 1 then if possibilities.size > 1 then
raise Gem::CommandLineError, raise Gem::CommandLineError,
"Ambiguous command #{cmd_name} " \ "Ambiguous command #{cmd_name} matches [#{possibilities.join(', ')}]"
"matches [#{possibilities.join(', ')}]"
elsif possibilities.empty? then elsif possibilities.empty? then
raise Gem::CommandLineError, "Unknown command #{cmd_name}" raise Gem::CommandLineError, "Unknown command #{cmd_name}"
end end

View file

@ -48,7 +48,7 @@ class Gem::Commands::InstallCommand < Gem::Command
end end
def defaults_str # :nodoc: 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}" "--install-dir #{Gem.dir}"
end end

View file

@ -76,8 +76,8 @@ class Gem::Commands::UninstallCommand < Gem::Command
end end
def defaults_str # :nodoc: def defaults_str # :nodoc:
"--version '#{Gem::Requirement.default}' --no-force " \ "--version '#{Gem::Requirement.default}' --no-force " +
"--install-dir #{Gem.dir}\n" \ "--install-dir #{Gem.dir}\n" +
"--user-install" "--user-install"
end end
@ -101,7 +101,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
Gem::Uninstaller.new(gem_name, options).uninstall Gem::Uninstaller.new(gem_name, options).uninstall
rescue Gem::GemNotInHomeException => e rescue Gem::GemNotInHomeException => e
spec = e.spec 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}") "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
end end
end end

View file

@ -54,8 +54,8 @@ class Gem::Indexer
require 'zlib' require 'zlib'
unless defined?(Builder::XChar) then unless defined?(Builder::XChar) then
raise "Gem::Indexer requires that the XML Builder library be installed:" \ raise "Gem::Indexer requires that the XML Builder library be installed:" +
"\n\tgem install builder" "\n\tgem install builder"
end end
options = { :build_modern => true }.merge options options = { :build_modern => true }.merge options

View file

@ -463,7 +463,7 @@ module Gem::Security
def self.re_sign expired_certificate, private_key, age = ONE_YEAR, def self.re_sign expired_certificate, private_key, age = ONE_YEAR,
extensions = EXTENSIONS extensions = EXTENSIONS
raise Gem::Security::Exception, raise Gem::Security::Exception,
"incorrect signing key for re-signing " \ "incorrect signing key for re-signing " +
"#{expired_certificate.subject}" unless "#{expired_certificate.subject}" unless
expired_certificate.public_key.to_pem == private_key.public_key.to_pem 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 issuer = alt_name_or_x509_entry expired_certificate, :issuer
raise Gem::Security::Exception, raise Gem::Security::Exception,
"#{subject} is not self-signed, contact #{issuer} " \ "#{subject} is not self-signed, contact #{issuer} " +
"to obtain a valid certificate" "to obtain a valid certificate"
end end

View file

@ -112,7 +112,7 @@ class Gem::Security::Policy
root = chain.first root = chain.first
raise Gem::Security::Exception, raise Gem::Security::Exception,
"root certificate #{root.subject} is not self-signed " \ "root certificate #{root.subject} is not self-signed " +
"(issuer #{root.issuer})" if "(issuer #{root.issuer})" if
root.issuer.to_s != root.subject.to_s # HACK to_s is for ruby 1.8 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 cert_dgst = digester.digest pkey_str
raise Gem::Security::Exception, raise Gem::Security::Exception,
"trusted root certificate #{root.subject} checksum " \ "trusted root certificate #{root.subject} checksum " +
"does not match signing root certificate checksum" unless "does not match signing root certificate checksum" unless
save_dgst == cert_dgst save_dgst == cert_dgst
@ -152,7 +152,7 @@ class Gem::Security::Policy
end end
def inspect # :nodoc: 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]" % [ "signed-only: %p trusted-only: %p]" % [
@name, @verify_chain, @verify_data, @verify_root, @verify_signer, @name, @verify_chain, @verify_data, @verify_root, @verify_signer,
@only_signed, @only_trusted, @only_signed, @only_trusted,

View file

@ -178,8 +178,8 @@ class Gem::Uninstaller
executables = executables.map { |exec| formatted_program_filename exec } executables = executables.map { |exec| formatted_program_filename exec }
remove = if @force_executables.nil? then remove = if @force_executables.nil? then
ask_yes_no("Remove executables:\n" \ ask_yes_no("Remove executables:\n" +
"\t#{executables.join ', '}\n\n" \ "\t#{executables.join ', '}\n\n" +
"in addition to the gem?", "in addition to the gem?",
true) true)
else else

View file

@ -441,8 +441,7 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
@cmd.handle_options %W[--certificate #{nonexistent}] @cmd.handle_options %W[--certificate #{nonexistent}]
end end
assert_equal "invalid argument: " \ assert_equal "invalid argument: --certificate #{nonexistent}: does not exist",
"--certificate #{nonexistent}: does not exist",
e.message e.message
bad = File.join @tempdir, 'bad' 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}] @cmd.handle_options %W[--certificate #{bad}]
end end
assert_equal "invalid argument: " \ assert_equal "invalid argument: " +
"--certificate #{bad}: invalid X509 certificate", "--certificate #{bad}: invalid X509 certificate",
e.message e.message
end 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}] @cmd.handle_options %W[--private-key #{nonexistent}]
end end
assert_equal "invalid argument: " \ assert_equal "invalid argument: " +
"--private-key #{nonexistent}: does not exist", "--private-key #{nonexistent}: does not exist",
e.message 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}] @cmd.handle_options %W[--private-key #{PUBLIC_KEY_FILE}]
end end
assert_equal "invalid argument: " \ assert_equal "invalid argument: " +
"--private-key #{PUBLIC_KEY_FILE}: private key not found", "--private-key #{PUBLIC_KEY_FILE}: private key not found",
e.message e.message
end end

View file

@ -302,7 +302,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package.extract_tar_gz tgz_io, @destination package.extract_tar_gz tgz_io, @destination
end 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) "#{@destination} is not allowed", e.message)
end end
@ -325,7 +325,7 @@ class TestGemPackage < Gem::Package::TarTestCase
package.install_location '/absolute.rb', @destination package.install_location '/absolute.rb', @destination
end 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) "#{@destination} is not allowed", e.message)
end end
@ -338,7 +338,7 @@ class TestGemPackage < Gem::Package::TarTestCase
parent = File.expand_path File.join @destination, "../relative.rb" 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) "#{@destination} is not allowed", e.message)
end end

View file

@ -129,7 +129,7 @@ class TestGemSecurity < Gem::TestCase
Gem::Security.re_sign CHILD_CERT, CHILD_KEY Gem::Security.re_sign CHILD_CERT, CHILD_KEY
end 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", "#{ALTERNATE_CERT.issuer} to obtain a valid certificate",
e.message e.message
end end
@ -139,7 +139,7 @@ class TestGemSecurity < Gem::TestCase
Gem::Security.re_sign ALTERNATE_CERT, PRIVATE_KEY Gem::Security.re_sign ALTERNATE_CERT, PRIVATE_KEY
end end
assert_equal "incorrect signing key for re-signing " \ assert_equal "incorrect signing key for re-signing " +
"#{ALTERNATE_CERT.subject}", "#{ALTERNATE_CERT.subject}",
e.message e.message
end end

View file

@ -91,8 +91,8 @@ class TestGemSecurityPolicy < Gem::TestCase
@chain.check_chain chain, Time.now @chain.check_chain chain, Time.now
end end
assert_equal "invalid signing chain: " \ assert_equal "invalid signing chain: " +
"certificate #{INVALIDCHILD_CERT.subject} " \ "certificate #{INVALIDCHILD_CERT.subject} " +
"was not issued by #{CHILD_CERT.subject}", e.message "was not issued by #{CHILD_CERT.subject}", e.message
end end
@ -105,7 +105,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@low.check_cert EXPIRED_CERT, nil, Time.now @low.check_cert EXPIRED_CERT, nil, Time.now
end end
assert_equal "certificate #{EXPIRED_CERT.subject} " \ assert_equal "certificate #{EXPIRED_CERT.subject} " +
"not valid after #{EXPIRED_CERT.not_after}", "not valid after #{EXPIRED_CERT.not_after}",
e.message e.message
end end
@ -115,7 +115,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@low.check_cert FUTURE_CERT, nil, Time.now @low.check_cert FUTURE_CERT, nil, Time.now
end end
assert_equal "certificate #{FUTURE_CERT.subject} " \ assert_equal "certificate #{FUTURE_CERT.subject} " +
"not valid before #{FUTURE_CERT.not_before}", "not valid before #{FUTURE_CERT.not_before}",
e.message e.message
end end
@ -125,7 +125,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@low.check_cert INVALID_ISSUER_CERT, PUBLIC_CERT, Time.now @low.check_cert INVALID_ISSUER_CERT, PUBLIC_CERT, Time.now
end end
assert_equal "certificate #{INVALID_ISSUER_CERT.subject} " \ assert_equal "certificate #{INVALID_ISSUER_CERT.subject} " +
"was not issued by #{PUBLIC_CERT.subject}", "was not issued by #{PUBLIC_CERT.subject}",
e.message e.message
end end
@ -143,7 +143,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@almost_no.check_key(PUBLIC_CERT, ALTERNATE_KEY) @almost_no.check_key(PUBLIC_CERT, ALTERNATE_KEY)
end end
assert_equal "certificate #{PUBLIC_CERT.subject} " \ assert_equal "certificate #{PUBLIC_CERT.subject} " +
"does not match the signing key", e.message "does not match the signing key", e.message
end end
@ -160,7 +160,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@chain.check_root chain, Time.now @chain.check_root chain, Time.now
end end
assert_equal "certificate #{INVALID_SIGNER_CERT.subject} " \ assert_equal "certificate #{INVALID_SIGNER_CERT.subject} " +
"was not issued by #{INVALID_SIGNER_CERT.issuer}", "was not issued by #{INVALID_SIGNER_CERT.issuer}",
e.message e.message
end end
@ -172,7 +172,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@chain.check_root chain, Time.now @chain.check_root chain, Time.now
end 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})", "is not self-signed (issuer #{INVALID_ISSUER_CERT.issuer})",
e.message e.message
end end
@ -196,7 +196,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@high.check_trust [WRONG_KEY_CERT], @sha1, @trust_dir @high.check_trust [WRONG_KEY_CERT], @sha1, @trust_dir
end 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 "does not match signing root certificate checksum", e.message
end end
@ -213,7 +213,7 @@ class TestGemSecurityPolicy < Gem::TestCase
@high.check_trust [PUBLIC_CERT, CHILD_CERT], @sha1, @trust_dir @high.check_trust [PUBLIC_CERT, CHILD_CERT], @sha1, @trust_dir
end 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 "(root of signing cert #{CHILD_CERT.subject})", e.message
end end