lib/cms_scanner.rb in cms_scanner-0.0.41.9 vs lib/cms_scanner.rb in cms_scanner-0.0.41.10
- old
+ new
@@ -15,10 +15,11 @@
require 'pathname'
require 'timeout'
require 'xmlrpc/client'
# Monkey Patches
require 'cms_scanner/typhoeus/response' # Adds a Response#html using Nokogiri to parse the body
+require 'cms_scanner/typhoeus/hydra' # https://github.com/typhoeus/typhoeus/issues/439
require 'cms_scanner/public_suffix/domain' # Adds a Domain#match method and logic, used in scope stuff
require 'cms_scanner/numeric' # Adds a Numeric#bytes_to_human
# Custom Libs
require 'cms_scanner/helper'
require 'cms_scanner/exit_code'
@@ -39,10 +40,14 @@
# Module
module CMSScanner
APP_DIR = Pathname.new(__FILE__).dirname.join('..', 'app').expand_path
NS = self
+ # Avoid memory leak when using Hydra, see https://github.com/typhoeus/typhoeus/issues/562
+ # Requests are still cached via the provided Cache system
+ Typhoeus::Config.memoize = false
+
# Number of requests performed and data sent/received to display at the end of the scan
Typhoeus.on_complete do |response|
self.cached_requests += 1 if response.cached?
next if response.cached?
@@ -147,10 +152,10 @@
reason: e.is_a?(Interrupt) ? 'Canceled by User' : e.message,
trace: e.backtrace,
verbose: controllers.first.parsed_options[:verbose] ||
run_error_exit_code == NS::ExitCode::EXCEPTION)
ensure
- # Browser.instance.hydra.abort
+ Browser.instance.hydra.abort
formatter.beautify
end
# Used for convenience