rapid7/metasploit-framework

View on GitHub
modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'VMware vCenter Extract Secrets from vmdir / vmafd DB File',
Severity: Minor
Found in modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.rb - About 1 hr to fix

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

      def extract_vmafd_certs
        db = SQLite3::Database.open(vmafd_file)
        db.results_as_hash = true
        unless (vecs_entry_alias = db.execute('SELECT DISTINCT Alias FROM CertTable WHERE PrivateKey NOT NULL;'))
          fail_with(Msf::Exploit::Failure::NoTarget, 'Empty Alias list returned from CertTable')
    Severity: Minor
    Found in modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.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 extract_vmafd_certs has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def extract_vmafd_certs
        db = SQLite3::Database.open(vmafd_file)
        db.results_as_hash = true
        unless (vecs_entry_alias = db.execute('SELECT DISTINCT Alias FROM CertTable WHERE PrivateKey NOT NULL;'))
          fail_with(Msf::Exploit::Failure::NoTarget, 'Empty Alias list returned from CertTable')
    Severity: Minor
    Found in modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.rb - About 1 hr to fix

      Method read_mdb_sts_block has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def read_mdb_sts_block(file_name, chunk_size, offset)
          bytes = nil
          file = File.open(file_name, 'rb')
          while offset <= file.size - chunk_size
            buf = File.binread(file, chunk_size, offset + 1)
      Severity: Minor
      Found in modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.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 extract_idp_cert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def extract_idp_cert
          sts_pem = nil
          unless (bytes = read_mdb_sts_block(vmdir_file, datastore['MDB_CHUNK_SIZE'], datastore['MDB_STARTING_OFFSET']))
            fail_with(Msf::Exploit::Failure::NoTarget, "Invalid vmdird database '#{vmdir_file}': unable to locate TenantCredential-1 in binary stream")
          end
      Severity: Minor
      Found in modules/auxiliary/admin/vmware/vcenter_offline_mdb_extract.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