rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/smb/smb_version.rb

Summary

Maintainability
D
2 days
Test Coverage

Method run_host has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  def run_host(ip)
    if datastore['RPORT'].blank? || datastore['RPORT'] == 0
      smb_services = [
        { port: 445, direct: true },
        { port: 139, direct: false }
Severity: Minor
Found in modules/auxiliary/scanner/smb/smb_version.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 run_host has 127 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run_host(ip)
    if datastore['RPORT'].blank? || datastore['RPORT'] == 0
      smb_services = [
        { port: 445, direct: true },
        { port: 139, direct: false }
Severity: Major
Found in modules/auxiliary/scanner/smb/smb_version.rb - About 5 hrs to fix

    Method smb_proto_info has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

      def smb_proto_info
        info = {
          capabilities: {},
          versions: []
        }
    Severity: Minor
    Found in modules/auxiliary/scanner/smb/smb_version.rb - About 4 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

    File smb_version.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'recog'
    
    class MetasploitModule < Msf::Auxiliary
    
      # Exploit mixins should be called first
    Severity: Minor
    Found in modules/auxiliary/scanner/smb/smb_version.rb - About 2 hrs to fix

      Method smb_proto_info has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def smb_proto_info
          info = {
            capabilities: {},
            versions: []
          }
      Severity: Major
      Found in modules/auxiliary/scanner/smb/smb_version.rb - About 2 hrs to fix

        Method smb_os_description has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def smb_os_description(res, nd_smb_fingerprint)
            #
            # Create the note hash for fingerprint.match
            #
            nd_fingerprint_match = {}
        Severity: Minor
        Found in modules/auxiliary/scanner/smb/smb_version.rb - About 1 hr to fix

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

            def smb_os_description(res, nd_smb_fingerprint)
              #
              # Create the note hash for fingerprint.match
              #
              nd_fingerprint_match = {}
          Severity: Minor
          Found in modules/auxiliary/scanner/smb/smb_version.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