rapid7/metasploit-framework

View on GitHub
lib/msf/ui/console/driver.rb

Summary

Maintainability
F
4 days
Test Coverage

File driver.rb has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'find'
require 'erb'
require 'rexml/document'
require 'fileutils'
require 'digest/md5'
Severity: Minor
Found in lib/msf/ui/console/driver.rb - About 7 hrs to fix

    Method initialize has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
        choose_readline(opts)
    
        histfile = opts['HistFile'] || Msf::Config.history_file
    
    
    Severity: Minor
    Found in lib/msf/ui/console/driver.rb - About 5 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 initialize has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {})
        choose_readline(opts)
    
        histfile = opts['HistFile'] || Msf::Config.history_file
    
    
    Severity: Major
    Found in lib/msf/ui/console/driver.rb - About 3 hrs to fix

      Method handle_session_tlv_logging has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

        def handle_session_tlv_logging(val)
          return false if val.nil?
      
          if val.casecmp?('console') || val.casecmp?('true') || val.casecmp?('false')
            return true
      Severity: Minor
      Found in lib/msf/ui/console/driver.rb - About 3 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

      Class Driver has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Driver < Msf::Ui::Driver
      
        ConfigCore  = "framework/core"
        ConfigGroup = "framework/ui/console"
      
      
      Severity: Minor
      Found in lib/msf/ui/console/driver.rb - About 2 hrs to fix

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

          def on_startup(opts = {})
            # Check for modules that failed to load
            if framework.modules.module_load_error_by_path.length > 0
              wlog("The following modules could not be loaded!")
        
        
        Severity: Minor
        Found in lib/msf/ui/console/driver.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 load_config has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def load_config(path=nil)
            begin
              conf = Msf::Config.load(path)
            rescue
              wlog("Failed to load configuration: #{$!}")
        Severity: Minor
        Found in lib/msf/ui/console/driver.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 on_startup has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def on_startup(opts = {})
            # Check for modules that failed to load
            if framework.modules.module_load_error_by_path.length > 0
              wlog("The following modules could not be loaded!")
        
        
        Severity: Minor
        Found in lib/msf/ui/console/driver.rb - About 1 hr to fix

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

            def handle_session_tlv_logging(val)
              return false if val.nil?
          
              if val.casecmp?('console') || val.casecmp?('true') || val.casecmp?('false')
                return true
          Severity: Minor
          Found in lib/msf/ui/console/driver.rb - About 1 hr to fix

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

              def unknown_command(method, line)
                if File.basename(method) == 'msfconsole'
                  print_error('msfconsole cannot be run inside msfconsole')
                  return
                end
            Severity: Minor
            Found in lib/msf/ui/console/driver.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 handle_payload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def handle_payload(val)
                if framework && !framework.payloads.valid?(val)
                  return false
                elsif active_module && (active_module.exploit? || active_module.evasion?)
                  return false unless active_module.is_payload_compatible?(val)
            Severity: Minor
            Found in lib/msf/ui/console/driver.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 on_variable_set has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def on_variable_set(glob, var, val)
                case var.downcase
                when 'sessionlogging'
                  handle_session_logging(val) if glob
                when 'sessiontlvlogging'
            Severity: Minor
            Found in lib/msf/ui/console/driver.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 choose_readline has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def choose_readline(opts)
                # Choose a readline library before calling the parent
                @rl_err = nil
                if opts['RealReadline']
                  # Remove the gem version from load path to be sure we're getting the
            Severity: Minor
            Found in lib/msf/ui/console/driver.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 on_variable_unset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def on_variable_unset(glob, var)
                case var.downcase
                when 'sessionlogging'
                  handle_session_logging('0') if glob
                when 'sessiontlvlogging'
            Severity: Minor
            Found in lib/msf/ui/console/driver.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

            Avoid deeply nested control flow statements.
            Open

                    if ::File.writable?(pathname.dirname)
                      return true
                    else
                      print_status "No write permissions for log output directory: #{pathname.dirname}"
                      return false
            Severity: Major
            Found in lib/msf/ui/console/driver.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      rescue ::StandardError => e
                        print_status "Error when trying to create directory #{pathname.dirname}: #{e.message}"
                        return false
              Severity: Major
              Found in lib/msf/ui/console/driver.rb - About 45 mins to fix

                Avoid too many return statements within this method.
                Open

                          return true
                Severity: Major
                Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return true
                  Severity: Major
                  Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return false
                    Severity: Major
                    Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return false
                      Severity: Major
                      Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                  return true
                        Severity: Major
                        Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                    return false
                          Severity: Major
                          Found in lib/msf/ui/console/driver.rb - About 30 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status