rapid7/ruby_smb

View on GitHub

Showing 174 of 307 total issues

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

def run_authentication(address, smb1, smb2, smb3, username, password)
Severity: Minor
Found in examples/authenticate.rb - About 45 mins to fix

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

        def sanitize_parameters!(obj_class, params)
          res = super
    
          type_class = params[:type]
          # Let the BinData::Array sanitization routine deal with "no type provided"
    Severity: Minor
    Found in lib/ruby_smb/dcerpc/ndr.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 do_session_setup_andx_smb1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def do_session_setup_andx_smb1(request, session)
              session_id = request.smb_header.uid
              if session_id == 0
                session_id = rand(1..0x10000)
                session = @session_table[session_id] = Server::Session.new(session_id)
    Severity: Minor
    Found in lib/ruby_smb/server/server_client/session_setup.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_smb3_capabilities has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_smb3_capabilities(response_packet)
            nc = response_packet.find_negotiate_context(
              RubySMB::SMB2::NegotiateContext::SMB2_PREAUTH_INTEGRITY_CAPABILITIES
            )
            @preauth_integrity_hash_algorithm = RubySMB::SMB2::PreauthIntegrityCapabilities::HASH_ALGORITM_MAP[nc&.data&.hash_algorithms&.first]
    Severity: Minor
    Found in lib/ruby_smb/client/negotiation.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 net_share_enum_all has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def net_share_enum_all(host)
            host = "\\\\#{host}" unless host.start_with?('\\\\')
            bind(endpoint: RubySMB::Dcerpc::Srvsvc)
    
            net_share_enum_all_request_packet = RubySMB::Dcerpc::Srvsvc::NetShareEnumAllRequest.new(server_name: host)
    Severity: Minor
    Found in lib/ruby_smb/dcerpc/srvsvc.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 display_field has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def display_field(field, depth = 0, parents = [])
          my_parents = parents.dup
          field_str = ''
          name = field[:name]
          if field[:class] == BinData::Array
    Severity: Minor
    Found in lib/ruby_smb/generic_packet.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 assign has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def assign(val)
          if val == :null
            @ref_id = 0
          elsif is_alias?
            ref_field = fetch_alias_referent
    Severity: Minor
    Found in lib/ruby_smb/dcerpc/ndr.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 do_nt_create_andx_smb1 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

                  def do_nt_create_andx_smb1(request)
                    path = request.data_block.file_name.snapshot
                    path = path.encode.gsub(/\/|\\/, File::SEPARATOR)
                    path = path.delete_prefix(File::SEPARATOR)
                    local_path = get_local_path(path)
    Severity: Minor
    Found in lib/ruby_smb/server/share/provider/disk/processor/create.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 run_negotiation has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def run_negotiation(address, smb1, smb2, smb3, netbios_name)
    Severity: Minor
    Found in examples/negotiate_with_netbios_service.rb - About 35 mins to fix

      Method run_negotiation has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def run_negotiation(address, smb1, smb2, smb3, opts = {})
      Severity: Minor
      Found in examples/negotiate.rb - About 35 mins to fix

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

              def send_packet(packet, nbss_header: true)
                data = nbss_header ? nbss(packet) : ''
                data << packet.to_binary_s
                bytes_written = 0
                begin
        Severity: Minor
        Found in lib/ruby_smb/dispatcher/socket.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 handle_negotiate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def handle_negotiate(raw_request)
                  response = nil
                  case raw_request[0...4].unpack1('L>')
                  when RubySMB::SMB1::SMB_PROTOCOL_ID
                    request = SMB1::Packet::NegotiateRequest.read(raw_request)
        Severity: Minor
        Found in lib/ruby_smb/server/server_client/negotiation.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 enum_registry_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def enum_registry_key(key, bind: true)
                bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
        
                root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
                root_key_handle = open_root_key(root_key)
        Severity: Minor
        Found in lib/ruby_smb/dcerpc/winreg.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 do_num_bytes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_num_bytes
              sum = 0
        
              if should_process_max_count?
                # count max_count (4 bytes)
        Severity: Minor
        Found in lib/ruby_smb/dcerpc/ndr.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 decompress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.decompress(buf, length_check: true)
                out = ''
                until buf.empty?
                  header = buf.unpack1('v')
                  length = (header & 0xfff) + 1
        Severity: Minor
        Found in lib/ruby_smb/compression/lznt1.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 compress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.compress(buf, chunk_size: 0x1000)
                out = ''
                until buf.empty?
                  chunk = buf[0...chunk_size]
                  compressed = compress_chunk(chunk)
        Severity: Minor
        Found in lib/ruby_smb/compression/lznt1.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 do_write has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def do_write(io)
              if should_process_max_count?
                max_count = retrieve_max_count
                io.writebytes([max_count].pack('L<')) if max_count
        
        
        Severity: Minor
        Found in lib/ruby_smb/dcerpc/ndr.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 add_attrtyp_from_oid has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def add_attrtyp_from_oid(oid, to_field: :p_partial_attr_set)
                  last_value = oid.split('.').last.to_i
                  binary_oid = OpenSSL::ASN1::ObjectId.new(oid).to_der[2..-1]
                  if last_value < 128
                    oid_prefix = binary_oid[0...-1].bytes
        Severity: Minor
        Found in lib/ruby_smb/dcerpc/drsr.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 do_transactions2_smb1 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                      def do_transactions2_smb1(request)
                        # can't find an example where more than one setup is set, this code makes alot of assumptions that there
                        # are exactly 0 or 1 entries
                        if request.parameter_block.setup.length > 1
                          raise NotImplementedError, 'There are more than 1 TRANSACTION2 setup values'
        Severity: Minor
        Found in lib/ruby_smb/server/share/provider/disk/processor/query.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 add has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                  def add(virtual_pathname)
                    raise ArgumentError.new('paths must be absolute') unless virtual_pathname.absolute?
        
                    path = virtual_pathname.to_s
                    raise ArgumentError.new('paths must be normalized') unless VirtualPathname.cleanpath(path) == path
        Severity: Minor
        Found in lib/ruby_smb/server/share/provider/virtual_disk.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

        Severity
        Category
        Status
        Source
        Language