rapid7/metasploit-credential

View on GitHub
lib/metasploit/credential/creation.rb

Summary

Maintainability
D
2 days
Test Coverage

File creation.rb has 323 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rex/socket'

# Implements a set of "convenience methods" for creating credentials and related portions of the object graph.  Creates
# {Metasploit::Credential::Core} objects and their attendant relationships as well as {Metasploit::Credential::Login}
# objects and their attendant `Mdm::Host` and `Mdm::Service` objects.
Severity: Minor
Found in lib/metasploit/credential/creation.rb - About 3 hrs to fix

    Method create_credential_login has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_credential_login(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.rb - About 3 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 create_credential_and_login has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_credential_and_login(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.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 create_cracked_credential has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_cracked_credential(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.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 create_cracked_credential has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create_cracked_credential(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

      Method create_credential_private has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_credential_private(opts={})
          return nil unless active_db?
          private_data = opts.fetch(:private_data)
          private_type = opts.fetch(:private_type)
      
      
      Severity: Minor
      Found in lib/metasploit/credential/creation.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 create_credential has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def create_credential(opts={})
          return nil unless active_db?
      
          if self.respond_to?(:[]) and self[:task]
            opts[:task_id] ||= self[:task].record.id
      Severity: Minor
      Found in lib/metasploit/credential/creation.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 create_credential_private has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_credential_private(opts={})
          return nil unless active_db?
          private_data = opts.fetch(:private_data)
          private_type = opts.fetch(:private_type)
      
      
      Severity: Minor
      Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

        Method create_credential_login has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_credential_login(opts={})
            return nil unless active_db?
        
            if self.respond_to?(:[]) and self[:task]
              opts[:task_id] ||= self[:task].record.id
        Severity: Minor
        Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

          Method create_credential_and_login has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create_credential_and_login(opts={})
              return nil unless active_db?
          
              if self.respond_to?(:[]) and self[:task]
                opts[:task_id] ||= self[:task].record.id
          Severity: Minor
          Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

              def create_credential(opts={})
                return nil unless active_db?
            
                if self.respond_to?(:[]) and self[:task]
                  opts[:task_id] ||= self[:task].record.id
            Severity: Minor
            Found in lib/metasploit/credential/creation.rb - About 1 hr to fix

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

                def create_credential_core(opts={})
                  return nil unless active_db?
              
                  if self.respond_to?(:[]) and self[:task]
                    opts[:task_id] ||= self[:task].record.id
              Severity: Minor
              Found in lib/metasploit/credential/creation.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 invalidate_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def invalidate_login(opts = {})
                  return nil unless active_db?
                  address     = opts.fetch(:address)
                  return nil unless Rex::Socket.is_ipv4?(address) || Rex::Socket.is_ipv6?(address)
                  port        = opts.fetch(:port)
              Severity: Minor
              Found in lib/metasploit/credential/creation.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

              There are no issues that match your filters.

              Category
              Status