rapid7/ruby_smb

View on GitHub
lib/ruby_smb/gss/provider/ntlm.rb

Summary

Maintainability
C
1 day
Test Coverage

Method process_ntlm_type3 has 66 lines of code (exceeds 25 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: Major
Found in lib/ruby_smb/gss/provider/ntlm.rb - About 2 hrs to fix

    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 process_gss_type3 has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

              def process_gss_type3(gss_api)
                neg_token_init = Hash[RubySMB::Gss.asn1dig(gss_api, 0).value.map { |obj| [obj.tag, obj.value[0].value] }]
                raw_type3_msg = neg_token_init[2]
    
                type3_msg = Net::NTLM::Message.parse(raw_type3_msg)
    Severity: Minor
    Found in lib/ruby_smb/gss/provider/ntlm.rb - About 1 hr to fix

      Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def process(request_buffer=nil)
                  if request_buffer.nil?
                    # this is only NTLMSSP (as opposed to SPNEGO + NTLMSSP)
                    buffer = OpenSSL::ASN1::ASN1Data.new([
                      Gss::OID_SPNEGO,
      Severity: Minor
      Found in lib/ruby_smb/gss/provider/ntlm.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 process_gss_type3 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                    def process_gss_type3(gss_api)
                      neg_token_init = Hash[RubySMB::Gss.asn1dig(gss_api, 0).value.map { |obj| [obj.tag, obj.value[0].value] }]
                      raw_type3_msg = neg_token_init[2]
          
                      type3_msg = Net::NTLM::Message.parse(raw_type3_msg)
          Severity: Minor
          Found in lib/ruby_smb/gss/provider/ntlm.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

          Avoid too many return statements within this method.
          Open

                        return WindowsError::NTStatus::STATUS_LOGON_FAILURE
          Severity: Major
          Found in lib/ruby_smb/gss/provider/ntlm.rb - About 30 mins to fix

            Method process has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                      def process(request_buffer=nil)
                        if request_buffer.nil?
                          # this is only NTLMSSP (as opposed to SPNEGO + NTLMSSP)
                          buffer = OpenSSL::ASN1::ASN1Data.new([
                            Gss::OID_SPNEGO,
            Severity: Minor
            Found in lib/ruby_smb/gss/provider/ntlm.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status