rapid7/metasploit-framework

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

Summary

Maintainability
F
1 wk
Test Coverage

File sys.rb has 1012 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/post/meterpreter'
require 'rex/post/meterpreter/extensions/stdapi/command_ids'

module Rex
module Post
Severity: Major
Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 2 days to fix

    Method cmd_reg has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_reg(*args)
        # Extract the command, if any
        cmd = args.shift
    
        if (args.length == 0)
    Severity: Minor
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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 cmd_reg has 195 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def cmd_reg(*args)
        # Extract the command, if any
        cmd = args.shift
    
        if (args.length == 0)
    Severity: Major
    Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 7 hrs to fix

      Class Sys has 44 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Console::CommandDispatcher::Stdapi::Sys
      
        Klass = Console::CommandDispatcher::Stdapi::Sys
      
        include Console::CommandDispatcher
      Severity: Minor
      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 6 hrs to fix

        Method match_processes has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

          def match_processes(processes, args, quiet: false)
        
            search_proc = nil
            search_user = nil
            exact_match = false
        Severity: Minor
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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_shell has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

          def cmd_shell(*args)
            use_pty = false
            raw = false
            sh_path = '/bin/bash'
        
        
        Severity: Minor
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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

        Method match_processes has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def match_processes(processes, args, quiet: false)
        
            search_proc = nil
            search_user = nil
            exact_match = false
        Severity: Major
        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 2 hrs to fix

          Method cmd_execute has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def cmd_execute(*args)
              if (args.length == 0)
                args.unshift("-h")
              end
          
          
          Severity: Major
          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 2 hrs to fix

            Method commands has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def commands
                all = {
                  'clearev'     => 'Clear the event log',
                  'drop_token'  => 'Relinquishes any active impersonation token.',
                  'execute'     => 'Execute a command',
            Severity: Major
            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 2 hrs to fix

              Method cmd_shell has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def cmd_shell(*args)
                  use_pty = false
                  raw = false
                  sh_path = '/bin/bash'
              
              
              Severity: Major
              Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 2 hrs to fix

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

                  def cmd_suspend(*args)
                    # give'em help if they want it, or seem confused
                    if args.length == 0 or (args.include? "-h")
                      cmd_suspend_help
                      return true
                Severity: Minor
                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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 pty_shell has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def pty_shell(sh_path, raw: false)
                    args = ['-p']
                
                    if raw
                      args << '-r' if raw

                  Method pty_shell has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def pty_shell(sh_path, raw: false)
                      args = ['-p']
                  
                      if raw
                        args << '-r' if raw

                  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_suspend has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def cmd_suspend(*args)
                      # give'em help if they want it, or seem confused
                      if args.length == 0 or (args.include? "-h")
                        cmd_suspend_help
                        return true

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

                      def cmd_pgrep(*args)
                        f_flag = false
                        l_flag = false
                    
                        @@pgrep_opts.parse(args) do |opt, idx, val|

                    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_pgrep has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def cmd_pgrep(*args)
                        f_flag = false
                        l_flag = false
                    
                        @@pgrep_opts.parse(args) do |opt, idx, val|

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

                        def validate_pids(pids, allow_pid_0 = false, allow_session_pid = false)
                      
                          return [] if (pids.class != Array or pids.empty?)
                          valid_pids = []
                          # to minimize network traffic, we only get host processes once

                      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_execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

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

                        def cmd_reg_tabs(str, words)
                          if words.length == 1
                            return %w[enumkey createkey deletekey queryclass setval deleteval queryval] + @@reg_opts.option_keys
                          end
                      
                      
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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_kill has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def cmd_kill(*args)
                          # give'em help if they want it, or seem confused
                          if ( args.length == 0 or (args.length == 1 and args[0].strip == "-h") )
                            cmd_kill_help
                            return true
                      Severity: Minor
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 35 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 false
                      Severity: Major
                      Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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/stdapi/sys.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/stdapi/sys.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return @@reg_opts.option_keys
                            Severity: Major
                            Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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/stdapi/sys.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                      return %w[REG_BINARY REG_DWORD REG_QWORD REG_DWORD_BIG_ENDIAN REG_EXPAND_SZ
                                                REG_LINK REG_MULTI_SZ REG_NONE REG_RESOURCE_LIST REG_SZ]
                                Severity: Major
                                Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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/stdapi/sys.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/stdapi/sys.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/stdapi/sys.rb - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                              return %w[32 64]
                                        Severity: Major
                                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb - About 30 mins to fix

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

                                            def cmd_ps_tabs(str, words)
                                              return @@ps_opts.option_keys if words.length == 1
                                          
                                              case words[-1]
                                              when '-A'
                                          Severity: Minor
                                          Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.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