lib/cms_scanner/errors/http.rb in cms_scanner-0.0.41.10 vs lib/cms_scanner/errors/http.rb in cms_scanner-0.0.42.0

- old
+ new

@@ -1,70 +1,71 @@ +# frozen_string_literal: true + module CMSScanner - class Error < StandardError - end + module Error + # Target Down Error + class TargetDown < Standard + attr_reader :response - # Target Down Error - class TargetDownError < Error - attr_reader :response + def initialize(response) + @response = response + end - def initialize(response) - @response = response + def to_s + "The url supplied '#{response.request.url}' seems to be down (#{response.return_message})" + end end - def to_s - "The url supplied '#{response.request.url}' seems to be down (#{response.return_message})" + # HTTP Authentication Required Error + class HTTPAuthRequired < Standard + # :nocov: + def to_s + 'HTTP authentication required (or was invalid), please provide it with --http-auth' + end + # :nocov: end - end - # HTTP Authentication Required Error - class HTTPAuthRequiredError < Error - # :nocov: - def to_s - 'HTTP authentication required (or was invalid), please provide it with --http-auth' + # Proxy Authentication Required Error + class ProxyAuthRequired < Standard + # :nocov: + def to_s + 'Proxy authentication required (or was invalid), please provide it with --proxy-auth' + end + # :nocov: end - # :nocov: - end - # Proxy Authentication Required Error - class ProxyAuthRequiredError < Error - # :nocov: - def to_s - 'Proxy authentication required (or was invalid), please provide it with --proxy-auth' - end - # :nocov: - end + # Access Forbidden Error + class AccessForbidden < Standard + attr_reader :random_user_agent_used - # Access Forbidden Error - class AccessForbiddenError < Error - attr_reader :random_user_agent_used + # @param [ Boolean ] random_user_agent_used + def initialize(random_user_agent_used) + @random_user_agent_used = random_user_agent_used + end - # @param [ Boolean ] random_user_agent_used - def initialize(random_user_agent_used) - @random_user_agent_used = random_user_agent_used - end + def to_s + msg = if random_user_agent_used + 'Well... --random-user-agent didn\'t work, you\'re on your own now!' + else + 'Please re-try with --random-user-agent' + end - def to_s - msg = if random_user_agent_used - 'Well... --random-user-agent didn\'t work, you\'re on your own now!' - else - 'Please re-try with --random-user-agent' - end - - "The target is responding with a 403, this might be due to a WAF. #{msg}" + "The target is responding with a 403, this might be due to a WAF. #{msg}" + end end - end - # HTTP Redirect Error - class HTTPRedirectError < Error - attr_reader :redirect_uri + # HTTP Redirect Error + class HTTPRedirect < Standard + attr_reader :redirect_uri - # @param [ String ] url - def initialize(url) - @redirect_uri = Addressable::URI.parse(url).normalize - end + # @param [ String ] url + def initialize(url) + @redirect_uri = Addressable::URI.parse(url).normalize + end - def to_s - "The URL supplied redirects to #{redirect_uri}. Use the --ignore-main-redirect "\ - 'option to ignore the redirection and scan the target.' + def to_s + "The URL supplied redirects to #{redirect_uri}. Use the --ignore-main-redirect "\ + 'option to ignore the redirection and scan the target.' + end end end end