rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

Avoid deeply nested control flow statements.
Open

        yield("Aborting, got error type:%d, message:'%s'" % [type, data]) if block_given?
Severity: Major
Found in lib/rex/proto/tftp/client.rb - About 45 mins to fix

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

        def self.request_static_ip(magic, dmac, ip, mask, gw, pwd="dbps")
    Severity: Minor
    Found in lib/rex/proto/addp.rb - About 45 mins to fix

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

        def from_s(header)
          reset
      
          # ghettoooooo!
          # If we don't have any newlines..., put one there.
      Severity: Minor
      Found in lib/rex/proto/http/packet/header.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

              yield("Aborting, got code:%d, type:%d, message:'%s'" % [code, type, data]) if block_given?
      Severity: Major
      Found in lib/rex/proto/tftp/client.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

              if temp_response.kind_of? Rex::Proto::Http::Response
                res = temp_response
              end
        Severity: Major
        Found in lib/rex/proto/http/client.rb - About 45 mins to fix

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

            def socket_check()
              if self.socket == nil
                self.socket_setup()
              end
          
          
          Severity: Minor
          Found in lib/rex/proto/dcerpc/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 trans_maxzero has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def trans_maxzero(pipe, param = '', body = '', setup_count = 0, setup_data = '', no_response = false, do_recv = true, ignore_errors = false)
          
              # Null-terminate the pipe parameter if needed
              if (pipe[-1] != 0)
                pipe << "\x00"
          Severity: Minor
          Found in lib/rex/proto/smb/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 nttrans has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def nttrans(subcommand, param = '', body = '', setup_count = 0, setup_data = '', do_recv = true)
          Severity: Minor
          Found in lib/rex/proto/smb/client.rb - About 45 mins to fix

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

                        def initialize(name, value, description)
                          raise ArgumentError, 'Invalid Error Name' unless name.is_a?(String) && !name.empty?
                          raise ArgumentError, 'Invalid Error Code Value' unless value.is_a?(Integer)
                          raise ArgumentError, 'Invalid Error Description' unless description.is_a?(String) && !description.empty?
            
            
            Severity: Minor
            Found in lib/rex/proto/kerberos/model/error.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 trans has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def trans(pipe, param = '', body = '', setup_count = 0, setup_data = '', no_response = false, do_recv = true)
            
                # Null-terminate the pipe parameter if needed
                if (pipe[-1,1] != "\x00")
                  pipe << "\x00"
            Severity: Minor
            Found in lib/rex/proto/smb/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 stop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def stop(flush_cache = false)
                ensure_close = [self.udp_sock, self.tcp_sock].compact
                begin
                  self.listener_thread.kill if self.listener_thread.respond_to?(:kill)
                  self.listener_thread = nil
            Severity: Minor
            Found in lib/rex/proto/dns/server.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 default_dispatch_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def default_dispatch_request(cli,data)
                return if data.strip.empty?
                req = Packet.encode_drb(data)
                forward = req.dup
                # Find cached items, remove request from forwarded packet
            Severity: Minor
            Found in lib/rex/proto/dns/server.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 load_config_static_hostnames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def load_config_static_hostnames
                  config = Msf::Config.load
            
                  static_hostnames.flush
                  config.fetch("#{CONFIG_KEY_BASE}/static_hostnames", {}).each do |_name, value|
            Severity: Minor
            Found in lib/rex/proto/dns/custom_nameserver_provider.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 parse_hosts_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_hosts_file
                  path = %w[
                    %WINDIR%\system32\drivers\etc\hosts
                    /etc/hosts
                    /data/data/com.termux/files/usr/etc/hosts
            Severity: Minor
            Found in lib/rex/proto/dns/static_hostnames.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

                        break if not data
            Severity: Major
            Found in lib/rex/proto/dcerpc/client.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          break if not data.length
              Severity: Major
              Found in lib/rex/proto/dcerpc/client.rb - About 45 mins to fix

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

                    def add(hostname, ip_address)
                      unless self.class.is_valid_hostname?(hostname)
                        # it is important to validate the hostname because assumptions about what characters it may contain are made
                        # when saving and loading it from the configuration
                        raise ::ArgumentError.new("Invalid hostname: #{hostname}")
                Severity: Minor
                Found in lib/rex/proto/dns/static_hostnames.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 delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def delete(hostname, ip_address)
                      ip_address = IPAddr.new(ip_address) if ip_address.is_a?(String) && Rex::Socket.is_ip_addr?(ip_address)
                      if ip_address.family == ::Socket::AF_INET
                        type = Dnsruby::Types::A
                      else
                Severity: Minor
                Found in lib/rex/proto/dns/static_hostnames.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 collect_host_fingerprint_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def collect_host_fingerprint_data(name)
                      return unless in_tag("device")
                      return if in_tag("service")
                      return unless in_tag("fingerprint")
                      return unless @text
                Severity: Minor
                Found in lib/rex/parser/nexpose_simple_document.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

                          formatted << (sysinfo.nil? ? default : sysinfo['Computer'])
                Severity: Major
                Found in lib/rex/ui/text/shell.rb - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language