rapid7/metasploit-framework

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

Summary

Maintainability
F
6 days
Test Coverage

File dns.rb has 611 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
module Ui
module Console
module CommandDispatcher

Severity: Major
Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 1 day to fix

    Method add_dns has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_dns(*args)
        rules = ['*']
        first_rule = true
        comm = nil
        resolvers = []
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/dns.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

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

      def cmd_dns_tabs(str, words)
        return if driver.framework.dns_resolver.nil?
    
        subcommands = %w[ add add-static delete flush-cache flush-entries flush-static help print query remove remove-static reset-config resolve ]
        if words.length == 1
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/dns.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

    Class DNS has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class DNS
    
      include Msf::Ui::Console::CommandDispatcher
    
      ADD_USAGE = 'dns [add] [--index <insertion index>] [--rule <wildcard DNS entry>] [--session <session id>] <resolver> ...'.freeze
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 3 hrs to fix

      Method add_dns has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def add_dns(*args)
          rules = ['*']
          first_rule = true
          comm = nil
          resolvers = []
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 2 hrs to fix

        Method resolve_dns has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def resolve_dns(*args)
            names = []
            query_type = Dnsruby::Types::A
        
            @@resolve_opts.parse(args) do |opt, idx, val|
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/dns.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 resolve_dns has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def resolve_dns(*args)
            names = []
            query_type = Dnsruby::Types::A
        
            @@resolve_opts.parse(args) do |opt, idx, val|
        Severity: Major
        Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 2 hrs to fix

          Method cmd_dns_tabs has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def cmd_dns_tabs(str, words)
              return if driver.framework.dns_resolver.nil?
          
              subcommands = %w[ add add-static delete flush-cache flush-entries flush-static help print query remove remove-static reset-config resolve ]
              if words.length == 1
          Severity: Major
          Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 2 hrs to fix

            Method reset_config_dns has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def reset_config_dns(*args)
                add_system_resolver = false
                should_confirm = true
                @@reset_config_opts.parse(args) do |opt, idx, val|
                  case opt
            Severity: Minor
            Found in lib/msf/ui/console/command_dispatcher/dns.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 print_dns has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def print_dns
                default_domain = 'N/A'
                if resolver.defname? && resolver.domain.present?
                  default_domain = resolver.domain
                end
            Severity: Minor
            Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 2 hrs to fix

              Method cmd_dns has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def cmd_dns(*args)
                  if driver.framework.dns_resolver.nil?
                    print_warning("Run the #{Msf::Ui::Tip.highlight("save")} command and restart the console for this feature configuration to take effect.")
                    return
                  end
              Severity: Minor
              Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 1 hr to fix

                Method cmd_dns_help has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def cmd_dns_help(*args)
                    if args.first.present?
                      handler = "#{args.first.gsub('-', '_')}_dns"
                      if respond_to?("#{handler}_help")
                        # if it is a valid command with dedicated help information
                Severity: Minor
                Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 1 hr to fix

                  Method remove_dns has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def remove_dns(*args)
                      remove_ids = []
                      @@remove_opts.parse(args) do |opt, idx, val|
                        case opt
                        when '-i', '--index'
                  Severity: Minor
                  Found in lib/msf/ui/console/command_dispatcher/dns.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 reset_config_dns has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def reset_config_dns(*args)
                      add_system_resolver = false
                      should_confirm = true
                      @@reset_config_opts.parse(args) do |opt, idx, val|
                        case opt
                  Severity: Minor
                  Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 1 hr to fix

                    Method cmd_dns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def cmd_dns(*args)
                        if driver.framework.dns_resolver.nil?
                          print_warning("Run the #{Msf::Ui::Tip.highlight("save")} command and restart the console for this feature configuration to take effect.")
                          return
                        end
                    Severity: Minor
                    Found in lib/msf/ui/console/command_dispatcher/dns.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 print_dns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def print_dns
                        default_domain = 'N/A'
                        if resolver.defname? && resolver.domain.present?
                          default_domain = resolver.domain
                        end
                    Severity: Minor
                    Found in lib/msf/ui/console/command_dispatcher/dns.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

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

                      def prettify_comm(comm, upstream_resolver)
                        if !Rex::Socket.is_ip_addr?(upstream_resolver.destination)
                          'N/A'
                        elsif comm.nil?
                          channel = Rex::Socket::SwitchBoard.best_comm(upstream_resolver.destination)
                    Severity: Minor
                    Found in lib/msf/ui/console/command_dispatcher/dns.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 session_ids.select { |id| id.start_with?(str) }
                    Severity: Major
                    Found in lib/msf/ui/console/command_dispatcher/dns.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/dns.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return ip_addresses.map(&:to_s).select { |ip_address| ip_address.start_with?(str) }
                        Severity: Major
                        Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                return subcommands.select { |sc| sc.start_with?(str) }
                          Severity: Major
                          Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return resolver.static_hostnames.each.select { |hostname,_| hostname.downcase.start_with?(str.downcase) }.map { |hostname,_| hostname }
                            Severity: Major
                            Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

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

                                Avoid too many return statements within this method.
                                Open

                                        return @@remove_opts.option_keys.select { |opt| opt.start_with?(str) }
                                Severity: Major
                                Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return families.select { |family| family.downcase.start_with?(str.downcase) }
                                  Severity: Major
                                  Found in lib/msf/ui/console/command_dispatcher/dns.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/dns.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return resolver.static_hostnames.each.select { |hostname,_| hostname.downcase.start_with?(str.downcase) }.map { |hostname,_| hostname }
                                      Severity: Major
                                      Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 30 mins to fix

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

                                          def remove_static_dns(*args)
                                            if args.length < 1
                                              raise ::ArgumentError.new('A hostname must be provided')
                                            end
                                        
                                        
                                        Severity: Minor
                                        Found in lib/msf/ui/console/command_dispatcher/dns.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