Sha256: 0572be410a20b948e4984d4de5ebb880920fa03994c4b099f9551014b9ee423e

Contents?: true

Size: 1.18 KB

Versions: 13

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

13 entries across 13 versions & 1 rubygems

Version Path
cms_scanner-0.0.39.4 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.39.3 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.39.2 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.39.1 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.39.0 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.38.4 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.38.3 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.38.2 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.38.1 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.38.0 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.37.12 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.37.11 lib/cms_scanner/finders/base_finders.rb
cms_scanner-0.0.37.10 lib/cms_scanner/finders/base_finders.rb