Module: Bundler::Security::Voting::BuildFailure

Defined in:
lib/bundler/security/voting/build_failure.rb

Overview

Build failure security verdict

Class Method Summary collapse

Class Method Details

.build(policy_type, command, errors) ⇒ String

Builds failure security verdict message

Parameters:

  • policy_type (String)
  • command (String)

    either install or update

  • errors (Array)

    detected security errors

Returns:

  • (String)


27
28
29
30
31
32
33
34
35
36
# File 'lib/bundler/security/voting/build_failure.rb', line 27

def build(policy_type, command, errors)
  [
    "\n",
    message_type(policy_type),
    ", blocking #{command}",
    "\n\n",
    errors.join("\n"),
    "\n\n"
  ].join
end

.call(policy_type, command, errors) ⇒ Object

Prints failure security verdict

Parameters:

  • policy_type (String)
  • command (String)

    either install or update

  • errors (Array)

    detected security errors



14
15
16
17
18
# File 'lib/bundler/security/voting/build_failure.rb', line 14

def call(policy_type, command, errors)
  Bundler.ui.error(
    build(policy_type, command, errors)
  )
end

.message_type(policy_type) ⇒ String

Builds a message based on policy type

Parameters:

  • policy_type (String)

Returns:

  • (String)

Raises:

  • InvalidPolicyType if policy type was not recognized



45
46
47
48
49
50
51
52
53
54
# File 'lib/bundler/security/voting/build_failure.rb', line 45

def message_type(policy_type)
  case policy_type
  when 'organization'
    'Not enough reviews on your organization'
  when 'community'
    'Not enough reviews in the community'
  else
    raise InvalidPolicyType, policy_type
  end
end