rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Summary

Maintainability
F
4 days
Test Coverage

File openssl_heartbleed.rb has 659 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::Tcp
  include Msf::Auxiliary::Scanner
  include Msf::Auxiliary::Report

Severity: Major
Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 day to fix

    Class MetasploitModule has 37 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Auxiliary
      include Msf::Exploit::Remote::Tcp
      include Msf::Auxiliary::Scanner
      include Msf::Auxiliary::Report
    
    
    Severity: Minor
    Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 4 hrs to fix

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

        def initialize
          super(
            'Name'           => 'OpenSSL Heartbeat (Heartbleed) Information Leak',
            'Description'    => %q{
              This module implements the OpenSSL Heartbleed attack. The problem
      Severity: Major
      Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 2 hrs to fix

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

          def get_server_hello
            server_done = nil
            ssl_record_counter = 0
        
            remaining_data = get_ssl_record
        Severity: Minor
        Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 bleed has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def bleed
            connect_result = establish_connect
            return if connect_result.nil?
        
            vprint_status("Sending Heartbeat...")
        Severity: Minor
        Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 hr to fix

          Method get_keys has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_keys
              connect_result = establish_connect
              disconnect
              return if connect_result.nil?
          
          
          Severity: Minor
          Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 hr to fix

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

              def loot_and_report(heartbeat_data)
                if heartbeat_data.to_s.empty?
                  vprint_error("Looks like there isn't leaked information...")
                  return
                end
            Severity: Minor
            Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 hr to fix

              Method parse_handshakes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def parse_handshakes(data)
                  # Can contain multiple handshakes
                  remaining_data = data
                  handshakes = []
                  handshake_count = 0
              Severity: Minor
              Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 hr to fix

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

                  def get_data(length = -1)
                    to_receive = length
                    data = ''
                    done = false
                    while done == false
                Severity: Minor
                Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 tls_jabber has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def tls_jabber
                    sock.put(jabber_connect_msg(xmpp_domain))
                    res = get_data
                    if res && res.include?('host-unknown')
                      jabber_host = res.match(/ from='([\w.]*)' /)
                Severity: Minor
                Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 get_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_keys
                    connect_result = establish_connect
                    disconnect
                    return if connect_result.nil?
                
                
                Severity: Minor
                Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 get_server_hello has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def get_server_hello
                    server_done = nil
                    ssl_record_counter = 0
                
                    remaining_data = get_ssl_record
                Severity: Minor
                Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb - About 1 hr to fix

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

                    def bleed
                      connect_result = establish_connect
                      return if connect_result.nil?
                  
                      vprint_status("Sending Heartbeat...")
                  Severity: Minor
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 parse_handshakes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def parse_handshakes(data)
                      # Can contain multiple handshakes
                      remaining_data = data
                      handshakes = []
                      handshake_count = 0
                  Severity: Minor
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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 get_factors has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_factors(data, n)
                      # Walk through data looking for factors of n
                      psize = n.num_bits / 8 / 2
                      return if data.nil?
                  
                  
                  Severity: Minor
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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

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

                    def get_ssl_record
                      hdr = get_data(SSL_RECORD_HEADER_SIZE)
                  
                      unless hdr
                        vprint_error("No SSL record header received after #{response_timeout} seconds...")
                  Severity: Minor
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.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

                    CIPHER_SUITES = [
                      0xc014, # TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
                      0xc00a, # TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
                      0xc022, # TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA
                      0xc021, # TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA
                  Severity: Major
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb and 1 other location - About 1 hr to fix
                  modules/auxiliary/scanner/ssl/openssl_ccs.rb on lines 11..63

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

                  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

                      abbreviated_data = printable_data.gsub(/(.)\1{#{(DEDUP_REPEATED_CHARS_THRESHOLD - 1)},}/) do |s|
                        s[0, duplicate_pad] +
                        ' repeated ' + (s.length - (2 * duplicate_pad)).to_s + ' times ' +
                        s[-duplicate_pad, duplicate_pad]
                  Severity: Minor
                  Found in modules/auxiliary/scanner/ssl/openssl_heartbleed.rb and 1 other location - About 30 mins to fix
                  modules/auxiliary/scanner/http/elasticsearch_memory_disclosure.rb on lines 135..138

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

                  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