rapid7/metasploit-framework

View on GitHub
lib/msf/core/exploit/remote/dns/enumeration.rb

Summary

Maintainability
F
3 days
Test Coverage

File enumeration.rb has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf

###
#
# This module exposes methods for querying a remote DNS service
Severity: Minor
Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 3 hrs to fix

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

      def dns_reverse(cidr, threads)
        unless cidr
          print_error 'ENUM_RVL enabled, but no IPRANGE specified'
          return
        end
    Severity: Minor
    Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_bruteforce has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def dns_bruteforce(domain, wordlist, threads)
        return if wordlist.blank?
        threads = 1 if threads <= 0
    
        queue = []
    Severity: Minor
    Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_axfr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def dns_axfr(domain)
        if datastore['NS'].blank?
          nameservers = dns_get_ns(domain)
          nameservers.map! { |ns| Rex::Socket.dotted_ip?(ns) ? ns : dns_get_a(ns, 'DNS AXFR records') }
          nameservers.compact!
    Severity: Minor
    Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_srv has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def dns_get_srv(domain)
        print_status("Querying DNS SRV records for #{domain}")
        srv_protos = %w(tcp udp tls)
        srv_record_types = %w(
          gc kerberos ldap test sips sip aix finger ftp http
    Severity: Minor
    Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_tld has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def dns_get_tld(domain)
        print_status("Querying DNS TLD records for #{domain}")
        domain_ = domain.split('.')
        domain_.pop
        domain_ = domain_.join('.')
    Severity: Minor
    Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 1 hr to fix

      Method dns_get_srv has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def dns_get_srv(domain)
          print_status("Querying DNS SRV records for #{domain}")
          srv_protos = %w(tcp udp tls)
          srv_record_types = %w(
            gc kerberos ldap test sips sip aix finger ftp http
      Severity: Minor
      Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 1 hr to fix

        Method dns_axfr has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def dns_axfr(domain)
            if datastore['NS'].blank?
              nameservers = dns_get_ns(domain)
              nameservers.map! { |ns| Rex::Socket.dotted_ip?(ns) ? ns : dns_get_a(ns, 'DNS AXFR records') }
              nameservers.compact!
        Severity: Minor
        Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 1 hr to fix

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

            def dns_reverse(cidr, threads)
              unless cidr
                print_error 'ENUM_RVL enabled, but no IPRANGE specified'
                return
              end
          Severity: Minor
          Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 1 hr to fix

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

              def dns_bruteforce(domain, wordlist, threads)
                return if wordlist.blank?
                threads = 1 if threads <= 0
            
                queue = []
            Severity: Minor
            Found in lib/msf/core/exploit/remote/dns/enumeration.rb - About 1 hr to fix

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

                def dns_get_a(domain, type='DNS A records', displayed=false)
                  resp = dns_query(domain, 'A')
                  return if resp.blank? || resp.answer.blank?
              
                  records = []
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_mx has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_mx(domain)
                  print_status("Querying DNS MX records for #{domain}")
                  begin
                    resp = dns_query(domain, 'MX')
                    return if resp.blank? || resp.answer.blank?
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_cname has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_cname(domain)
                  print_status("Querying DNS CNAME records for #{domain}")
                  resp = dns_query(domain, 'CNAME')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_ptr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_ptr(ip)
                  resp = dns_query(ip, 'PTR')
                  return if resp.blank? || resp.answer.blank?
              
                  records = []
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_ns has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_ns(domain)
                  print_status("Querying DNS NS records for #{domain}")
                  resp = dns_query(domain, 'NS')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_txt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_txt(domain)
                  print_status("Querying DNS TXT records for #{domain}")
                  resp = dns_query(domain, 'TXT')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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 dns_get_soa has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def dns_get_soa(domain)
                  print_status("Querying DNS SOA records for #{domain}")
                  resp = dns_query(domain, 'SOA')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Minor
              Found in lib/msf/core/exploit/remote/dns/enumeration.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

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                def dns_get_soa(domain)
                  print_status("Querying DNS SOA records for #{domain}")
                  resp = dns_query(domain, 'SOA')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Major
              Found in lib/msf/core/exploit/remote/dns/enumeration.rb and 2 other locations - About 1 hr to fix
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 132..145
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 169..182

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                def dns_get_ns(domain)
                  print_status("Querying DNS NS records for #{domain}")
                  resp = dns_query(domain, 'NS')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Major
              Found in lib/msf/core/exploit/remote/dns/enumeration.rb and 2 other locations - About 1 hr to fix
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 132..145
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 200..213

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                def dns_get_cname(domain)
                  print_status("Querying DNS CNAME records for #{domain}")
                  resp = dns_query(domain, 'CNAME')
                  return if resp.blank? || resp.answer.blank?
              
              
              Severity: Major
              Found in lib/msf/core/exploit/remote/dns/enumeration.rb and 2 other locations - About 1 hr to fix
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 169..182
              lib/msf/core/exploit/remote/dns/enumeration.rb on lines 200..213

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 61.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status