rapid7/metasploit-framework

View on GitHub
modules/post/windows/gather/enum_ad_users.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method initialize has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Windows Gather Active Directory Users',
Severity: Minor
Found in modules/post/windows/gather/enum_ad_users.rb - About 1 hr to fix

    Method store_username has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def store_username(username, uac, lockout_time, realm, domain_ip)
        service_data = {
          address: domain_ip,
          port: 445,
          service_name: 'smb',
    Severity: Minor
    Found in modules/post/windows/gather/enum_ad_users.rb - About 1 hr to fix

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

        def store_username(username, uac, lockout_time, realm, domain_ip)
      Severity: Minor
      Found in modules/post/windows/gather/enum_ad_users.rb - About 35 mins to fix

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

          def run
            @user_fields = USER_FIELDS.dup
        
            if datastore['ADDITIONAL_FIELDS']
              additional_fields = datastore['ADDITIONAL_FIELDS'].gsub(/\s+/, '').split(',')
        Severity: Minor
        Found in modules/post/windows/gather/enum_ad_users.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 query_filter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def query_filter
            inner_filter = '(objectCategory=person)(objectClass=user)'
            inner_filter << '(!(lockoutTime>=1))' if datastore['EXCLUDE_LOCKED']
            inner_filter << '(!(userAccountControl:1.2.840.113556.1.4.803:=2))' if datastore['EXCLUDE_DISABLED']
            inner_filter << "(memberof:1.2.840.113556.1.4.1941:=#{datastore['GROUP_MEMBER']})" if datastore['GROUP_MEMBER']
        Severity: Minor
        Found in modules/post/windows/gather/enum_ad_users.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