rapid7/metasploit-framework

View on GitHub
modules/auxiliary/server/local_hwbridge.rb

Summary

Maintainability
F
3 days
Test Coverage

Method isotp_send_and_wait has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

  def isotp_send_and_wait(bus, srcid, dstid, data, opt = {})
    result = {}
    result["Success"] = false
    srcid = srcid.to_i(16).to_s(16)
    dstid = dstid.to_i(16).to_s(16)
Severity: Minor
Found in modules/auxiliary/server/local_hwbridge.rb - About 1 day 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_uri has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

  def on_request_uri(cli, request)
    if request.uri =~ /status$/i
      print_status("Sending status...") if datastore['VERBOSE']
      send_response_html(cli, get_status().to_json(), { 'Content-Type' => 'application/json' })
    elsif request.uri =~ /statistics$/i
Severity: Minor
Found in modules/auxiliary/server/local_hwbridge.rb - About 7 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 isotp_send_and_wait has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def isotp_send_and_wait(bus, srcid, dstid, data, opt = {})
    result = {}
    result["Success"] = false
    srcid = srcid.to_i(16).to_s(16)
    dstid = dstid.to_i(16).to_s(16)
Severity: Major
Found in modules/auxiliary/server/local_hwbridge.rb - About 2 hrs to fix

    File local_hwbridge.rb has 263 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Auxiliary
      include Msf::Exploit::Remote::HttpServer::HTML
      include Msf::Auxiliary::Report
    
      HWBRIDGE_API_VERSION = "0.0.4"
    Severity: Minor
    Found in modules/auxiliary/server/local_hwbridge.rb - About 2 hrs to fix

      Method on_request_uri has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def on_request_uri(cli, request)
          if request.uri =~ /status$/i
            print_status("Sending status...") if datastore['VERBOSE']
            send_response_html(cli, get_status().to_json(), { 'Content-Type' => 'application/json' })
          elsif request.uri =~ /statistics$/i
      Severity: Minor
      Found in modules/auxiliary/server/local_hwbridge.rb - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

            elsif request.uri =~ /custom_methods$/i
              print_status("Sending custom methods") if datastore['VERBOSE']
              send_response_html(cli, get_custom_methods().to_json(), { 'Content-Type' => 'application/json' })
            elsif request.uri =~ /custom\/sample_cmd\?data=(\S+)$/
              print_status("Request for custom command with args #{$1}") if datastore['VERBOSE']
        Severity: Major
        Found in modules/auxiliary/server/local_hwbridge.rb - About 45 mins to fix

          Method cansend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def cansend(bus, id, data)
              result = {}
              result["Success"] = false
              id = id.to_i(16).to_s(16)  # Clean up the HEX
              bytes = data.scan(/../)  # Break up data string into 2 char (byte) chunks
          Severity: Minor
          Found in modules/auxiliary/server/local_hwbridge.rb - About 45 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

          Avoid deeply nested control flow statements.
          Open

                print_status("Sending Timezone") if datastore['VERBOSE']
          Severity: Major
          Found in modules/auxiliary/server/local_hwbridge.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if result["Packets"][0]["DATA"][0] == "10"
                            system("cansend #{bus} #{srcid}#3000000000000000")
                            candump(bus, dstid, timeout, maxpkts)
                            @packets_sent += 1
                            @last_sent = Time.now.to_i
            Severity: Major
            Found in modules/auxiliary/server/local_hwbridge.rb - About 45 mins to fix

              Method isotp_send_and_wait has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def isotp_send_and_wait(bus, srcid, dstid, data, opt = {})
              Severity: Minor
              Found in modules/auxiliary/server/local_hwbridge.rb - About 35 mins to fix

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                    super(update_info(info,
                      'Name'        => 'Hardware Bridge Server',
                      'Description' => %q{
                          This module sets up a web server to bridge communications between
                        Metasploit and physically attached hardware.
                Severity: Minor
                Found in modules/auxiliary/server/local_hwbridge.rb and 3 other locations - About 15 mins to fix
                modules/auxiliary/server/capture/http_basic.rb on lines 11..34
                modules/auxiliary/server/capture/http_ntlm.rb on lines 16..34
                modules/auxiliary/server/http_ntlmrelay.rb on lines 24..51

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 25.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status