Module: Bundler::Security

Defined in:
lib/bundler/security.rb,
lib/bundler/security/errors.rb,
lib/bundler/security/voting.rb,
lib/bundler/security/version.rb,
lib/bundler/security/commands.rb,
lib/bundler/security/config/fetcher.rb,
lib/bundler/security/voting/request.rb,
lib/bundler/security/voting/gem_policy.rb,
lib/bundler/security/config/file_finder.rb,
lib/bundler/security/voting/build_failure.rb,
lib/bundler/security/voting/build_success.rb,
lib/bundler/security/voting/remote_policy.rb,
lib/bundler/security/voting/versions/local.rb,
lib/bundler/security/voting/versions/remote.rb,
lib/bundler/security/voting/build_unsafe_gem.rb

Overview

Plugin responsible for safe gem installation

Defined Under Namespace

Modules: Commands, Config, Errors, Voting

Constant Summary collapse

VERSION =

Current BundlerSecurity version

'0.1.1'
HOMEPAGE =

Coditsu differ homepage

'https://diff.coditsu.io'

Class Method Summary collapse

Class Method Details

.build_definitionBundler::Definition

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

Returns:

  • (Bundler::Definition)


49
50
51
52
53
54
55
56
57
# File 'lib/bundler/security.rb', line 49

def build_definition
  Bundler.configure

  Bundler::Definition.build(
    Bundler.default_gemfile,
    Bundler.default_lockfile,
    true
  )
end

.commandString

Command that was run with bundle

Returns:

  • (String)


62
63
64
65
66
# File 'lib/bundler/security.rb', line 62

def command
  ARGV
    .first
    .then { |value| value || Bundler::Security::Commands::INSTALL }
end

.registerObject

Registers the plugin and add before install all hook



33
34
35
36
37
38
39
40
41
42
43
44
# 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