rapid7/metasploit-framework

View on GitHub
lib/msf/ui/console/command_dispatcher/db.rb

Summary

Maintainability
F
1 mo
Test Coverage

File db.rb has 1956 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'rexml/document'
require 'metasploit/framework/data_service'
require 'metasploit/framework/data_service/remote/http/core'

Severity: Major
Found in lib/msf/ui/console/command_dispatcher/db.rb - About 5 days to fix

    Method cmd_notes has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_notes(*args)
        return unless active?
      ::ApplicationRecord.connection_pool.with_connection {
        mode = :search
        data = nil
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/db.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 cmd_services has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_services(*args)
        return unless active?
        mode = :search
        onlyup = false
        output_file = nil
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/db.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_workspace has a Cognitive Complexity of 84 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_workspace(*args)
        return unless active?
    
        state = :nil
    
    
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/db.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_hosts has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_hosts(*args)
        return unless active?
        onlyup = false
        set_rhosts = false
        mode = []
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/db.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_loot has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
    Open

      def cmd_loot(*args)
        return unless active?
    
        mode = :search
        host_ranges = []
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/db.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 Db has 70 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Db
    
      require 'tempfile'
    
      include Msf::Ui::Console::CommandDispatcher
    Severity: Major
    Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 day to fix

      Method cmd_vulns has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
      Open

        def cmd_vulns(*args)
          return unless active?
      
          default_columns = ['Timestamp', 'Host', 'Name', 'References']
          host_ranges = []
      Severity: Minor
      Found in lib/msf/ui/console/command_dispatcher/db.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_hosts has 215 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cmd_hosts(*args)
          return unless active?
          onlyup = false
          set_rhosts = false
          mode = []
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 day to fix

        Method cmd_notes has 164 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def cmd_notes(*args)
            return unless active?
          ::ApplicationRecord.connection_pool.with_connection {
            mode = :search
            data = nil
        Severity: Major
        Found in lib/msf/ui/console/command_dispatcher/db.rb - About 6 hrs to fix

          Method cmd_db_import has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
          Open

            def cmd_db_import(*args)
              return unless active?
            ::ApplicationRecord.connection_pool.with_connection {
              if args.include?("-h") || ! (args && args.length > 0)
                cmd_db_import_help
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/db.rb - About 6 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_services has 155 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def cmd_services(*args)
              return unless active?
              mode = :search
              onlyup = false
              output_file = nil
          Severity: Major
          Found in lib/msf/ui/console/command_dispatcher/db.rb - About 6 hrs to fix

            Method cmd_workspace has 146 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def cmd_workspace(*args)
                return unless active?
            
                state = :nil
            
            
            Severity: Major
            Found in lib/msf/ui/console/command_dispatcher/db.rb - About 5 hrs to fix

              Method cmd_loot has 135 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def cmd_loot(*args)
                  return unless active?
              
                  mode = :search
                  host_ranges = []
              Severity: Major
              Found in lib/msf/ui/console/command_dispatcher/db.rb - About 5 hrs to fix

                Method cmd_db_connect has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                  def cmd_db_connect(*args)
                    return if not db_check_driver
                
                    opts = {}
                    while (arg = args.shift)
                Severity: Minor
                Found in lib/msf/ui/console/command_dispatcher/db.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 cmd_vulns has 106 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def cmd_vulns(*args)
                    return unless active?
                
                    default_columns = ['Timestamp', 'Host', 'Name', 'References']
                    host_ranges = []
                Severity: Major
                Found in lib/msf/ui/console/command_dispatcher/db.rb - About 4 hrs to fix

                  Method run_nmap has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run_nmap(nmap, arguments, use_sudo: false)
                      print_warning('Running Nmap with sudo') if use_sudo
                      begin
                        nmap_pipe = use_sudo ? ::Open3::popen3('sudo', nmap, *arguments) : ::Open3::popen3(nmap, *arguments)
                        temp_nmap_threads = []
                  Severity: Minor
                  Found in lib/msf/ui/console/command_dispatcher/db.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_db_stats has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def cmd_db_stats(*args)
                      return unless active?
                      print_line "Session Type: #{db_connection_info(framework)}"
                  
                      current_workspace = framework.db.workspace
                  Severity: Major
                  Found in lib/msf/ui/console/command_dispatcher/db.rb - About 3 hrs to fix

                    Method cmd_db_connect has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def cmd_db_connect(*args)
                        return if not db_check_driver
                    
                        opts = {}
                        while (arg = args.shift)
                    Severity: Major
                    Found in lib/msf/ui/console/command_dispatcher/db.rb - About 3 hrs to fix

                      Method cmd_db_nmap has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def cmd_db_nmap(*args)
                          return unless active?
                        ::ApplicationRecord.connection_pool.with_connection {
                          if (args.length == 0)
                            print_status("Usage: db_nmap [--save | [--help | -h]] [nmap options]")
                      Severity: Minor
                      Found in lib/msf/ui/console/command_dispatcher/db.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_db_import has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def cmd_db_import(*args)
                          return unless active?
                        ::ApplicationRecord.connection_pool.with_connection {
                          if args.include?("-h") || ! (args && args.length > 0)
                            cmd_db_import_help
                      Severity: Major
                      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 2 hrs to fix

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

                          def list_saved_data_services
                            conf = Msf::Config.load
                            default = nil
                            tbl = Rex::Text::Table.new({
                                                           'Header'    => 'Data Services',
                        Severity: Minor
                        Found in lib/msf/ui/console/command_dispatcher/db.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 save_db_to_config has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def save_db_to_config(database, database_name)
                            if database_name =~ /\/|\[|\]/
                              raise ArgumentError, 'Data service name contains an invalid character.'
                            end
                            config_path = "#{DB_CONFIG_PATH}/#{database_name}"
                        Severity: Minor
                        Found in lib/msf/ui/console/command_dispatcher/db.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_db_import_help has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def cmd_db_import_help
                            print_line "Usage: db_import <filename> [file2...]"
                            print_line
                            print_line "Filenames can be globs like *.xml, or **/*.xml which will search recursively"
                            print_line "Currently supported file types include:"
                        Severity: Minor
                        Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 hr to fix

                          Method cmd_db_nmap has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def cmd_db_nmap(*args)
                              return unless active?
                            ::ApplicationRecord.connection_pool.with_connection {
                              if (args.length == 0)
                                print_status("Usage: db_nmap [--save | [--help | -h]] [nmap options]")
                          Severity: Minor
                          Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 hr to fix

                            Method cmd_db_stats has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def cmd_db_stats(*args)
                                return unless active?
                                print_line "Session Type: #{db_connection_info(framework)}"
                            
                                current_workspace = framework.db.workspace
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/db.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_db_export has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def cmd_db_export(*args)
                                return unless active?
                              ::ApplicationRecord.connection_pool.with_connection {
                            
                                export_formats = %W{xml pwdump}
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/db.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_db_connect_help has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def cmd_db_connect_help
                                print_line("   USAGE:")
                                print_line("      * Postgres Data Service:")
                                print_line("          db_connect <user:[pass]>@<host:[port]>/<database>")
                                print_line("        Examples:")
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 hr to fix

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

                                def cmd_db_export(*args)
                                  return unless active?
                                ::ApplicationRecord.connection_pool.with_connection {
                              
                                  export_formats = %W{xml pwdump}
                              Severity: Minor
                              Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 hr to fix

                                Method db_connection_info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def db_connection_info(framework)
                                    unless framework.db.connection_established?
                                      return "#{framework.db.driver} selected, no connection"
                                    end
                                
                                
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/db.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_db_disconnect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def cmd_db_disconnect(*args)
                                    return if not db_check_driver
                                
                                    if args[0] == '-h' || args[0] == '--help'
                                      cmd_db_disconnect_help
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/db.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_db_nmap_help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def cmd_db_nmap_help
                                    nmap = find_nmap_path
                                    unless nmap
                                      print_error("The nmap executable could not be found")
                                      return
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 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

                                          current_workspace.name == ws.name ? '*' : '',
                                Severity: Major
                                Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                            framework.db.workspace = updated_ws if names.first == framework.db.workspace.name
                                  Severity: Major
                                  Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                          if workspace
                                            framework.db.workspace = workspace
                                            print_status("Workspace: #{workspace.name}")
                                          else
                                            print_error("Workspace not found: #{name}")
                                    Severity: Major
                                    Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                            unless verbose
                                              current = nil
                                              framework.db.workspaces.sort_by {|s| s.name}.each do |s|
                                                if s.name == current_workspace.name
                                                  current = s.name
                                      Severity: Major
                                      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 45 mins to fix

                                        Method change_host_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def change_host_data(host_ranges, host_data)
                                            if !host_data || host_data.length != 1
                                              print_error("A single key-value data hash is required to change the host data")
                                              return
                                            end
                                        Severity: Minor
                                        Found in lib/msf/ui/console/command_dispatcher/db.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

                                        Method delete_host_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def delete_host_tag(rws, tag_name)
                                            opts = Hash.new()
                                            opts[:workspace] = framework.db.workspace
                                            opts[:tag_name] = tag_name
                                        
                                        
                                        Severity: Minor
                                        Found in lib/msf/ui/console/command_dispatcher/db.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

                                        Method cmd_db_nmap_tabs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          def cmd_db_nmap_tabs(str, words)
                                            nmap = find_nmap_path
                                            unless nmap
                                              return
                                            end
                                        Severity: Minor
                                        Found in lib/msf/ui/console/command_dispatcher/db.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
                                        Severity: Major
                                        Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

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

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

                                                      return cmd_workspace_help unless state == :nil
                                              Severity: Major
                                              Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

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

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return cmd_workspace_help unless state == :nil
                                                  Severity: Major
                                                  Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

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

                                                      Avoid too many return statements within this method.
                                                      Open

                                                          return @@hosts_opts.option_keys.select { |opt| opt.start_with?(str) }
                                                      Severity: Major
                                                      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

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

                                                            Avoid too many return statements within this method.
                                                            Open

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

                                                              Avoid too many return statements within this method.
                                                              Open

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

                                                                Avoid too many return statements within this method.
                                                                Open

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

                                                                  Avoid too many return statements within this method.
                                                                  Open

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

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                          return []
                                                                    Severity: Major
                                                                    Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

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

                                                                        Avoid too many return statements within this method.
                                                                        Open

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

                                                                          Avoid too many return statements within this method.
                                                                          Open

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

                                                                            Avoid too many return statements within this method.
                                                                            Open

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

                                                                              Avoid too many return statements within this method.
                                                                              Open

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

                                                                                Avoid too many return statements within this method.
                                                                                Open

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

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

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

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

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

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

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

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

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

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

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

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

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

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

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

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

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

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

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

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

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

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

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

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

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

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

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

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

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

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

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

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

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

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

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

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

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

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

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

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

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

                                                                                                                          Avoid too many return statements within this method.
                                                                                                                          Open

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

                                                                                                                            Avoid too many return statements within this method.
                                                                                                                            Open

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

                                                                                                                              Avoid too many return statements within this method.
                                                                                                                              Open

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

                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                Open

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

                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                  Open

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

                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                    Open

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

                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                      Open

                                                                                                                                            return []
                                                                                                                                      Severity: Major
                                                                                                                                      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 30 mins to fix

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

                                                                                                                                          def print_connection_info
                                                                                                                                            cdb = ''
                                                                                                                                            if framework.db.driver == 'http'
                                                                                                                                              cdb = framework.db.name
                                                                                                                                            else
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.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

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

                                                                                                                                          def cmd_db_save(*args)
                                                                                                                                            while (arg = args.shift)
                                                                                                                                              case arg
                                                                                                                                                when '-h', '--help'
                                                                                                                                                  cmd_db_save_help
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.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

                                                                                                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                        Open

                                                                                                                                          def db_connection_info(framework)
                                                                                                                                            unless framework.db.connection_established?
                                                                                                                                              return "#{framework.db.driver} selected, no connection"
                                                                                                                                            end
                                                                                                                                        
                                                                                                                                        
                                                                                                                                        Severity: Major
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.rb and 1 other location - About 1 hr to fix
                                                                                                                                        lib/msf/ui/debug.rb on lines 372..394

                                                                                                                                        Duplicated Code

                                                                                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                        Tuning

                                                                                                                                        This issue has a mass of 58.

                                                                                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                        Refactorings

                                                                                                                                        Further Reading

                                                                                                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                        Open

                                                                                                                                            more = {
                                                                                                                                              "workspace"     => "Switch between database workspaces",
                                                                                                                                              "hosts"         => "List all hosts in the database",
                                                                                                                                              "services"      => "List all services in the database",
                                                                                                                                              "vulns"         => "List all vulnerabilities in the database",
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.rb and 1 other location - About 20 mins to fix
                                                                                                                                        lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/ui.rb on lines 27..40

                                                                                                                                        Duplicated Code

                                                                                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                        Tuning

                                                                                                                                        This issue has a mass of 28.

                                                                                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                        Refactorings

                                                                                                                                        Further Reading

                                                                                                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                        Open

                                                                                                                                            default_columns = [
                                                                                                                                                'address',
                                                                                                                                                'arch',
                                                                                                                                                'comm',
                                                                                                                                                'comments',
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.rb and 1 other location - About 20 mins to fix
                                                                                                                                        modules/auxiliary/scanner/http/soap_xml.rb on lines 42..68

                                                                                                                                        Duplicated Code

                                                                                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                        Tuning

                                                                                                                                        This issue has a mass of 28.

                                                                                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                        Refactorings

                                                                                                                                        Further Reading

                                                                                                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                        Open

                                                                                                                                            when mode == [:delete_tag]
                                                                                                                                              begin
                                                                                                                                                delete_host_tag(host_ranges, tag_name)
                                                                                                                                              rescue => e
                                                                                                                                                if e.message.include?('Validation failed')
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.rb and 1 other location - About 15 mins to fix
                                                                                                                                        lib/msf/ui/console/command_dispatcher/db.rb on lines 592..603

                                                                                                                                        Duplicated Code

                                                                                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                        Tuning

                                                                                                                                        This issue has a mass of 25.

                                                                                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                        Refactorings

                                                                                                                                        Further Reading

                                                                                                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                        Open

                                                                                                                                            when mode == [:tag]
                                                                                                                                              begin
                                                                                                                                                add_host_tag(host_ranges, tag_name)
                                                                                                                                              rescue => e
                                                                                                                                                if e.message.include?('Validation failed')
                                                                                                                                        Severity: Minor
                                                                                                                                        Found in lib/msf/ui/console/command_dispatcher/db.rb and 1 other location - About 15 mins to fix
                                                                                                                                        lib/msf/ui/console/command_dispatcher/db.rb on lines 603..614

                                                                                                                                        Duplicated Code

                                                                                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                        Tuning

                                                                                                                                        This issue has a mass of 25.

                                                                                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                        Refactorings

                                                                                                                                        Further Reading

                                                                                                                                        There are no issues that match your filters.

                                                                                                                                        Category
                                                                                                                                        Status