Class: PolishGeeks::DevTools::Commands::Brakeman

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/brakeman.rb

Overview

A static analysis security vulnerability scanner for Ruby on Rails applications

Constant Summary collapse

REGEXPS =

Regexps to get some stat info from brakeman output

{
  controllers: /Controller.* (\d+)/,
  models: /Model.* (\d+)/,
  templates: /Template.* (\d+)/,
  errors: /Error.* (\d+)/,
  warnings: /Warning.* (\d+)/
}.freeze

Constants inherited from Base

PolishGeeks::DevTools::Commands::Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!, #error_message

Instance Method Details

#executeString

Executes this command

Returns:

  • (String)

    command output



24
25
26
27
28
# File 'lib/polish_geeks/dev_tools/commands/brakeman.rb', line 24

def execute
  cmd = ['bundle exec brakeman -q']
  cmd << "-c #{self.class.config_manager.path}" if self.class.config_manager.present?
  @output = Shell.new.execute(cmd.join(' '))
end

#labelString

Returns label with details bout brakeman scan.

Returns:

  • (String)

    label with details bout brakeman scan



36
37
38
# File 'lib/polish_geeks/dev_tools/commands/brakeman.rb', line 36

def label
  "Brakeman (#{controllers} con, #{models} mod, #{templates} temp)"
end

#valid?Boolean

Returns true if we didn’t have any vulnerabilities detected.

Returns:

  • (Boolean)

    true if we didn’t have any vulnerabilities detected



31
32
33
# File 'lib/polish_geeks/dev_tools/commands/brakeman.rb', line 31

def valid?
  warnings.zero? && errors.zero?
end