rapid7/ruby_smb

View on GitHub

Showing 307 of 307 total issues

Method drs_bind has a Cognitive Complexity of 10 (exceeds 5 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

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 recv_struct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def recv_struct(struct)
        raise Error::CommunicationError, 'Connection has already been closed' if @tcp_socket.closed?
        if IO.select([@tcp_socket], nil, nil, @read_timeout).nil?
          raise Error::CommunicationError, "Read timeout expired when reading from the Socket (timeout=#{@read_timeout})"
        end
Severity: Minor
Found in lib/ruby_smb/dcerpc/client.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 name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def name
          sid = case sub_authority.size
          when 1
            WELL_KNOWN_SID_NAME[[identifier_authority[-1].to_i, sub_authority[0].to_i]]
          when 2
Severity: Minor
Found in lib/ruby_smb/dcerpc/samr/rpc_sid.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 samr_enumerate_domains_in_sam_server has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def samr_enumerate_domains_in_sam_server(server_handle:, enumeration_context: 0)
        samr_enum_domains_request = SamrEnumerateDomainsInSamServerRequest.new(
          server_handle: server_handle,
          enumeration_context: enumeration_context,
          prefered_maximum_length: 0xFFFFFFFF
Severity: Minor
Found in lib/ruby_smb/dcerpc/samr.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 write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def write(data:'', offset: 0)
        max_write = tree.client.server_max_write_size
        max_write = 65536 unless tree.client.server_supports_multi_credit
        buffer            = data.dup
        bytes             = data.length
Severity: Minor
Found in lib/ruby_smb/smb2/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 samr_enumerate_users_in_domain has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def samr_enumerate_users_in_domain(domain_handle:,
                                         enumeration_context: 0,
                                         user_account_control: USER_NORMAL_ACCOUNT |
                                                               USER_WORKSTATION_TRUST_ACCOUNT |
                                                               USER_SERVER_TRUST_ACCOUNT |
Severity: Minor
Found in lib/ruby_smb/dcerpc/samr.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_nt_create_andx_smb1 has 27 lines of code (exceeds 25 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 1 hr to fix

    Method process_ntlm_type1 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

              def process_ntlm_type1(type1_msg)
                type2_msg = Net::NTLM::Message::Type2.new.tap do |msg|
                  msg.target_name = 'LOCALHOST'.encode('UTF-16LE').b
                  msg.flag = 0
                  %i{ KEY56 KEY128 KEY_EXCHANGE UNICODE TARGET_INFO VERSION_INFO }.each do |flag|
    Severity: Minor
    Found in lib/ruby_smb/gss/provider/ntlm.rb - About 1 hr to fix

      Method do_num_bytes has 27 lines of code (exceeds 25 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

        Method do_transactions2_smb1 has 27 lines of code (exceeds 25 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 1 hr to fix

          Method samr_enumerate_users_in_domain has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def samr_enumerate_users_in_domain(domain_handle:,
                                                   enumeration_context: 0,
                                                   user_account_control: USER_NORMAL_ACCOUNT |
                                                                         USER_WORKSTATION_TRUST_ACCOUNT |
                                                                         USER_SERVER_TRUST_ACCOUNT |
          Severity: Minor
          Found in lib/ruby_smb/dcerpc/samr.rb - About 1 hr to fix

            Method samr_enumerate_domains_in_sam_server has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def samr_enumerate_domains_in_sam_server(server_handle:, enumeration_context: 0)
                    samr_enum_domains_request = SamrEnumerateDomainsInSamServerRequest.new(
                      server_handle: server_handle,
                      enumeration_context: enumeration_context,
                      prefered_maximum_length: 0xFFFFFFFF
            Severity: Minor
            Found in lib/ruby_smb/dcerpc/samr.rb - About 1 hr to fix

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                        loop do
                          break if dcerpc_response.pdu_header.pfc_flags.last_frag == 1
                          raw_data = read(bytes: @tree.client.max_buffer_size)
                          dcerpc_response = dcerpc_response_from_raw_response(raw_data)
                          if options[:auth_level] &&
              Severity: Major
              Found in lib/ruby_smb/smb1/pipe.rb and 1 other location - About 1 hr to fix
              lib/ruby_smb/smb2/pipe.rb on lines 148..156

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                        loop do
                          break if dcerpc_response.pdu_header.pfc_flags.last_frag == 1
                          raw_data = read(bytes: @tree.client.max_buffer_size)
                          dcerpc_response = dcerpc_response_from_raw_response(raw_data)
                          if options[:auth_level] &&
              Severity: Major
              Found in lib/ruby_smb/smb2/pipe.rb and 1 other location - About 1 hr to fix
              lib/ruby_smb/smb1/pipe.rb on lines 150..158

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method drs_domain_controller_info has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def drs_domain_controller_info(h_drs, domain)
                      drs_domain_controller_info_request = DrsDomainControllerInfoRequest.new(
                        h_drs: h_drs,
                        pmsg_in: {
                          switch_type: 1,
              Severity: Minor
              Found in lib/ruby_smb/dcerpc/drsr.rb - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      def close_service_handle(svc_handle)
                        csh_request = CloseServiceHandleRequest.new(h_sc_object: svc_handle)
                        response = dcerpc_request(csh_request)
                        begin
                          csh_response = CloseServiceHandleResponse.read(response)
                Severity: Minor
                Found in lib/ruby_smb/dcerpc/svcctl.rb and 1 other location - About 1 hr to fix
                lib/ruby_smb/dcerpc/svcctl.rb on lines 522..533

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 47.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      def delete_service(svc_handle)
                        ds_request = DeleteServiceRequest.new(lp_sc_handle: svc_handle)
                        response = dcerpc_request(ds_request)
                        begin
                          ds_response = DeleteServiceResponse.read(response)
                Severity: Minor
                Found in lib/ruby_smb/dcerpc/svcctl.rb and 1 other location - About 1 hr to fix
                lib/ruby_smb/dcerpc/svcctl.rb on lines 502..513

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 47.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      class CreateContextRequest < CreateContext
                        delayed_io :data, read_abs_offset: -> { abs_offset + data_offset } do
                          choice  :data, selection: -> { name.snapshot } do
                            create_durable_handle_request       CREATE_DURABLE_HANDLE,       length: :data_length
                            create_durable_handle_v2_request    CREATE_DURABLE_HANDLE_V2,    length: :data_length
                Severity: Minor
                Found in lib/ruby_smb/smb2/create_context/request.rb and 1 other location - About 1 hr to fix
                lib/ruby_smb/smb2/create_context/response.rb on lines 45..53

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 47.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      class CreateContextResponse < CreateContext
                        delayed_io :data, read_abs_offset: -> { abs_offset + data_offset } do
                          choice  :data, selection: -> { name.snapshot } do
                            create_durable_handle_response       CREATE_DURABLE_HANDLE,       length: :data_length
                            create_durable_handle_v2_response    CREATE_DURABLE_HANDLE_V2,    length: :data_length
                Severity: Minor
                Found in lib/ruby_smb/smb2/create_context/response.rb and 1 other location - About 1 hr to fix
                lib/ruby_smb/smb2/create_context/request.rb on lines 47..55

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 47.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                    def logoff!
                      if smb2 || smb3
                        request      = RubySMB::SMB2::Packet::LogoffRequest.new
                        raw_response = send_recv(request)
                        response     = RubySMB::SMB2::Packet::LogoffResponse.read(raw_response)
                Severity: Minor
                Found in lib/ruby_smb/client.rb - About 55 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