Sha256: dac48978981a6a4ffe84e6b9f298c3c30631778f5f92d48697ba4ebb1a213d57

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'cms_scanner/mocked_progress_bar'
require 'cms_scanner/finders/finder/smart_url_checker'
require 'cms_scanner/finders/finder/enumerator'
require 'cms_scanner/finders/finder/fingerprinter'

module CMSScanner
  module Finders
    # Finder
    class Finder
      # Constants for common found_by
      DIRECT_ACCESS = 'Direct Access (Aggressive Detection)'.freeze

      attr_accessor :target, :progress_bar

      def initialize(target)
        @target = target
      end

      # @return [ String ] The titleized name of the finder
      def titleize
        self.class.to_s.demodulize.underscore.titleize
      end

      # @param [ Hash ] _opts
      def passive(_opts = {}); end

      # @param [ Hash ] _opts
      def aggressive(_opts = {}); end

      # @param [ Hash ] opts See https://github.com/jfelchner/ruby-progressbar/wiki/Options
      # @option opts [ Boolean ] :show_progression
      #
      # @return [ ProgressBar::Base, CMSScanner::MockedProgressBar ]
      def create_progress_bar(opts = {})
        klass = opts[:show_progression] ? ProgressBar : MockedProgressBar

        @progress_bar = klass.create({ format: '%t %a <%B> (%c / %C) %P%% %e' }.merge(opts))
      end

      # @return [ Browser ]
      def browser
        @browser ||= NS::Browser.instance
      end

      # @return [ Typhoeus::Hydra ]
      def hydra
        @hydra ||= browser.hydra
      end

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

          next unless %w[aggressive passive].include? label

          return "#{titleize} (#{label.capitalize} Detection)"
        end
        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cms_scanner-0.0.37.12 lib/cms_scanner/finders/finder.rb
cms_scanner-0.0.37.11 lib/cms_scanner/finders/finder.rb
cms_scanner-0.0.37.10 lib/cms_scanner/finders/finder.rb