rapid7/metasploit-framework

View on GitHub
lib/msf/core/post/vcenter/vcenter.rb

Summary

Maintainability
F
3 days
Test Coverage

Class Post has 35 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Post
    module Vcenter
      module Vcenter
        include Msf::Post::File
        include Msf::Post::Linux::Priv
Severity: Minor
Found in lib/msf/core/post/vcenter/vcenter.rb - About 4 hrs to fix

    Method get_aes_keys has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

            def get_aes_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
              return nil unless command_exists? ldapsearch_bin
    
              # this may error,
              header = 'vmwSTSTenantKey: '
    Severity: Minor
    Found in lib/msf/core/post/vcenter/vcenter.rb - About 4 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

    File vcenter.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Msf
      class Post
        module Vcenter
          module Vcenter
            include Msf::Post::File
    Severity: Minor
    Found in lib/msf/core/post/vcenter/vcenter.rb - About 3 hrs to fix

      Method get_idp_keys has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_idp_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                return nil unless command_exists? ldapsearch_bin
      
                header = 'vmwSTSPrivateKey:: '
                legacy_key_file = '/etc/vmware-sso/keys/ssoserverSign.key'
      Severity: Minor
      Found in lib/msf/core/post/vcenter/vcenter.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 get_idp_certs has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_idp_certs(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                return nil unless command_exists? ldapsearch_bin
      
                header = 'userCertificate:: '
                legacy_cert_file = '/etc/vmware-sso/keys/ssoserverSign.crt'
      Severity: Minor
      Found in lib/msf/core/post/vcenter/vcenter.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 get_vecs_entries has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_vecs_entries(vecs_store)
                return nil unless command_exists? vecs_bin
      
                out = cmd_exec("#{vecs_bin} entry list --store #{vecs_store}")
                return nil if out.nil?
      Severity: Minor
      Found in lib/msf/core/post/vcenter/vcenter.rb - About 2 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 process_vcdb_properties_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              def process_vcdb_properties_file(location = vcd_properties_file)
                return nil unless file_exist?(location)
      
                contents = read_file(location)
                return nil if contents.nil?
      Severity: Minor
      Found in lib/msf/core/post/vcenter/vcenter.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_aes_keys has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def get_aes_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                return nil unless command_exists? ldapsearch_bin
      
                # this may error,
                header = 'vmwSTSTenantKey: '
      Severity: Minor
      Found in lib/msf/core/post/vcenter/vcenter.rb - About 1 hr to fix

        Method get_idp_keys has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def get_idp_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                  return nil unless command_exists? ldapsearch_bin
        
                  header = 'vmwSTSPrivateKey:: '
                  legacy_key_file = '/etc/vmware-sso/keys/ssoserverSign.key'
        Severity: Minor
        Found in lib/msf/core/post/vcenter/vcenter.rb - About 1 hr to fix

          Method get_idp_certs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def get_idp_certs(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                    return nil unless command_exists? ldapsearch_bin
          
                    header = 'userCertificate:: '
                    legacy_cert_file = '/etc/vmware-sso/keys/ssoserverSign.crt'
          Severity: Minor
          Found in lib/msf/core/post/vcenter/vcenter.rb - About 1 hr to fix

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

                    def get_vecs_entries(vecs_store)
                      return nil unless command_exists? vecs_bin
            
                      out = cmd_exec("#{vecs_bin} entry list --store #{vecs_store}")
                      return nil if out.nil?
            Severity: Minor
            Found in lib/msf/core/post/vcenter/vcenter.rb - About 1 hr to fix

              Method get_ldif_contents has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def get_ldif_contents(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
              Severity: Minor
              Found in lib/msf/core/post/vcenter/vcenter.rb - About 35 mins to fix

                Method get_idp_keys has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def get_idp_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                Severity: Minor
                Found in lib/msf/core/post/vcenter/vcenter.rb - About 35 mins to fix

                  Method get_aes_keys has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def get_aes_keys(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                  Severity: Minor
                  Found in lib/msf/core/post/vcenter/vcenter.rb - About 35 mins to fix

                    Method get_idp_certs has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def get_idp_certs(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                    Severity: Minor
                    Found in lib/msf/core/post/vcenter/vcenter.rb - About 35 mins to fix

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

                              def get_ldif_contents(base_fqdn, vc_psc_fqdn, base_dn, bind_dn, shell_bind_pw)
                                temp_ldif_file = "/tmp/.#{base_fqdn}_#{Time.now.strftime('%Y%m%d%H%M%S')}.tmp"
                                rm_f(temp_ldif_file) if file_exist?(temp_ldif_file)
                                out = cmd_exec("#{ldapsearch_bin} -h #{vc_psc_fqdn} -b '#{base_dn}' -s sub -D '#{bind_dn}' -w #{shell_bind_pw} \\* \\+ \\- \> #{temp_ldif_file}")
                                return nil unless file_exist?(temp_ldif_file)
                      Severity: Minor
                      Found in lib/msf/core/post/vcenter/vcenter.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

                      There are no issues that match your filters.

                      Category
                      Status