rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def rm_rf(*remote_dirs)
    remote_dirs.each do |remote|
      if session.type == 'meterpreter'
        session.fs.dir.rmdir(remote) if exist?(remote)
      elsif session.type == 'powershell'
Severity: Minor
Found in lib/msf/core/post/file.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 copy_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def copy_file(src_file, dst_file)
    return false if directory?(dst_file) || directory?(src_file)

    verification_token = Rex::Text.rand_text_alpha_upper(8)
    if session.type == 'meterpreter'
Severity: Minor
Found in lib/msf/core/post/file.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 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 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 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 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 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 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 ldap_auth_opts_kerberos has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def ldap_auth_opts_kerberos(opts, ssl)
                    auth_opts = {}
                    raise Msf::ValidationError, 'The LDAP::Rhostname option is required when using Kerberos authentication.' if opts[:ldap_rhostname].blank?
                    raise Msf::ValidationError, 'The DOMAIN option is required when using Kerberos authentication.' if opts[:domain].blank?
          
          
          Severity: Minor
          Found in lib/metasploit/framework/ldap/client.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 ldap_auth_opts_schannel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def ldap_auth_opts_schannel(opts, ssl)
                    auth_opts = {}
                    pfx_path = opts[:ldap_cert_file]
                    raise Msf::ValidationError, 'The SSL option must be enabled when using Schannel authentication.' unless ssl
                    raise Msf::ValidationError, 'The LDAP::CertFile option is required when using Schannel authentication.' if pfx_path.blank?
          Severity: Minor
          Found in lib/metasploit/framework/ldap/client.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 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 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 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

          Avoid deeply nested control flow statements.
          Open

                          if version && platform && board
                            info = "#{platform.strip} #{board.strip} #{version.strip}"
                          end
          Severity: Major
          Found in lib/metasploit/framework/ssh/platform.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        s[:lmhash] = "00" * 24 if s[:lmhash] == '' or s[:lmhash] =~ /^(00)*$/m
            Severity: Major
            Found in data/exploits/psnuffle/smb.rb - About 45 mins to fix

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

                      public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
              Severity: Minor
              Found in external/source/psh_exe/dot_net_service.cs - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language