rapid7/metasploit-framework

View on GitHub
lib/metasploit/framework/login_scanner/http.rb

Summary

Maintainability
C
1 day
Test Coverage

File http.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'metasploit/framework/login_scanner/base'
require 'metasploit/framework/login_scanner/rex_socket'

module Metasploit
  module Framework
Severity: Minor
Found in lib/metasploit/framework/login_scanner/http.rb - About 2 hrs to fix

    Method configure_http_client has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def configure_http_client(http_client)
              http_client.set_config(
                'vhost'                  => vhost || host,
                'agent'                  => user_agent
              )
    Severity: Minor
    Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

      Method attempt_login has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def attempt_login(credential)
                result_opts = {
                  credential: credential,
                  status: Metasploit::Model::Login::Status::INCORRECT,
                  proof: nil,
      Severity: Minor
      Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

        Method create_client has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def create_client(opts)
                  rhost           = opts['host'] || host
                  rport           = opts['rport'] || port
                  cli_ssl         = opts['ssl'] || ssl
                  cli_ssl_version = opts['ssl_version'] || ssl_version
        Severity: Minor
        Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

          Method create_client has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  def create_client(opts)
                    rhost           = opts['host'] || host
                    rport           = opts['rport'] || port
                    cli_ssl         = opts['ssl'] || ssl
                    cli_ssl_version = opts['ssl_version'] || ssl_version
          Severity: Minor
          Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method attempt_login has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def attempt_login(credential)
                    result_opts = {
                      credential: credential,
                      status: Metasploit::Model::Login::Status::INCORRECT,
                      proof: nil,
          Severity: Minor
          Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method set_sane_defaults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def set_sane_defaults
                    self.connection_timeout ||= 20
                    self.uri = '/' if self.uri.blank?
                    self.method = 'GET' if self.method.blank?
                    self.http_success_codes = DEFAULT_HTTP_SUCCESS_CODES if self.http_success_codes.nil?
          Severity: Minor
          Found in lib/metasploit/framework/login_scanner/http.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method validate_http_codes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def validate_http_codes
                    errors.add(:http_success_codes, "HTTP codes must be an Array") unless @http_success_codes.is_a?(Array)
                    @http_success_codes.each do |code|
                      next if code >= 200 && code < 400
                      errors.add(:http_success_codes, "Invalid HTTP code provided #{code}")
          Severity: Minor
          Found in lib/metasploit/framework/login_scanner/http.rb - About 25 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          There are no issues that match your filters.

          Category
          Status