rapid7/metasploit-framework

View on GitHub
lib/msf/core/post/windows/ldap.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method query_ldap has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

        def query_ldap(session_handle, base, scope, filter, fields)
          vprint_status('Searching LDAP directory')
          search = wldap32.ldap_search_sA(session_handle, base, scope, filter, nil, 0, 4)
          if search['return'] == LDAP_SIZELIMIT_EXCEEDED
            print_error('LDAP_SIZELIMIT_EXCEEDED, parsing what we retrieved, try increasing the MAX_SEARCH value [0:LDAP_NO_LIMIT]')
Severity: Minor
Found in lib/msf/core/post/windows/ldap.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 query_ldap has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def query_ldap(session_handle, base, scope, filter, fields)
          vprint_status('Searching LDAP directory')
          search = wldap32.ldap_search_sA(session_handle, base, scope, filter, nil, 0, 4)
          if search['return'] == LDAP_SIZELIMIT_EXCEEDED
            print_error('LDAP_SIZELIMIT_EXCEEDED, parsing what we retrieved, try increasing the MAX_SEARCH value [0:LDAP_NO_LIMIT]')
Severity: Minor
Found in lib/msf/core/post/windows/ldap.rb - About 2 hrs to fix

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

            def bind_default_ldap_server(size_limit, domain = nil)
              vprint_status('Initializing LDAP connection.')
    
              # If domain is still null the API may be able to handle it...
              init_result = wldap32.ldap_sslinitA(domain, 389, 0)
    Severity: Minor
    Found in lib/msf/core/post/windows/ldap.rb - About 1 hr to fix

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

              def query(filter, max_results, fields, domain = nil)
                domain ||= datastore['DOMAIN']
                domain ||= get_domain
      
                if domain.blank?
      Severity: Minor
      Found in lib/msf/core/post/windows/ldap.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

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

              def query_ldap(session_handle, base, scope, filter, fields)
      Severity: Minor
      Found in lib/msf/core/post/windows/ldap.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status