Sha256: 029efbcfa4b851125285be2e83d5fb87c0568b123791de50f03415ccce50a0d1

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

require_relative 'core/cli_options'

module CMSScanner
  module Controller
    # Core Controller
    class Core < Base
      def setup_cache
        return unless parsed_options[:cache_dir]

        storage_path = File.join(parsed_options[:cache_dir], Digest::MD5.hexdigest(target.url))

        Typhoeus::Config.cache = Cache::Typhoeus.new(storage_path)
        Typhoeus::Config.cache.clean if parsed_options[:clear_cache]
      end

      def before_scan
        setup_cache

        fail "The url supplied '#{target.url}' seems to be down" unless target.online?

        fail HTTPAuthRequiredError if target.http_auth?
        fail ProxyAuthRequiredError if target.proxy_auth?

        # TODO: ask if the redirection should be followed
        # if user_interaction? is allowed (if followed, the Cache#storage_path should be updated)
        redirection = target.redirection
        fail "The url supplied redirects to #{redirection}" if redirection
      end

      def run
        @start_time   = Time.now
        @start_memory = memory_usage

        output('started', url: target.url)
      end

      def after_scan
        @stop_time   = Time.now
        @elapsed     = @stop_time - @start_time
        @used_memory = memory_usage - @start_memory

        output('finished')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cms_scanner-0.0.9 app/controllers/core.rb
cms_scanner-0.0.8 app/controllers/core.rb
cms_scanner-0.0.7 app/controllers/core.rb
cms_scanner-0.0.6 app/controllers/core.rb
cms_scanner-0.0.5 app/controllers/core.rb
cms_scanner-0.0.4 app/controllers/core.rb
cms_scanner-0.0.3 app/controllers/core.rb
cms_scanner-0.0.2 app/controllers/core.rb