Skip to content

Commit

Permalink
Move security exception handling to the only place using it
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Jun 9, 2022
1 parent 600a9ac commit ba975b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions bundler/lib/bundler/rubygems_integration.rb
Expand Up @@ -205,10 +205,6 @@ def ext_lock

def spec_from_gem(path, policy = nil)
gem_from_path(path, security_policies[policy]).spec
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)
Expand Down
4 changes: 4 additions & 0 deletions bundler/lib/bundler/source/rubygems.rb
Expand Up @@ -157,6 +157,10 @@ def install(spec, options = {})
path = fetch_gem(spec, options[:previous_spec])
begin
s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
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}"
rescue Gem::Package::FormatError
Bundler.rm_rf(path)
raise
Expand Down

0 comments on commit ba975b3

Please sign in to comment.