rapid7/metasploit-framework

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

Summary

Maintainability
F
3 days
Test Coverage

Method get_files_info has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

  def get_files_info(ip, shares)
    # Creating a separate file for each IP address's results.
    detailed_tbl = Rex::Text::Table.new(
      'Header' => "Spidered results for #{ip}.",
      'Indent' => 1,
Severity: Minor
Found in modules/auxiliary/scanner/smb/smb_enumshares.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 get_files_info has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_files_info(ip, shares)
    # Creating a separate file for each IP address's results.
    detailed_tbl = Rex::Text::Table.new(
      'Header' => "Spidered results for #{ip}.",
      'Indent' => 1,
Severity: Major
Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 4 hrs to fix

    File smb_enumshares.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Auxiliary
    
      # Exploit mixins should be called first
      include Msf::Exploit::Remote::SMB::Client
      include Msf::Exploit::Remote::SMB::Client::Authenticated
    Severity: Minor
    Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 3 hrs to fix

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

        def run_host(ip)
          if session
            print_status("Using existing session #{session.sid}")
            client = session.client
            self.simple = ::Rex::Proto::SMB::SimpleClient.new(client.dispatcher.tcp_socket, client: client)
      Severity: Minor
      Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 2 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 enum_tree has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def enum_tree(tree, share, subdir = '')
          subdir = subdir[1..subdir.length] if subdir.starts_with?('\\')
          read = tree.permissions.read_ea == 1
          write = tree.permissions.write_ea == 1
          skip = false
      Severity: Minor
      Found in modules/auxiliary/scanner/smb/smb_enumshares.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 enum_shares has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def enum_shares(ip)
          shares = []
      
          begin
            # Return all shares if `Shares` option has not been set
      Severity: Minor
      Found in modules/auxiliary/scanner/smb/smb_enumshares.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 enum_shares has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def enum_shares(ip)
          shares = []
      
          begin
            # Return all shares if `Shares` option has not been set
      Severity: Minor
      Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 1 hr to fix

        Method run_host has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run_host(ip)
            if session
              print_status("Using existing session #{session.sid}")
              client = session.client
              self.simple = ::Rex::Proto::SMB::SimpleClient.new(client.dispatcher.tcp_socket, client: client)
        Severity: Minor
        Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 1 hr to fix

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

            def initialize(info = {})
              super(
                update_info(
                  info,
                  'Name' => 'SMB Share Enumeration',
          Severity: Minor
          Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 1 hr to fix

            Method enum_tree has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def enum_tree(tree, share, subdir = '')
                subdir = subdir[1..subdir.length] if subdir.starts_with?('\\')
                read = tree.permissions.read_ea == 1
                write = tree.permissions.write_ea == 1
                skip = false
            Severity: Minor
            Found in modules/auxiliary/scanner/smb/smb_enumshares.rb - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status