rapid7/metasploit-framework

View on GitHub
lib/msf/ui/console/command_dispatcher/creds.rb

Summary

Maintainability
F
6 days
Test Coverage

Method creds_search has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

  def creds_search(*args)
    host_ranges   = []
    origin_ranges = []
    port_ranges   = []
    svcs          = []
Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 1 day 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

File creds.rb has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rexml/document'
require 'metasploit/framework/password_crackers/hashcat/formatter'
require 'metasploit/framework/password_crackers/jtr/formatter'

module Msf
Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 7 hrs to fix

    Method creds_search has 166 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def creds_search(*args)
        host_ranges   = []
        origin_ranges = []
        port_ranges   = []
        svcs          = []
    Severity: Major
    Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 6 hrs to fix

      Method creds_add has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def creds_add(*args)
          params = args.inject({}) do |hsh, n|
            opt = n.split(':') # Splitting the string on colons.
            hsh[opt[0]] = opt[1..-1].join(':') # everything before the first : is the key, reasembling everything after the colon. why ntlm hashes
            hsh
      Severity: Minor
      Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 4 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 cmd_creds_help has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def cmd_creds_help
          print_line
          print_line "With no sub-command, list credentials. If an address range is"
          print_line "given, show only credentials with logins on hosts within that"
          print_line "range."
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 3 hrs to fix

        Method filtered_query has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def filtered_query(query, opts, origin_ranges, host_ranges)
            query.each do |core|
              # Exclude non-blank username creds if that's what we're after
              if opts[:user] == '' && core.public && !(core.public.username.blank?)
                next
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/creds.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 creds_add has 84 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def creds_add(*args)
            params = args.inject({}) do |hsh, n|
              opt = n.split(':') # Splitting the string on colons.
              hsh[opt[0]] = opt[1..-1].join(':') # everything before the first : is the key, reasembling everything after the colon. why ntlm hashes
              hsh
        Severity: Major
        Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 3 hrs to fix

          Method filtered_query has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def filtered_query(query, opts, origin_ranges, host_ranges)
              query.each do |core|
                # Exclude non-blank username creds if that's what we're after
                if opts[:user] == '' && core.public && !(core.public.username.blank?)
                  next
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 1 hr to fix

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

              def cmd_creds(*args)
                return unless active?
            
                # Short-circuit help
                if args.delete("-h") || args.delete("--help")
            Severity: Minor
            Found in lib/msf/ui/console/command_dispatcher/creds.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

            Avoid too many return statements within this method.
            Open

                      return
            Severity: Major
            Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return
              Severity: Major
              Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return
                Severity: Major
                Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return
                  Severity: Major
                  Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                   return
                    Severity: Major
                    Found in lib/msf/ui/console/command_dispatcher/creds.rb - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status