rapid7/ruby_smb

View on GitHub

Showing 173 of 310 total issues

Method process_ntlm_type3 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

          def process_ntlm_type3(type3_msg)
            if type3_msg.user == '' && type3_msg.domain == ''
              if @provider.allow_anonymous
                @session_key = "\x00".b * 16 # see MS-NLMP section 3.4
                return WindowsError::NTStatus::STATUS_SUCCESS
Severity: Minor
Found in lib/ruby_smb/gss/provider/ntlm.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 compress_chunk has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def self.compress_chunk(chunk)
        blob = chunk
        out = ''
        pow2 = 0x10
        l_mask3 = 0x1002
Severity: Minor
Found in lib/ruby_smb/compression/lznt1.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 negotiate_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def negotiate_response(raw_data)
        response = nil
        if smb1
          packet = RubySMB::SMB1::Packet::NegotiateResponseExtended.read raw_data

Severity: Minor
Found in lib/ruby_smb/client/negotiation.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 read has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def read(bytes: size, offset: 0)
        max_read = tree.client.server_max_read_size
        max_read = 65536 unless tree.client.server_supports_multi_credit
        atomic_read_size = [bytes, max_read].min
        credit_charge = 0
Severity: Minor
Found in lib/ruby_smb/smb2/file.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 transaction2_smb1_find_first2 has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

              def transaction2_smb1_find_first2(request)
                # see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/f93455dc-2bd7-4698-b91e-8c9c7abd63cf
                raise ArgumentError unless request.data_block.trans2_parameters.is_a? SMB1::Packet::Trans2::FindFirst2RequestTrans2Parameters

                subdir, _, search_pattern = request.data_block.trans2_parameters.filename.encode.gsub('\\', File::SEPARATOR).rpartition(File::SEPARATOR)
Severity: Major
Found in lib/ruby_smb/server/share/provider/disk/processor/query.rb - About 2 hrs to fix

    Method _open has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def _open(filename:, attributes: nil, options: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
                        impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE, read: true, write: false, delete: false)
    
            create_request = RubySMB::SMB2::Packet::CreateRequest.new
            create_request = set_header_fields(create_request)
    Severity: Major
    Found in lib/ruby_smb/smb2/tree.rb - About 2 hrs to fix

      Method handle_smb1 has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def handle_smb1(raw_request, header)
              session = @session_table[header.uid]
      
              if session.nil? && !(header.command == SMB1::Commands::SMB_COM_SESSION_SETUP_ANDX && header.uid == 0)
                response = SMB1::Packet::EmptyPacket.new
      Severity: Minor
      Found in lib/ruby_smb/server/server_client.rb - About 1 hr to fix

        Method ioctl_send_recv has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def ioctl_send_recv(action, options={})
                request = set_header_fields(RubySMB::SMB2::Packet::IoctlRequest.new(options))
                request.ctl_code = 0x0011C017
                request.flags.is_fsctl = 0x00000001
                # TODO: handle fragmentation when the request size > MAX_XMIT_FRAG
        Severity: Minor
        Found in lib/ruby_smb/smb2/pipe.rb - About 1 hr to fix

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

                def read(bytes: @size, offset: 0)
                  atomic_read_size = [bytes, @tree.client.max_buffer_size].min
                  remaining_bytes = bytes
                  data = ''
          
          
          Severity: Minor
          Found in lib/ruby_smb/smb1/file.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 smb2_authenticate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def smb2_authenticate
                  response = smb2_ntlmssp_negotiate
                  challenge_packet = smb2_ntlmssp_challenge_packet(response)
                  if @dialect == '0x0311'
                    update_preauth_hash(challenge_packet)
          Severity: Minor
          Found in lib/ruby_smb/client/authentication.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 _open has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def _open(filename:, flags: nil, options: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
                          impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE, read: true, write: false, delete: false)
                  nt_create_andx_request = RubySMB::SMB1::Packet::NtCreateAndxRequest.new
                  nt_create_andx_request = set_header_fields(nt_create_andx_request)
          
          
          Severity: Minor
          Found in lib/ruby_smb/smb1/tree.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(args = nil)
                  if args.nil?
                    super
                  elsif args.is_a? String
                    super(args)
          Severity: Minor
          Found in lib/ruby_smb/error.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 drs_bind has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def drs_bind
                  drs_extensions_int = DrsExtensionsInt.new(
                    dw_flags: DRS_EXT_GETCHGREQ_V6 | DRS_EXT_GETCHGREPLY_V6 | DRS_EXT_GETCHGREQ_V8 | DRS_EXT_STRONG_ENCRYPTION,
                    dw_ext_caps: 0xFFFFFFFF
                  )
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/drsr.rb - About 1 hr to fix

            Method fetch_alias_referent has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_alias_referent(current: parent, ref: get_parameter(:ref_to), name: nil)
                  return if current.nil?
                  if current.get_parameter(:ref_to) == ref
                    raise ArgumentError.new(
                      "Pointer alias refering to #{ref} cannot be found. This referent "\
            Severity: Minor
            Found in lib/ruby_smb/dcerpc/ndr.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 do_num_bytes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def do_num_bytes(struct_offset = 0, is_deferred: false)
                  sum = 0
                  if is_deferred
                    if is_a?(NdrStruct) && self.class.superclass.has_conformant_array
                      # align :max_count since it will be placed in front of the structure.
            Severity: Minor
            Found in lib/ruby_smb/dcerpc/ndr.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 negotiate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def negotiate
                    request_packet  = negotiate_request
                    raw_response    = send_recv(request_packet)
                    response_packet = negotiate_response(raw_response)
                    # The list of dialect identifiers sent to the server is stored
            Severity: Minor
            Found in lib/ruby_smb/client/negotiation.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 extend_top_level_class has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def extend_top_level_class
                  current = self
                  loop do
                    current.extend(TopLevelPlugin) unless current.is_a?(TopLevelPlugin)
                    if current.parent.nil?
            Severity: Minor
            Found in lib/ruby_smb/dcerpc/ndr.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 find has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                    def find(src, target, max_len)
                      result_offset = 0
                      result_length = 0
                      1.upto(max_len - 1) do |i|
                        offset = src.rindex(target[0...i])
            Severity: Minor
            Found in lib/ruby_smb/compression/lznt1.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 read has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def read(bytes: size, offset: 0)
                    max_read = tree.client.server_max_read_size
                    max_read = 65536 unless tree.client.server_supports_multi_credit
                    atomic_read_size = [bytes, max_read].min
                    credit_charge = 0
            Severity: Minor
            Found in lib/ruby_smb/smb2/file.rb - About 1 hr to fix

              Method send_recv has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def send_recv(packet, encrypt: false)
                    version = packet.packet_smb_version
                    case version
                    when 'SMB1'
                      packet.smb_header.uid = self.user_id if self.user_id
              Severity: Minor
              Found in lib/ruby_smb/client.rb - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language