Class: CMSScanner::Controller::Base

Inherits:
Object
  • Object
show all
Includes:
OptParseValidator
Defined in:
lib/cms_scanner/controller.rb

Overview

Base Controller

Direct Known Subclasses

Core, InterestingFindings

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parsed_options=(options) ⇒ Object

Set the parsed options and initialize the browser with them

Parameters:

  • options (Hash)


38
39
40
41
42
# File 'lib/cms_scanner/controller.rb', line 38

def self.parsed_options=(options)
  @@parsed_options = options

  NS::Browser.instance(options)
end

.resetObject

Reset all the class attibutes Currently only used in specs



22
23
24
25
26
27
# File 'lib/cms_scanner/controller.rb', line 22

def self.reset
  @@target         = nil
  @@parsed_options = nil
  @@datastore      = nil
  @@formatter      = nil
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/cms_scanner/controller.rb', line 16

def ==(other)
  self.class == other.class
end

#after_scanObject



14
# File 'lib/cms_scanner/controller.rb', line 14

def after_scan; end

#before_scanObject



10
# File 'lib/cms_scanner/controller.rb', line 10

def before_scan; end

#cli_optionsArray<OptParseValidator::OptBase>

Returns:

  • (Array<OptParseValidator::OptBase>)


8
# File 'lib/cms_scanner/controller.rb', line 8

def cli_options; end

#datastoreHash

Returns:

  • (Hash)


50
51
52
# File 'lib/cms_scanner/controller.rb', line 50

def datastore
  @@datastore ||= {}
end

#formatterFormatter::Base

Returns:



55
56
57
# File 'lib/cms_scanner/controller.rb', line 55

def formatter
  @@formatter ||= NS::Formatter.load(parsed_options[:format], datastore[:views])
end

#output(tpl, vars = {}) ⇒ Void

Returns:

  • (Void)

See Also:

  • Formatter#output


62
63
64
# File 'lib/cms_scanner/controller.rb', line 62

def output(tpl, vars = {})
  formatter.output(*tpl_params(tpl, vars))
end

#parsed_optionsHash

Returns:

  • (Hash)


45
46
47
# File 'lib/cms_scanner/controller.rb', line 45

def parsed_options
  @@parsed_options ||= {}
end

#render(tpl, vars = {}) ⇒ String

Returns:

  • (String)

See Also:

  • Formatter#render


69
70
71
# File 'lib/cms_scanner/controller.rb', line 69

def render(tpl, vars = {})
  formatter.render(*tpl_params(tpl, vars))
end

#runObject



12
# File 'lib/cms_scanner/controller.rb', line 12

def run; end

#targetTarget

Returns:



30
31
32
# File 'lib/cms_scanner/controller.rb', line 30

def target
  @@target ||= NS::Target.new(parsed_options[:url], parsed_options)
end

#tmp_directoryString

Returns:

  • (String)


79
80
81
# File 'lib/cms_scanner/controller.rb', line 79

def tmp_directory
  File.join('/tmp', NS.app_name)
end

#user_interaction?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/cms_scanner/controller.rb', line 74

def user_interaction?
  formatter.user_interaction? && !parsed_options[:output]
end