class CMSScanner::Finders::Finder

Finder

Constants

DIRECT_ACCESS

Constants for common found_by

Attributes

progress_bar[RW]
target[RW]

Public Class Methods

new(target) click to toggle source
# File lib/cms_scanner/finders/finder.rb, line 17
def initialize(target)
  @target = target
end

Public Instance Methods

aggressive(_opts = {}) click to toggle source

@param [ Hash ] _opts

# File lib/cms_scanner/finders/finder.rb, line 34
def aggressive(_opts = {}); end
browser() click to toggle source

@return [ Browser ]

# File lib/cms_scanner/finders/finder.rb, line 48
def browser
  @browser ||= NS::Browser.instance
end
create_progress_bar(opts = {}) click to toggle source

@param [ Hash ] opts See github.com/jfelchner/ruby-progressbar/wiki/Options @option opts [ Boolean ] :show_progression

@return [ ProgressBar::Base ]

# File lib/cms_scanner/finders/finder.rb, line 40
def create_progress_bar(opts = {})
  bar_opts          = { format: '%t %a <%B> (%c / %C) %P%% %e' }
  bar_opts[:output] = ProgressBarNullOutput unless opts[:show_progression]

  @progress_bar = ::ProgressBar.create(bar_opts.merge(opts))
end
found_by(klass = self.class) click to toggle source

@param [String, Class ] klass @return [ String ]

# File lib/cms_scanner/finders/finder.rb, line 59
def found_by(klass = self.class)
  labels = %w[aggressive passive]

  caller_locations.each do |call|
    label = call.label

    next unless labels.include? label

    title = klass.to_s.demodulize.gsub(/(\d+)[a-z]+/i, '_\0').titleize(keep_id_suffix: true)

    return "#{title} (#{label.capitalize} Detection)"
  end
  nil
end
hydra() click to toggle source

@return [ Typhoeus::Hydra ]

# File lib/cms_scanner/finders/finder.rb, line 53
def hydra
  @hydra ||= browser.hydra
end
passive(_opts = {}) click to toggle source

@param [ Hash ] _opts

# File lib/cms_scanner/finders/finder.rb, line 31
def passive(_opts = {}); end
titleize() click to toggle source

@return [ String ] The titleized name of the finder

# File lib/cms_scanner/finders/finder.rb, line 22
def titleize
  # Put a _ char before any digits except those at the end, which will be replaced by a space
  # Otherwise, class such as Error404Page are returned as Error404 Page instead of Error 404 page
  # The keep_id_suffix is to concevert classes such as CssId to Css Id instead of Css

  @titleize ||= self.class.to_s.demodulize.gsub(/(\d+)[a-z]+/i, '_\0').titleize(keep_id_suffix: true)
end