Sha256: 09a631b4ac37aece6f087329ddc176e81c0ba35c7925f4d72926117b6efc9b61

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module CMSScanner
  module Finders
    # Independent Finders container
    # This class is designed to handle independent results
    # which are not related with others
    # e.g: interesting files
    class IndependentFinders < Array
      # @return [ Findings ]
      def findings
        @findings ||= NS::Finders::Findings.new
      end

      # @param [ Hash ] opts
      # @option opts [ Symbol ] mode :mixed, :passive or :aggressive
      #
      # @return [ Findings ]
      def run(opts = {})
        each do |finder|
          symbols_from_mode(opts[:mode]).each do |symbol|
            r = finder.send(symbol, opts)

            next unless r

            findings + [*r]
          end
        end

        findings
      end

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

        return symbols if mode.nil? || mode == :mixed
        symbols.include?(mode) ? [*mode] : []
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cms_scanner-0.0.5 lib/cms_scanner/finders/independent_finders.rb
cms_scanner-0.0.4 lib/cms_scanner/finders/independent_finders.rb
cms_scanner-0.0.3 lib/cms_scanner/finders/independent_finders.rb
cms_scanner-0.0.2 lib/cms_scanner/finders/independent_finders.rb