rapid7/metasploit-framework

View on GitHub
modules/auxiliary/fuzzers/dns/dns_fuzzer.rb

Summary

Maintainability
F
6 days
Test Coverage

Method run_host has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
Open

  def run_host(ip)
    msg = "#{ip}:#{rhost} - DNS -"
    begin
      @lastdata = nil
      @probablyVuln = nil
Severity: Minor
Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 2 days 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 dns_fuzzer.rb has 438 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'bindata'

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::Udp
  include Msf::Exploit::Remote::Tcp
Severity: Minor
Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 6 hrs to fix

    Method run_host has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run_host(ip)
        msg = "#{ip}:#{rhost} - DNS -"
        begin
          @lastdata = nil
          @probablyVuln = nil
    Severity: Major
    Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 5 hrs to fix

      Method dns_send has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

        def dns_send(data,method)
          method = "UDP" if (method == "AUTO" && data.length < 512)
          method = "TCP" if (method == "AUTO" && data.length >= 512)
      
          connect_udp if method == "UDP"
      Severity: Minor
      Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 5 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_send has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def dns_send(data,method)
          method = "UDP" if (method == "AUTO" && data.length < 512)
          method = "TCP" if (method == "AUTO" && data.length >= 512)
      
          connect_udp if method == "UDP"
      Severity: Minor
      Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 1 hr to fix

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

          def dns_alive(method)
            connect_udp if method == "UDP" || method == "AUTO"
            connect if method == "TCP"
        
            payload = ""
        Severity: Minor
        Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 1 hr to fix

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

            def initialize
              super(
                'Name'           => 'DNS and DNSSEC Fuzzer',
                'Description'    => %q{
                  This module will connect to a DNS server and perform DNS and
          Severity: Minor
          Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 1 hr to fix

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

              def dns_alive(method)
                connect_udp if method == "UDP" || method == "AUTO"
                connect if method == "TCP"
            
                payload = ""
            Severity: Minor
            Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.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

            Avoid deeply nested control flow statements.
            Open

                              if !dns_send(pkt,@underlayerProtocol) then return end
            Severity: Major
            Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if @lastdata
                          print_error("#{msg} DNS is DOWN since the request:")
                          print_error(lastdata.unpack('H*'))
                        else
                          print_error("#{msg} DNS is DOWN")
              Severity: Major
              Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 45 mins to fix

                Method build_packet has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def build_packet(dnsOpcode,dnssec,trailingnul,reqns,classns,payload)
                Severity: Minor
                Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 45 mins to fix

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

                    def build_packet(dnsOpcode,dnssec,trailingnul,reqns,classns,payload)
                      pkt = Dns_header.new
                      pkt.opcode = dnsOpcode
                      if trailingnul
                        if @dnsfile
                  Severity: Minor
                  Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.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 true
                  Severity: Major
                  Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                      if !dns_send(pkt,@underlayerProtocol) then return end # If then return end?
                    Severity: Major
                    Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return true
                      Severity: Major
                      Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return true
                        Severity: Major
                        Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              if !dns_send(pkt,@underlayerProtocol) then return end
                          Severity: Major
                          Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                    return false
                            Severity: Major
                            Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              if !dns_send(pkt,@underlayerProtocol) then return end
                              Severity: Major
                              Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                          return
                                Severity: Major
                                Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                    if !dns_send(pkt,@underlayerProtocol) then return end
                                  Severity: Major
                                  Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 30 mins to fix

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

                                      def fix_variables
                                        @fuzz_opcode = datastore['OPCODE'].blank? ? "QUERY,IQUERY,STATUS,UNASSIGNED,NOTIFY,UPDATE" : datastore['OPCODE']
                                        @fuzz_class  = datastore['CLASS'].blank? ? "IN,CH,HS,NONE,ANY" : datastore['CLASS']
                                        fuzz_rr_queries = "A,NS,MD,MF,CNAME,SOA,MB,MG,MR,NULL,WKS,PTR," <<
                                          "HINFO,MINFO,MX,TXT,RP,AFSDB,X25,ISDN,RT," <<
                                    Severity: Minor
                                    Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.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

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                  if @startsize == 0
                                                    if !dns_send(pkt,@underlayerProtocol) then return end
                                                  else
                                                    while @startsize <= @endsize
                                                      pkt = fuzz_padding(pkt, @startsize)
                                    Severity: Minor
                                    Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb and 1 other location - About 35 mins to fix
                                    modules/auxiliary/fuzzers/dns/dns_fuzzer.rb on lines 471..479

                                    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 34.

                                    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

                                    Identical blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                                    if @startsize == 0
                                                      if !dns_send(pkt,@underlayerProtocol) then return end # If then return end?
                                                    else
                                                      while @startsize <= @endsize
                                                        pkt = fuzz_padding(pkt, @startsize)
                                    Severity: Minor
                                    Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb and 1 other location - About 35 mins to fix
                                    modules/auxiliary/fuzzers/dns/dns_fuzzer.rb on lines 447..455

                                    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 34.

                                    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