Sha256: 60bc5eb2d6bf4e00b1a33217d6f53d828a1183d4a5a3f3763cf1741b540b01e8

Contents?: true

Size: 1.69 KB

Versions: 66

Compression:

Stored size: 1.69 KB

Contents

module VmScanItemRegistry
  def to_xml
    xml = @xml_class.newNode("scan_item")
    xml.add_attributes("guid" => @params["guid"], "name" => @params["name"], "item_type" => @params["item_type"])

    scan_definition["content"].each do |d|
      if d[:data]
        xml_partial = xml.root.add_element("registry")
        xml_partial.add_attributes("base_path" => base_reg_path(d), "id" => build_reg_path(d))
        xml_partial << d[:data]
      end
    end
    xml
  end

  def parse_data(_vm, data)
    if data
      scan_definition["content"].each do |d|
        d[:data] = MIQRexml.findRegElement(build_reg_path(d), data.root) if d[:data].nil?
      end
    end
  end

  def build_reg_path(scanHash)
    path = get_long_hive_name(scanHash["hive"]) + "\\" + scanHash["key"]

    # Include the value as part of the search if we have a valid value
    path += "\\" + scanHash["value"] if include_value?(scanHash)

    path
  end

  def base_reg_path(scanHash)
    path = File.join(scanHash["hive"], scanHash["key"])
    path.tr!("/", "\\")
    # If we are not processing the value the base path is the hive + key, minus the last path element
    path = path.split("\\")[0..-2].join("\\") unless include_value?(scanHash)
    path
  end

  def include_value?(scanHash)
    # Include the value as part of the search if we have a valid value
    value = scanHash["value"].to_s.strip
    value = "" if value.length == 1 && value[0, 1] == "*"
    if !value.blank?
      return true
    else
      return false
    end
  end

  def get_long_hive_name(hive)
    case hive
    when "HKLM"
      "HKEY_LOCAL_MACHINE"
    when "HKCU"
      "HKEY_CURRENT_USER"
    when "HKCR"
      "HKEY_CLASSES_ROOT"
    else
      hive
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
manageiq-smartstate-0.5.4 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.5 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.5.3 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.5.2 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.5.1 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.5.0 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.4 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.4.0 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.18.2 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.3 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.2 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.1 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.3.0 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.24 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.18.1 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.23 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.22 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.21 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.20 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb
manageiq-smartstate-0.2.19 lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb