rapid7/metasploit-framework

View on GitHub
lib/msf/core/handler/reverse_http.rb

Summary

Maintainability
D
2 days
Test Coverage

Method on_request has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

  def on_request(cli, req)
    Thread.current[:cli] = cli
    resp = Rex::Proto::Http::Response.new
    info = process_uri_resource(req.relative_resource)
    uuid = info[:uuid]
Severity: Minor
Found in lib/msf/core/handler/reverse_http.rb - About 6 hrs 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 on_request has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def on_request(cli, req)
    Thread.current[:cli] = cli
    resp = Rex::Proto::Http::Response.new
    info = process_uri_resource(req.relative_resource)
    uuid = info[:uuid]
Severity: Major
Found in lib/msf/core/handler/reverse_http.rb - About 3 hrs to fix

    File reverse_http.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rex/io/stream_abstraction'
    require 'rex/sync/ref'
    
    require 'rex/post/meterpreter/core_ids'
    require 'rex/socket/x509_certificate'
    Severity: Minor
    Found in lib/msf/core/handler/reverse_http.rb - About 3 hrs to fix

      Method initialize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(info = {})
          super
      
          register_options(
            [
      Severity: Minor
      Found in lib/msf/core/handler/reverse_http.rb - About 1 hr to fix

        Method setup_handler has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def setup_handler
        
            local_addr = nil
            local_port = bind_port
            ex = false
        Severity: Minor
        Found in lib/msf/core/handler/reverse_http.rb - About 1 hr to fix

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

            def payload_uri(req=nil)
              callback_host = nil
              callback_scheme = nil
          
              # Extract whatever the client sent us in the Host header
          Severity: Minor
          Found in lib/msf/core/handler/reverse_http.rb - About 1 hr to fix

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

              def payload_uri(req=nil)
                callback_host = nil
                callback_scheme = nil
            
                # Extract whatever the client sent us in the Host header
            Severity: Minor
            Found in lib/msf/core/handler/reverse_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 lookup_proxy_settings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def lookup_proxy_settings
                info = {}
                return @proxy_settings if @proxy_settings
            
                if datastore['HttpProxyHost'].to_s == ''
            Severity: Minor
            Found in lib/msf/core/handler/reverse_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 lookup_proxy_settings has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def lookup_proxy_settings
                info = {}
                return @proxy_settings if @proxy_settings
            
                if datastore['HttpProxyHost'].to_s == ''
            Severity: Minor
            Found in lib/msf/core/handler/reverse_http.rb - About 1 hr to fix

              Method setup_handler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def setup_handler
              
                  local_addr = nil
                  local_port = bind_port
                  ex = false
              Severity: Minor
              Found in lib/msf/core/handler/reverse_http.rb - About 55 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

              Method luri has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def luri
                  l = datastore['LURI'] || ""
              
                  if l && l.length > 0
                    # strip trailing slashes
              Severity: Minor
              Found in lib/msf/core/handler/reverse_http.rb - About 35 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