rapid7/metasploit-framework

View on GitHub
lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Summary

Maintainability
F
2 wks
Test Coverage

File core.rb has 1333 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'set'
require 'rex/post/meterpreter'
require 'rex'

module Rex
Severity: Major
Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 3 days to fix

    Method cmd_transport has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_transport(*args)
        if ( args.length == 0 or args.include?("-h") )
          cmd_transport_help
          return
        end
    Severity: Minor
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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

    Class Core has 64 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Console::CommandDispatcher::Core
    
      include Console::CommandDispatcher
    
      #
    Severity: Major
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 1 day to fix

      Method cmd_migrate has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
      Open

        def cmd_migrate(*args)
          if args.length == 0 || args.any? { |arg| %w(-h --pid --name).include? arg }
            cmd_migrate_help
            return true
          end
      Severity: Minor
      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_transport has 168 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cmd_transport(*args)
          if ( args.length == 0 or args.include?("-h") )
            cmd_transport_help
            return
          end
      Severity: Major
      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 6 hrs to fix

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

          def cmd_load(*args)
            if args.length == 0
              args.unshift('-h')
            end
        
        
        Severity: Minor
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_pivot has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

          def cmd_pivot(*args)
            if args.length == 0 || args.include?('-h')
              cmd_pivot_help
              return true
            end
        Severity: Minor
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_migrate has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cmd_migrate(*args)
            if args.length == 0 || args.any? { |arg| %w(-h --pid --name).include? arg }
              cmd_migrate_help
              return true
            end
        Severity: Major
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 3 hrs to fix

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

            def cmd_write(*args)
              if args.length == 0 || args.include?("-h")
                cmd_write_help
                return
              end
          Severity: Minor
          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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

          Method cmd_load has 88 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def cmd_load(*args)
              if args.length == 0
                args.unshift('-h')
              end
          
          
          Severity: Major
          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 3 hrs to fix

            Method cmd_pivot has 83 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def cmd_pivot(*args)
                if args.length == 0 || args.include?('-h')
                  cmd_pivot_help
                  return true
                end
            Severity: Major
            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 3 hrs to fix

              Method cmd_channel has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def cmd_channel(*args)
                  if args.empty? || args.include?('-h')
                    cmd_channel_help
                    return
                  end
              Severity: Major
              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 2 hrs to fix

                Method cmd_channel has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def cmd_channel(*args)
                    if args.empty? || args.include?('-h')
                      cmd_channel_help
                      return
                    end
                Severity: Minor
                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 commands has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def commands
                    cmds = {
                      '?'                        => 'Help menu',
                      'background'               => 'Backgrounds the current session',
                      'bg'                       => 'Alias for background',
                Severity: Major
                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 2 hrs to fix

                  Method cmd_ssl_verify has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cmd_ssl_verify(*args)
                      if ( args.length == 0 or args.include?("-h") )
                        cmd_ssl_verify_help
                        return
                      end
                  Severity: Minor
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_set_timeouts has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cmd_set_timeouts(*args)
                      if args.length == 0 || args.include?('-h')
                        cmd_set_timeouts_help
                        return
                      end
                  Severity: Minor
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cmd_run(*args)
                      if args.empty? || args.first == '-h'
                        cmd_run_help
                        return true
                      end
                  Severity: Minor
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_write has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def cmd_write(*args)
                      if args.length == 0 || args.include?("-h")
                        cmd_write_help
                        return
                      end
                  Severity: Major
                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 2 hrs to fix

                    Method cmd_ssl_verify has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def cmd_ssl_verify(*args)
                        if ( args.length == 0 or args.include?("-h") )
                          cmd_ssl_verify_help
                          return
                        end
                    Severity: Minor
                    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 2 hrs to fix

                      Method get_extension_client_class has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def get_extension_client_class(mod)
                          self.class.client_extension_search_paths.each do |path|
                            path = ::File.join(path, "#{mod}.rb")
                            klass = CommDispatcher.check_hash(path)
                            return klass unless klass.nil?
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 unknown_command has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def unknown_command(cmd, line)
                          status = super
                      
                          if status.nil?
                            # Check to see if we can find this command in another extension. This relies on the core extension being the last
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_run has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def cmd_run(*args)
                          if args.empty? || args.first == '-h'
                            cmd_run_help
                            return true
                          end
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 1 hr to fix

                        Method cmd_run_tabs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_run_tabs(str, words)
                            tabs = []
                            unless words[1] && words[1].match(/^\//)
                              begin
                                tabs += tab_complete_modules(str, words) if msf_loaded?
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_info(*args)
                            return unless msf_loaded?
                        
                            if args.length != 1 or args.include?('-h')
                              cmd_info_help
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 cmd_read has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_read(*args)
                            if args.empty? || args.include?('-h')
                              cmd_read_help
                              return true
                            end
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.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 too many return statements within this method.
                        Open

                                return
                        Severity: Major
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                return
                          Severity: Major
                          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                return true
                            Severity: Major
                            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return @@pivot_opts.option_keys
                              Severity: Major
                              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return false
                                Severity: Major
                                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                            return
                                  Severity: Major
                                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                          return
                                    Severity: Major
                                    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return false
                                      Severity: Major
                                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return false
                                        Severity: Major
                                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return false
                                          Severity: Major
                                          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                  return ['pipe']
                                            Severity: Major
                                            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return false
                                              Severity: Major
                                              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                      return %w[reverse_tcp reverse_http reverse_https bind_tcp]
                                                Severity: Major
                                                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return
                                                  Severity: Major
                                                  Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                          return @@transport_opts.option_keys
                                                    Severity: Major
                                                    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return false
                                                      Severity: Major
                                                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                return
                                                        Severity: Major
                                                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 30 mins to fix

                                                          There are no issues that match your filters.

                                                          Category
                                                          Status