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

ruby-changes:72131

From: David <ko1@a...>
Date: Sat, 11 Jun 2022 18:43:46 +0900 (JST)
Subject: [ruby-changes:72131] 692fec4e72 (master): [rubygems/rubygems] Simplify `Gem::Security::Exception` handling

https://git.ruby-lang.org/ruby.git/commit/?id=692fec4e72

From 692fec4e727e5635ba03cdae4a08ce5f0d3c953b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 8 Jun 2022 22:08:44 +0200
Subject: [rubygems/rubygems] Simplify `Gem::Security::Exception` handling

These days all these errors are raised as `Gem::Security::Exception` so
there's no need to do any matching on the exception message.

https://github.com/rubygems/rubygems/commit/bd3403da57
---
 lib/bundler/rubygems_integration.rb | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 637307389d..7e1f5ee451 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -206,16 +206,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_integration.rb#L206
     def spec_from_gem(path, policy = nil)
       require "psych"
       gem_from_path(path, security_policies[policy]).spec
-    rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
-      if e.is_a?(Gem::Security::Exception) ||
-          e.message =~ /unknown trust policy|unsigned gem/i ||
-          e.message =~ /couldn't verify (meta)?data signature/i
-        raise SecurityError,
-          "The gem #{File.basename(path, ".gem")} can't be installed because " \
-          "the security policy didn't allow it, with the message: #{e.message}"
-      else
-        raise e
-      end
+    rescue Gem::Security::Exception => e
+      raise SecurityError,
+        "The gem #{File.basename(path, ".gem")} can't be installed because " \
+        "the security policy didn't allow it, with the message: #{e.message}"
     end
 
     def build_gem(gem_dir, spec)
-- 
cgit v1.2.1


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

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