module Bundler::Security

Plugin responsible for safe gem installation

Constants

HOMEPAGE

Coditsu differ homepage

VERSION

Current BundlerSecurity version

Public Class Methods

build_definition() click to toggle source

Build clean instance of bundler definition, as we don't want to pollute the main one

@return [Bundler::Definition]

# File lib/bundler/security.rb, line 49
def build_definition
  Bundler.configure

  Bundler::Definition.build(
    Bundler.default_gemfile,
    Bundler.default_lockfile,
    true
  )
end
command() click to toggle source

Command that was run with bundle

@return [String]

# File lib/bundler/security.rb, line 62
def command
  ARGV
    .first
    .then { |value| value || Bundler::Security::Commands::INSTALL }
end
register() click to toggle source

Registers the plugin and add before install all hook

# File lib/bundler/security.rb, line 33
def register
  return if defined?(@registered) && @registered

  @registered = true

  Bundler::Plugin.add_hook('before-install-all') do |_|
    Bundler::Security::Voting.call(
      command,
      build_definition
    )
  end
end