rapid7/metasploit-framework

View on GitHub
modules/exploits/multi/php/wp_duplicator_code_inject.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Snap Creek Duplicator WordPress plugin code injection',
Severity: Minor
Found in modules/exploits/multi/php/wp_duplicator_code_inject.rb - About 1 hr to fix

    Method exploit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def exploit
        print_status("Checking if the wp-config.php file already exists...")
        tpath_wp_config = normalize_uri(datastore['TARGETURI'] + '/../wp-config.php')
        response = send_request_cgi({ 'uri' => tpath_wp_config }, timeout = datastore['TIMEOUT'])
    
    
    Severity: Minor
    Found in modules/exploits/multi/php/wp_duplicator_code_inject.rb - About 1 hr to fix

      Method create_wp_config_file has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_wp_config_file
          # 1. GET the installer.php to retrieve the archive name.
          response = send_request_cgi({ 'uri' => normalize_uri(datastore['TARGETURI']) }, timeout = datastore['TIMEOUT'])
          unless response && response.code == 200
            fail_with(Failure::NotFound, "Failed to retrieve the archive name, cannot create the wp-config.php file.")
      Severity: Minor
      Found in modules/exploits/multi/php/wp_duplicator_code_inject.rb - About 1 hr to fix

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

          def create_wp_config_file
            # 1. GET the installer.php to retrieve the archive name.
            response = send_request_cgi({ 'uri' => normalize_uri(datastore['TARGETURI']) }, timeout = datastore['TIMEOUT'])
            unless response && response.code == 200
              fail_with(Failure::NotFound, "Failed to retrieve the archive name, cannot create the wp-config.php file.")
        Severity: Minor
        Found in modules/exploits/multi/php/wp_duplicator_code_inject.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 check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def check
            tpath = normalize_uri(datastore['TARGETURI'])
        
            vprint_status("Checking URI #{rhost + tpath}")
            response = send_request_cgi({ 'uri' => tpath }, timeout = datastore['TIMEOUT'])
        Severity: Minor
        Found in modules/exploits/multi/php/wp_duplicator_code_inject.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