Sha256: 2afe23dd2008677f508f244bbb65888efa2edd448e52ecc34152f4d038eb510c

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module CMSScanner
  module Finders
    # Independent Finders container
    # This class is designed to handle independent results
    # which are not related with each 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|
            [*finder.send(symbol, opts)].compact.each do |found|
              findings << found
            end
          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

3 entries across 3 versions & 1 rubygems

Version Path
cms_scanner-0.0.15 lib/cms_scanner/finders/independent_finders.rb
cms_scanner-0.0.14 lib/cms_scanner/finders/independent_finders.rb
cms_scanner-0.0.13 lib/cms_scanner/finders/independent_finders.rb