Class: Pentest::Commandline

Inherits:
Object
  • Object
show all
Defined in:
lib/pentest/commandline.rb

Overview

Implements Command-Line Interface of Pentest

Class Method Summary collapse

Class Method Details

.create_option_parser(options) ⇒ Object



34
35
36
37
38
# File 'lib/pentest/commandline.rb', line 34

def create_option_parser options
  OptionParser.new do |opts|
    opts.banner = "Usage: pentest [options] rails/root/path"
  end
end

.get_optionsObject



27
28
29
30
31
32
# File 'lib/pentest/commandline.rb', line 27

def get_options
  options = {}
  parser = create_option_parser options
  args = parser.parse! ARGV
  [options, args]
end

.run(default_app_path = ".") ⇒ Object

Runs everything:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pentest/commandline.rb', line 9

def run default_app_path = "."
  options, args = get_options

  if args.size >= 1
    options[:app_path] = args[0]
  else
    options[:app_path] = default_app_path
  end

  result = Pentest.run options.merge(:print_report => true)

  if result.nil?
    exit 0
  else
    exit 1
  end
end