rapid7/metasploit-framework

View on GitHub
lib/msf/core/exploit/remote/http/nagios_xi/install.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method install_nagios_xi has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def install_nagios_xi(pass)
    print_status('Attempting to finish the Nagios XI installation on the target using the provided password. The username will be `nagiosadmin`.')

    # Visit the install page to obtain the cookies and nsp token required for installing the app
     res_install_page = send_request_cgi({
Severity: Minor
Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 1 hr to fix

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

      def install_nagios_xi(pass)
        print_status('Attempting to finish the Nagios XI installation on the target using the provided password. The username will be `nagiosadmin`.')
    
        # Visit the install page to obtain the cookies and nsp token required for installing the app
         res_install_page = send_request_cgi({
    Severity: Minor
    Found in lib/msf/core/exploit/remote/http/nagios_xi/install.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 sign_license_agreement has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def sign_license_agreement(cookies, nsp)
        if cookies.blank?
          return [2, 'Cannot sign the license agreement. The provided cookies are empty or nil.']
        end
    
    
    Severity: Minor
    Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 1 hr to fix

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

        def sign_license_agreement(cookies, nsp)
          if cookies.blank?
            return [2, 'Cannot sign the license agreement. The provided cookies are empty or nil.']
          end
      
      
      Severity: Minor
      Found in lib/msf/core/exploit/remote/http/nagios_xi/install.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
      Severity: Major
      Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return [1, 'Connection failed']
        Severity: Major
        Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return
          Severity: Major
          Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return [2, 'Received unexpected reply while trying to install Nagios XI on the target.']
            Severity: Major
            Found in lib/msf/core/exploit/remote/http/nagios_xi/install.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status