rapid7/metasploit-framework

View on GitHub
modules/auxiliary/scanner/http/log4shell_scanner.rb

Summary

Maintainability
C
1 day
Test Coverage

Method build_ldap_search_response has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def build_ldap_search_response(msg_id, base_dn)
    token, java_os, java_version, uri_parts = base_dn.split('/', 4)
    target_info = @mutex.synchronize { @tokens.delete(token) }
    if target_info
      @mutex.synchronize { @successes << target_info }
Severity: Minor
Found in modules/auxiliary/scanner/http/log4shell_scanner.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 initialize has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize
    super(
      'Name' => 'Log4Shell HTTP Scanner',
      'Description' => %q{
        Versions of Apache Log4j2 impacted by CVE-2021-44228 which allow JNDI features used in configuration,
Severity: Major
Found in modules/auxiliary/scanner/http/log4shell_scanner.rb - About 2 hrs to fix

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

      def build_ldap_search_response(msg_id, base_dn)
        token, java_os, java_version, uri_parts = base_dn.split('/', 4)
        target_info = @mutex.synchronize { @tokens.delete(token) }
        if target_info
          @mutex.synchronize { @successes << target_info }
    Severity: Minor
    Found in modules/auxiliary/scanner/http/log4shell_scanner.rb - About 1 hr to fix

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

        def run_host(ip)
          # probe the target before continuing
          return if send_request_cgi('uri' => normalize_uri(target_uri)).nil?
      
          run_host_uri(ip, normalize_uri(target_uri)) unless target_uri.blank?
      Severity: Minor
      Found in modules/auxiliary/scanner/http/log4shell_scanner.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 run_host_uri has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def run_host_uri(_ip, uri)
          # HTTP_HEADER isn't exposed via the datastore but allows other modules to leverage this one to test a specific value
          unless datastore['HTTP_HEADER'].blank?
            token = rand_text_alpha_lower_numeric(8..32)
            test(token, uri: uri, headers: { datastore['HTTP_HEADER'] => log4j_jndi_string(token) })
      Severity: Minor
      Found in modules/auxiliary/scanner/http/log4shell_scanner.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

      There are no issues that match your filters.

      Category
      Status