Sha256: a36915140883acdc26ffc940cbf06f8d4cffdfaf11993f2aaedddd915b7cedfc

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

module CMSScanner
  module Finders
    # Base class container for the Finders (i.e IndependentFinders etc)
    class BaseFinders < Array
      # @return [ Findings ]
      def findings
        @findings ||= NS::Finders::Findings.new
      end

      # Should be implemented in child classes
      def run; end

      protected

      # @param [ Symbol ] mode :mixed, :passive or :aggressive
      # @return [ Array<Symbol> ] The symbols to call for the mode
      def symbols_from_mode(mode)
        symbols = %i[passive aggressive]

        return symbols if mode.nil? || mode == :mixed

        symbols.include?(mode) ? [*mode] : []
      end

      # @param [ CMSScanner::Finders::Finder ] finder
      # @param [ Symbol ] symbol See return values of #symbols_from_mode
      # @param [ Hash ] opts
      def run_finder(finder, symbol, opts)
        [*finder.send(symbol, opts.merge(found: findings))].compact.each do |found|
          findings << found
        end
      end

      # Allow child classes to filter the findings, such as return the best one
      # or remove the low confidence ones.
      #
      # @return [ Findings ]
      def filter_findings
        findings
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cms_scanner-0.0.41.10 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.9 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.8 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.7 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.6 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.5 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.4 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.3 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.2 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.1 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.41.0 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.40.3 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.40.2 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.40.1 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.40 lib/cms_scanner/finders/base_finders.rb