rapid7/metasploit-framework

View on GitHub

Showing 21,757 of 21,757 total issues

Method query_pg_shadow_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def query_pg_shadow_values(pg_password, vcdb_user, vcdb_name)
          return nil unless command_exists? psql_bin

          output = []
          postgres_users = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT usename, passwd FROM pg_shadow;' -P pager -A -t")
Severity: Minor
Found in lib/msf/core/post/vcenter/database.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

              if counter.zero?  # Get starting packet
                if pkt["DATA"][0] == "10"
                  data += pkt["DATA"][start_offset, 8 - start_offset]
                  left2combine -= 1
                  counter += 1
Severity: Major
Found in lib/msf/core/post/hardware/automotive/uds.rb - About 45 mins to fix

    Method query_pg_shadow_values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def query_pg_shadow_values(pg_password, vcdb_user, vcdb_name)
              return nil unless command_exists? psql_bin
    
              output = []
              postgres_users = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT usename, passwd FROM pg_shadow;' -P pager -A -t")
    Severity: Minor
    Found in lib/msf/core/post/vcenter/database.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

    Method get_vpx_vms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def get_vpx_vms(pg_password, vcdb_user, vcdb_name, _vc_sym_key)
              return nil unless command_exists? psql_bin
    
              output = []
              vm_rows = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT vmid, name, configfilename, guest_state, is_template FROM vpxv_vms;' -P pager -A -t")
    Severity: Minor
    Found in lib/msf/core/post/vcenter/database.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

    Method get_vpx_users has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def get_vpx_users(pg_password, vcdb_user, vcdb_name, vc_sym_key)
              return nil unless command_exists? psql_bin
    
              output = []
              vpxuser_rows = cmd_exec("#{postgress_connect(pg_password, vcdb_user, vcdb_name)} -c 'SELECT dns_name, ip_address, user_name, password FROM vc.vpx_host ORDER BY dns_name ASC;' -P pager -A -t")
    Severity: Minor
    Found in lib/msf/core/post/vcenter/database.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

    Method get_freeze_frame_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def get_freeze_frame_data(bus, src_id, dst_id, pid, frame, opt = {})
    Severity: Minor
    Found in lib/msf/core/post/hardware/automotive/uds.rb - About 45 mins to fix

      Method send_security_token_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def send_security_token_response(bus, src_id, dst_id, key, response_level = 2, opt = {})
      Severity: Minor
      Found in lib/msf/core/post/hardware/automotive/uds.rb - About 45 mins to fix

        Method write_data_by_id has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def write_data_by_id(bus, src_id, dst_id, id, data, opt = {})
        Severity: Minor
        Found in lib/msf/core/post/hardware/automotive/uds.rb - About 45 mins to fix

          Method reset_ecu has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def reset_ecu(bus, src_id, dst_id, hard, opt = {})
              unless client.automotive
                print_error("Not an automotive hwbridge session")
                return {}
              end
          Severity: Minor
          Found in lib/msf/core/post/hardware/automotive/uds.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

          Method normalize_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def normalize_key(key)
              keys = split_key(key)
              if (keys[0] =~ /HKLM|HKEY_LOCAL_MACHINE/)
                keys[0] = 'HKEY_LOCAL_MACHINE'
              elsif (keys[0] =~ /HKCU|HKEY_CURRENT_USER/)
          Severity: Minor
          Found in lib/msf/core/post/windows/registry.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

          Method reg_key_value_exists? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def reg_key_value_exists?(reg_key, reg_value, opts = {})
                    remote_host = opts[:remote_system].present? || datastore['ScheduleRemoteSystem'].present?
                    result = false
                    if remote_host
                      begin
          Severity: Minor
          Found in lib/msf/core/post/windows/task_scheduler.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

          Method clean_up has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def clean_up(script_file = nil, eof = '', running_pids = [], open_channels = [],
                               env_suffix = Rex::Text.rand_text_alpha(8), delete = false)
          Severity: Minor
          Found in lib/msf/core/post/windows/powershell.rb - About 45 mins to fix

            Method get_versionception has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_versionception(dotnet_vkey)
                exact_version = nil
                begin
                  subkeys = registry_enumkeys(dotnet_vkey)
                rescue Rex::Post::Meterpreter::RequestError => e
            Severity: Minor
            Found in lib/msf/core/post/windows/dotnet.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

            Method hosts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def hosts(opts = {})
                begin
                  self.data_service_operation do |data_service|
                    opts[:non_dead] = false unless opts.has_key?(:non_dead)
                    opts[:address] = opts.delete(:address) || opts.delete(:host)
            Severity: Minor
            Found in lib/metasploit/framework/data_service/proxy/host_data_proxy.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

            Method attempt_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def attempt_login(credential)
                      result_opts = {
                          credential: credential,
                          host: host,
                          port: port,
            Severity: Minor
            Found in lib/metasploit/framework/login_scanner/wordpress_rpc.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

            Method each_credential has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                      def each_credential
                        cred_details.each do |raw_cred|
            
                          # This could be a Credential object, or a Credential Core, or an Attempt object
                          # so make sure that whatever it is, we end up with a Credential.
            Severity: Minor
            Found in lib/metasploit/framework/login_scanner/base.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

            Method validate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def validate(data_service)
                raise "Invalid data_service: #{data_service.class}, not of type Metasploit::Framework::DataService" unless data_service.is_a? (Metasploit::Framework::DataService)
                raise 'Cannot register null data service data_service' unless data_service
                raise 'Data Service already exists' if data_service_exist?(data_service)
                # Raising an error for local DB causes startup to fail if there is a DB configured but we are unable to connect
            Severity: Minor
            Found in lib/metasploit/framework/data_service/proxy/core.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

            Method attempt_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def attempt_login(credential)
                      result_opts = {
                        credential: credential,
                        host: host,
                        port: port,
            Severity: Minor
            Found in lib/metasploit/framework/login_scanner/jupyter.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

            Method set_sane_defaults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def set_sane_defaults
                      self.connection_timeout ||= 30
                      self.port               ||= DEFAULT_PORT
                      self.banner_timeout     ||= 25
                      self.telnet_timeout     ||= 10
            Severity: Minor
            Found in lib/metasploit/framework/login_scanner/telnet.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

            Method attempt_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def attempt_login(credential)
                      result_options = {
                        credential: credential,
                        status: Metasploit::Model::Login::Status::INCORRECT,
                        host: host,
            Severity: Minor
            Found in lib/metasploit/framework/login_scanner/redis.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

            Severity
            Category
            Status
            Source
            Language