rapid7/metasploit-framework

View on GitHub
lib/msf/core/auxiliary/scanner.rb

Summary

Maintainability
F
4 days
Test Coverage

Method run has a Cognitive Complexity of 129 (exceeds 5 allowed). Consider refactoring.
Open

def run
  @show_progress = datastore['ShowProgress']
  @show_percent  = datastore['ShowProgressPercent'].to_i

  if self.respond_to?(:session) && session
Severity: Minor
Found in lib/msf/core/auxiliary/scanner.rb - About 2 days 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 has 160 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def run
  @show_progress = datastore['ShowProgress']
  @show_percent  = datastore['ShowProgressPercent'].to_i

  if self.respond_to?(:session) && session
Severity: Major
Found in lib/msf/core/auxiliary/scanner.rb - About 6 hrs to fix

    File scanner.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Msf
    
    ###
    #
    # This module provides methods for scanning modules
    Severity: Minor
    Found in lib/msf/core/auxiliary/scanner.rb - About 2 hrs to fix

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

      def add_delay_jitter(_delay, _jitter)
        # Introduce the delay
        delay_value = _delay.to_i
        original_value = delay_value
        jitter_value = _jitter.to_i
      Severity: Minor
      Found in lib/msf/core/auxiliary/scanner.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

      Avoid deeply nested control flow statements.
      Open

                if (not datastore)
                  nohosts = true
                  break
                end
      Severity: Major
      Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    rescue ::Exception => e
                      print_status("Error: #{mybatch[0]}-#{mybatch[-1]}: #{e}")
        Severity: Major
        Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    rescue StopIteration
                      datastore = nil
          Severity: Major
          Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        rescue ::Interrupt,::NoMethodError, ::RuntimeError, ::ArgumentError, ::NameError
                          raise $!
            Severity: Major
            Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          rescue ::Rex::BindFailed
                            if datastore['CHOST']
                              @scan_errors << "The source IP (CHOST) value of #{datastore['CHOST']} was not usable"
                            end
              Severity: Major
              Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            rescue ::Rex::ConnectionError, ::Rex::ConnectionProxyError, ::Errno::ECONNRESET, ::Errno::EINTR, ::Rex::TimeoutError, ::Timeout::Error
                Severity: Major
                Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              rescue Msf::Auxiliary::Scanner::AttemptFailed => e
                                print_error("#{e}")
                  Severity: Major
                  Found in lib/msf/core/auxiliary/scanner.rb - About 45 mins to fix

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

                    def scanner_handle_fatal_errors
                      return unless has_fatal_errors?
                      return unless @thread_list
                    
                      # First kill any running threads
                    Severity: Minor
                    Found in lib/msf/core/auxiliary/scanner.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