lib/cms_scanner.rb in cms_scanner-0.0.41.6 vs lib/cms_scanner.rb in cms_scanner-0.0.41.7

- old
+ new

@@ -15,14 +15,12 @@ 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 -require 'cms_scanner/progressbar_null_output' # Custom Libs require 'cms_scanner/helper' require 'cms_scanner/exit_code' require 'cms_scanner/errors/http' require 'cms_scanner/errors/scan' @@ -34,10 +32,11 @@ require 'cms_scanner/controllers' require 'cms_scanner/formatter' require 'cms_scanner/references' require 'cms_scanner/finders' require 'cms_scanner/vulnerability' +require 'cms_scanner/progressbar_null_output' # Module module CMSScanner APP_DIR = Pathname.new(__FILE__).dirname.join('..', 'app').expand_path NS = self @@ -166,20 +165,27 @@ controllers.first.datastore end # Hook to be able to have an exit code returned # depending on the findings / errors + # :nocov: def exit_hook + # Avoid hooking the exit when rspec is running, otherwise it will always return 0 + # and Travis won't detect failed builds. Couldn't find a better way, even though + # some people managed to https://github.com/rspec/rspec-core/pull/410 + return if defined?(RSpec) + at_exit do exit(run_error_exit_code) if run_error controller = controllers.first # The parsed_option[:url] must be checked to avoid raising erros when only -h/-v are given exit(NS::ExitCode::VULNERABLE) if controller.parsed_options[:url] && controller.target.vulnerable? exit(NS::ExitCode::OK) end end + # :nocov: # @return [ Integer ] The exit code related to the run_error def run_error_exit_code return NS::ExitCode::CLI_OPTION_ERROR if run_error.is_a?(OptParseValidator::Error) || run_error.is_a?(OptionParser::ParseError)