manageiq-smartstate 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +4 -0
  4. data/.rspec_ci +4 -0
  5. data/.travis.yml +15 -0
  6. data/Gemfile +9 -0
  7. data/LICENSE.txt +202 -0
  8. data/README.md +45 -0
  9. data/Rakefile +23 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/lib/MiqContainerGroup/MiqContainerGroup.rb +31 -0
  13. data/lib/MiqVm/MiqLocalVm.rb +50 -0
  14. data/lib/MiqVm/MiqRhevmVm.rb +179 -0
  15. data/lib/MiqVm/MiqVm.rb +355 -0
  16. data/lib/MiqVm/miq_azure_vm.rb +96 -0
  17. data/lib/MiqVm/miq_scvmm_vm.rb +38 -0
  18. data/lib/MiqVm/test/camcorder_fleece_test.rb +60 -0
  19. data/lib/MiqVm/test/localVm.rb +45 -0
  20. data/lib/MiqVm/test/partitionAlignmentCheck.rb +76 -0
  21. data/lib/MiqVm/test/remoteVm.rb +65 -0
  22. data/lib/MiqVm/test/rhevmNfsTest.rb +62 -0
  23. data/lib/MiqVm/test/rhevmNfsTest2.rb +66 -0
  24. data/lib/MiqVm/test/rhevmTest.rb +70 -0
  25. data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackCommon.rb +107 -0
  26. data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +67 -0
  27. data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +182 -0
  28. data/lib/Scvmm/miq_hyperv_disk.rb +273 -0
  29. data/lib/Scvmm/miq_scvmm_parse_powershell.rb +75 -0
  30. data/lib/Scvmm/miq_scvmm_vm_ssa_info.rb +135 -0
  31. data/lib/Scvmm/test/miq_hyperv_disk_test.rb +33 -0
  32. data/lib/Scvmm/test/miq_scvmm_vm_ssa_info_test.rb +41 -0
  33. data/lib/VmLocalDiskAccess/test/localCfg.rb +97 -0
  34. data/lib/VolumeManager/LVM/logical_volume.rb +75 -0
  35. data/lib/VolumeManager/LVM/lv_segment.rb +43 -0
  36. data/lib/VolumeManager/LVM/lvm2disk.rb +158 -0
  37. data/lib/VolumeManager/LVM/parser.rb +138 -0
  38. data/lib/VolumeManager/LVM/physical_volume.rb +19 -0
  39. data/lib/VolumeManager/LVM/scanner.rb +156 -0
  40. data/lib/VolumeManager/LVM/thin/btree.rb +83 -0
  41. data/lib/VolumeManager/LVM/thin/constants.rb +86 -0
  42. data/lib/VolumeManager/LVM/thin/data_map.rb +44 -0
  43. data/lib/VolumeManager/LVM/thin/mapping_tree.rb +19 -0
  44. data/lib/VolumeManager/LVM/thin/space_maps.rb +58 -0
  45. data/lib/VolumeManager/LVM/thin/superblock.rb +136 -0
  46. data/lib/VolumeManager/LVM/thin.rb +6 -0
  47. data/lib/VolumeManager/LVM/volume_group.rb +97 -0
  48. data/lib/VolumeManager/LVM.rb +8 -0
  49. data/lib/VolumeManager/MiqLdm.rb +546 -0
  50. data/lib/VolumeManager/MiqLvm.rb +17 -0
  51. data/lib/VolumeManager/MiqNativeVolumeManager.rb +150 -0
  52. data/lib/VolumeManager/MiqVolumeManager.rb +277 -0
  53. data/lib/VolumeManager/VolMgrPlatformSupport.rb +18 -0
  54. data/lib/VolumeManager/VolMgrPlatformSupportLinux.rb +77 -0
  55. data/lib/VolumeManager/VolMgrPlatformSupportWin.rb +17 -0
  56. data/lib/VolumeManager/test/blockDevTest.rb +40 -0
  57. data/lib/VolumeManager/test/ldm.rb +97 -0
  58. data/lib/blackbox/VmBlackBox.rb +103 -0
  59. data/lib/blackbox/xmlStorage.rb +180 -0
  60. data/lib/db/MiqBdb/MiqBdb.rb +309 -0
  61. data/lib/db/MiqBdb/MiqBdbBtree.rb +219 -0
  62. data/lib/db/MiqBdb/MiqBdbHash.rb +199 -0
  63. data/lib/db/MiqBdb/MiqBdbPage.rb +159 -0
  64. data/lib/db/MiqBdb/MiqBdbUtil.rb +18 -0
  65. data/lib/db/MiqSqlite/MiqSqlite3.rb +330 -0
  66. data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +167 -0
  67. data/lib/db/MiqSqlite/MiqSqlite3Page.rb +151 -0
  68. data/lib/db/MiqSqlite/MiqSqlite3Table.rb +124 -0
  69. data/lib/db/MiqSqlite/MiqSqlite3Util.rb +32 -0
  70. data/lib/disk/DiskProbe.rb +68 -0
  71. data/lib/disk/MiqDisk.rb +317 -0
  72. data/lib/disk/camcorder_test.rb +90 -0
  73. data/lib/disk/dos_mbr.img +0 -0
  74. data/lib/disk/modules/AzureBlobDisk.rb +101 -0
  75. data/lib/disk/modules/LocalDevMod.rb +47 -0
  76. data/lib/disk/modules/LocalDevProbe.rb +6 -0
  77. data/lib/disk/modules/MSCommon.rb +352 -0
  78. data/lib/disk/modules/MSVSDiffDisk.rb +91 -0
  79. data/lib/disk/modules/MSVSDiskProbe.rb +61 -0
  80. data/lib/disk/modules/MSVSDynamicDisk.rb +42 -0
  81. data/lib/disk/modules/MSVSFixedDisk.rb +45 -0
  82. data/lib/disk/modules/MiqLargeFile.rb +63 -0
  83. data/lib/disk/modules/MiqLargeFileWin32.rb +107 -0
  84. data/lib/disk/modules/QcowDisk.rb +692 -0
  85. data/lib/disk/modules/QcowDiskProbe.rb +34 -0
  86. data/lib/disk/modules/RawBlockIO.rb +116 -0
  87. data/lib/disk/modules/RawDisk.rb +45 -0
  88. data/lib/disk/modules/RawDiskProbe.rb +7 -0
  89. data/lib/disk/modules/RhevmDescriptor.rb +167 -0
  90. data/lib/disk/modules/RhevmDiskProbe.rb +52 -0
  91. data/lib/disk/modules/VMWareCowdDisk.rb +207 -0
  92. data/lib/disk/modules/VMWareDescriptor.rb +214 -0
  93. data/lib/disk/modules/VMWareDiskProbe.rb +74 -0
  94. data/lib/disk/modules/VMWareSparseDisk.rb +189 -0
  95. data/lib/disk/modules/VhdxDisk.rb +625 -0
  96. data/lib/disk/modules/VhdxDiskProbe.rb +46 -0
  97. data/lib/disk/modules/VixDiskMod.rb +54 -0
  98. data/lib/disk/modules/VixDiskProbe.rb +6 -0
  99. data/lib/disk/modules/miq_disk_cache.rb +135 -0
  100. data/lib/disk/modules/miq_dummy_disk.rb +41 -0
  101. data/lib/disk/modules/vhdx_bat_entry.rb +10 -0
  102. data/lib/disk/test.rb +66 -0
  103. data/lib/fs/MetakitFS/MetakitFS.rb +530 -0
  104. data/lib/fs/MetakitFS/test/Makefile +14 -0
  105. data/lib/fs/MetakitFS/test/MkCollectFiles.rb +165 -0
  106. data/lib/fs/MetakitFS/test/MkSelectFiles.rb +30 -0
  107. data/lib/fs/MetakitFS/test/collect_files.yaml +70 -0
  108. data/lib/fs/MetakitFS/test/init.rb +3 -0
  109. data/lib/fs/MetakitFS/test/mk2vmdk.rb +64 -0
  110. data/lib/fs/MetakitFS/test/mk4test.c +92 -0
  111. data/lib/fs/MetakitFS/test/mkFsTest.rb +113 -0
  112. data/lib/fs/MetakitFS/test/proto.rb +97 -0
  113. data/lib/fs/MiqFS/FsProbe.rb +39 -0
  114. data/lib/fs/MiqFS/MiqFS.rb +515 -0
  115. data/lib/fs/MiqFS/modules/AUFSProbe.rb +26 -0
  116. data/lib/fs/MiqFS/modules/Ext3.rb +305 -0
  117. data/lib/fs/MiqFS/modules/Ext3Probe.rb +25 -0
  118. data/lib/fs/MiqFS/modules/Ext4.rb +304 -0
  119. data/lib/fs/MiqFS/modules/Ext4Probe.rb +25 -0
  120. data/lib/fs/MiqFS/modules/Fat32.rb +318 -0
  121. data/lib/fs/MiqFS/modules/Fat32Probe.rb +30 -0
  122. data/lib/fs/MiqFS/modules/HFSProbe.rb +18 -0
  123. data/lib/fs/MiqFS/modules/Iso9660.rb +293 -0
  124. data/lib/fs/MiqFS/modules/Iso9660Probe.rb +18 -0
  125. data/lib/fs/MiqFS/modules/LocalFS.rb +105 -0
  126. data/lib/fs/MiqFS/modules/NTFS.rb +287 -0
  127. data/lib/fs/MiqFS/modules/NTFSProbe.rb +21 -0
  128. data/lib/fs/MiqFS/modules/NativeFS.rb +155 -0
  129. data/lib/fs/MiqFS/modules/ReFSProbe.rb +17 -0
  130. data/lib/fs/MiqFS/modules/RealFS.rb +79 -0
  131. data/lib/fs/MiqFS/modules/RealFSProbe.rb +6 -0
  132. data/lib/fs/MiqFS/modules/Reiser4Probe.rb +18 -0
  133. data/lib/fs/MiqFS/modules/ReiserFS.rb +315 -0
  134. data/lib/fs/MiqFS/modules/ReiserFSProbe.rb +42 -0
  135. data/lib/fs/MiqFS/modules/UnionFSProbe.rb +18 -0
  136. data/lib/fs/MiqFS/modules/WebDAV.rb +127 -0
  137. data/lib/fs/MiqFS/modules/WebDAVFile.rb +68 -0
  138. data/lib/fs/MiqFS/modules/XFS.rb +300 -0
  139. data/lib/fs/MiqFS/modules/XFSProbe.rb +26 -0
  140. data/lib/fs/MiqFS/modules/ZFSProbe.rb +18 -0
  141. data/lib/fs/MiqFS/test.rb +59 -0
  142. data/lib/fs/MiqFsUtil.rb +383 -0
  143. data/lib/fs/MiqMountManager.rb +209 -0
  144. data/lib/fs/MiqNativeMountManager.rb +101 -0
  145. data/lib/fs/MountManagerProbe.rb +29 -0
  146. data/lib/fs/ReiserFS/block.rb +209 -0
  147. data/lib/fs/ReiserFS/directory.rb +136 -0
  148. data/lib/fs/ReiserFS/directory_entry.rb +140 -0
  149. data/lib/fs/ReiserFS/file_data.rb +111 -0
  150. data/lib/fs/ReiserFS/superblock.rb +140 -0
  151. data/lib/fs/ReiserFS/utils.rb +95 -0
  152. data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +192 -0
  153. data/lib/fs/ext3/alloc_bitmap.rb +38 -0
  154. data/lib/fs/ext3/block_pointers_path.rb +130 -0
  155. data/lib/fs/ext3/directory.rb +51 -0
  156. data/lib/fs/ext3/directory_entry.rb +67 -0
  157. data/lib/fs/ext3/ex_attrib_header.rb +14 -0
  158. data/lib/fs/ext3/ex_attrib_name.rb +23 -0
  159. data/lib/fs/ext3/file_data.rb +130 -0
  160. data/lib/fs/ext3/group_descriptor_entry.rb +65 -0
  161. data/lib/fs/ext3/group_descriptor_table.rb +54 -0
  162. data/lib/fs/ext3/hash_tree_entry.rb +18 -0
  163. data/lib/fs/ext3/hash_tree_header.rb +15 -0
  164. data/lib/fs/ext3/inode.rb +228 -0
  165. data/lib/fs/ext3/posix_acl_entry.rb +29 -0
  166. data/lib/fs/ext3/posix_acl_header.rb +11 -0
  167. data/lib/fs/ext3/superblock.rb +406 -0
  168. data/lib/fs/ext3/test/tc_Ext3BlockPointersPath.rb +74 -0
  169. data/lib/fs/ext4/alloc_bitmap.rb +38 -0
  170. data/lib/fs/ext4/directory.rb +87 -0
  171. data/lib/fs/ext4/directory_entry.rb +77 -0
  172. data/lib/fs/ext4/ex_attrib_header.rb +14 -0
  173. data/lib/fs/ext4/ex_attrib_name.rb +23 -0
  174. data/lib/fs/ext4/extent.rb +35 -0
  175. data/lib/fs/ext4/extent_header.rb +40 -0
  176. data/lib/fs/ext4/extent_index.rb +33 -0
  177. data/lib/fs/ext4/group_descriptor_entry.rb +69 -0
  178. data/lib/fs/ext4/group_descriptor_table.rb +54 -0
  179. data/lib/fs/ext4/hash_tree_entry.rb +58 -0
  180. data/lib/fs/ext4/hash_tree_header.rb +35 -0
  181. data/lib/fs/ext4/inode.rb +465 -0
  182. data/lib/fs/ext4/posix_acl_entry.rb +29 -0
  183. data/lib/fs/ext4/posix_acl_header.rb +11 -0
  184. data/lib/fs/ext4/superblock.rb +412 -0
  185. data/lib/fs/fat32/boot_sect.rb +379 -0
  186. data/lib/fs/fat32/directory.rb +222 -0
  187. data/lib/fs/fat32/directory_entry.rb +540 -0
  188. data/lib/fs/fat32/file_data.rb +128 -0
  189. data/lib/fs/iso9660/boot_sector.rb +170 -0
  190. data/lib/fs/iso9660/directory.rb +90 -0
  191. data/lib/fs/iso9660/directory_entry.rb +147 -0
  192. data/lib/fs/iso9660/file_data.rb +78 -0
  193. data/lib/fs/iso9660/rock_ridge.rb +329 -0
  194. data/lib/fs/iso9660/util.rb +57 -0
  195. data/lib/fs/modules/LinuxMount.rb +300 -0
  196. data/lib/fs/modules/LinuxMountProbe.rb +29 -0
  197. data/lib/fs/modules/WinMount.rb +97 -0
  198. data/lib/fs/modules/WinMountProbe.rb +24 -0
  199. data/lib/fs/ntfs/attrib_attribute_list.rb +131 -0
  200. data/lib/fs/ntfs/attrib_bitmap.rb +26 -0
  201. data/lib/fs/ntfs/attrib_data.rb +74 -0
  202. data/lib/fs/ntfs/attrib_file_name.rb +110 -0
  203. data/lib/fs/ntfs/attrib_header.rb +194 -0
  204. data/lib/fs/ntfs/attrib_index_allocation.rb +19 -0
  205. data/lib/fs/ntfs/attrib_index_root.rb +247 -0
  206. data/lib/fs/ntfs/attrib_object_id.rb +40 -0
  207. data/lib/fs/ntfs/attrib_standard_information.rb +107 -0
  208. data/lib/fs/ntfs/attrib_type.rb +49 -0
  209. data/lib/fs/ntfs/attrib_volume_information.rb +53 -0
  210. data/lib/fs/ntfs/attrib_volume_name.rb +31 -0
  211. data/lib/fs/ntfs/boot_sect.rb +253 -0
  212. data/lib/fs/ntfs/data_run.rb +358 -0
  213. data/lib/fs/ntfs/directory_index_node.rb +114 -0
  214. data/lib/fs/ntfs/index_node_header.rb +69 -0
  215. data/lib/fs/ntfs/index_record_header.rb +85 -0
  216. data/lib/fs/ntfs/mft_entry.rb +288 -0
  217. data/lib/fs/ntfs/utils.rb +43 -0
  218. data/lib/fs/test/camcorder_fs_test.rb +108 -0
  219. data/lib/fs/test/collect_files_direct.yaml +22 -0
  220. data/lib/fs/test/collect_files_in.yaml +24 -0
  221. data/lib/fs/test/collect_files_in_nc.yaml +22 -0
  222. data/lib/fs/test/collect_files_out.yaml +6 -0
  223. data/lib/fs/test/collect_files_rm.yaml +6 -0
  224. data/lib/fs/test/copyTest.rb +126 -0
  225. data/lib/fs/test/fsTest.rb +87 -0
  226. data/lib/fs/test/updateTest.rb +184 -0
  227. data/lib/fs/xfs/allocation_group.rb +160 -0
  228. data/lib/fs/xfs/bmap_btree_block.rb +125 -0
  229. data/lib/fs/xfs/bmap_btree_record.rb +80 -0
  230. data/lib/fs/xfs/bmap_btree_root_node.rb +72 -0
  231. data/lib/fs/xfs/directory.rb +133 -0
  232. data/lib/fs/xfs/directory2_data_header.rb +27 -0
  233. data/lib/fs/xfs/directory3_data_header.rb +34 -0
  234. data/lib/fs/xfs/directory_block_tail.rb +22 -0
  235. data/lib/fs/xfs/directory_data_header.rb +46 -0
  236. data/lib/fs/xfs/directory_entry.rb +106 -0
  237. data/lib/fs/xfs/inode.rb +532 -0
  238. data/lib/fs/xfs/inode_map.rb +100 -0
  239. data/lib/fs/xfs/short_form_directory_entry.rb +91 -0
  240. data/lib/fs/xfs/short_form_header.rb +44 -0
  241. data/lib/fs/xfs/superblock.rb +556 -0
  242. data/lib/lib/tasks/azure.rake +52 -0
  243. data/lib/manageiq/smartstate/version.rb +5 -0
  244. data/lib/manageiq/smartstate.rb +7 -0
  245. data/lib/manageiq-smartstate.rb +1 -0
  246. data/lib/metadata/MIQExtract/MIQExtract.rb +297 -0
  247. data/lib/metadata/MIQExtract/test/extractTest.rb +41 -0
  248. data/lib/metadata/MIQExtract/test/full_extract_test.rb +68 -0
  249. data/lib/metadata/ScanProfile/HostScanItem.rb +4 -0
  250. data/lib/metadata/ScanProfile/HostScanProfile.rb +4 -0
  251. data/lib/metadata/ScanProfile/HostScanProfiles.rb +41 -0
  252. data/lib/metadata/ScanProfile/ScanItemBase.rb +63 -0
  253. data/lib/metadata/ScanProfile/ScanProfileBase.rb +51 -0
  254. data/lib/metadata/ScanProfile/ScanProfilesBase.rb +60 -0
  255. data/lib/metadata/ScanProfile/VmScanItem.rb +4 -0
  256. data/lib/metadata/ScanProfile/VmScanProfile.rb +4 -0
  257. data/lib/metadata/ScanProfile/VmScanProfiles.rb +38 -0
  258. data/lib/metadata/ScanProfile/modules/HostScanItemFile.rb +51 -0
  259. data/lib/metadata/ScanProfile/modules/HostScanItemNteventlog.rb +84 -0
  260. data/lib/metadata/ScanProfile/modules/VmScanItemFile.rb +39 -0
  261. data/lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb +34 -0
  262. data/lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb +64 -0
  263. data/lib/metadata/VMMount/VMMount.rb +81 -0
  264. data/lib/metadata/VMMount/VMPlatformMount.rb +18 -0
  265. data/lib/metadata/VMMount/VMPlatformMountLinux.rb +75 -0
  266. data/lib/metadata/VMMount/VMPlatformMountWin.rb +13 -0
  267. data/lib/metadata/VmConfig/GetNativeCfg.rb +45 -0
  268. data/lib/metadata/VmConfig/VmConfig.rb +947 -0
  269. data/lib/metadata/VmConfig/cfgConfig.rb +45 -0
  270. data/lib/metadata/VmConfig/ovfConfig.rb +99 -0
  271. data/lib/metadata/VmConfig/test/GetVMwareCfgTest.rb +40 -0
  272. data/lib/metadata/VmConfig/vmcConfig.rb +116 -0
  273. data/lib/metadata/VmConfig/vmtxConfig.rb +4 -0
  274. data/lib/metadata/VmConfig/vmxConfig.rb +162 -0
  275. data/lib/metadata/VmConfig/xmlConfig.rb +79 -0
  276. data/lib/metadata/VmConfig/xmlMsHyperVConfig.rb +41 -0
  277. data/lib/metadata/linux/InitProcHash.rb +632 -0
  278. data/lib/metadata/linux/LinuxInitProcs.rb +142 -0
  279. data/lib/metadata/linux/LinuxOSInfo.rb +237 -0
  280. data/lib/metadata/linux/LinuxPackages.rb +209 -0
  281. data/lib/metadata/linux/LinuxSystemd.rb +130 -0
  282. data/lib/metadata/linux/LinuxUsers.rb +289 -0
  283. data/lib/metadata/linux/LinuxUtils.rb +197 -0
  284. data/lib/metadata/linux/MiqConaryPackages.rb +41 -0
  285. data/lib/metadata/linux/MiqRpmPackages.rb +160 -0
  286. data/lib/metadata/linux/test/Name +0 -0
  287. data/lib/metadata/linux/test/Packages +0 -0
  288. data/lib/metadata/linux/test/rpoTest.rb +5 -0
  289. data/lib/metadata/linux/test/tc_LinuxUtils.rb +4157 -0
  290. data/lib/metadata/util/event_log_filter.rb +61 -0
  291. data/lib/metadata/util/md5deep.rb +280 -0
  292. data/lib/metadata/util/win32/Win32Accounts.rb +764 -0
  293. data/lib/metadata/util/win32/Win32EventLog.rb +743 -0
  294. data/lib/metadata/util/win32/Win32Services.rb +86 -0
  295. data/lib/metadata/util/win32/Win32Software.rb +326 -0
  296. data/lib/metadata/util/win32/Win32System.rb +333 -0
  297. data/lib/metadata/util/win32/boot_info_win.rb +59 -0
  298. data/lib/metadata/util/win32/fleece_hives.rb +220 -0
  299. data/lib/metadata/util/win32/ms-registry.rb +650 -0
  300. data/lib/metadata/util/win32/peheader.rb +868 -0
  301. data/lib/metadata/util/win32/remote-registry.rb +142 -0
  302. data/lib/metadata/util/win32/system_path_win.rb +103 -0
  303. data/lib/metadata/util/win32/versioninfo.rb +17 -0
  304. data/manageiq-smartstate.gemspec +35 -0
  305. metadata +486 -0
@@ -0,0 +1,297 @@
1
+ require 'MiqVm/MiqVm'
2
+ require 'metadata/util/md5deep'
3
+ require 'util/miq-xml'
4
+ require 'util/miq-logger'
5
+ require 'ostruct'
6
+ require 'metadata/util/win32/Win32Accounts'
7
+ require 'metadata/util/win32/Win32Software'
8
+ require 'metadata/util/win32/Win32Services'
9
+ require 'metadata/util/win32/Win32System'
10
+ require 'metadata/util/win32/Win32EventLog'
11
+ require 'metadata/linux/LinuxUsers'
12
+ require 'metadata/linux/LinuxPackages'
13
+ require 'metadata/linux/LinuxInitProcs'
14
+ require 'metadata/linux/LinuxSystemd'
15
+ require 'metadata/linux/LinuxOSInfo'
16
+ require 'metadata/ScanProfile/VmScanProfiles'
17
+ require 'VMwareWebService/MiqVim'
18
+ require 'OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage'
19
+ require 'OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance'
20
+ require 'util/miq-password'
21
+ require 'VMwareWebService/MiqVimBroker'
22
+
23
+ class MIQExtract
24
+ attr_reader :systemFsMsg, :systemFs, :vm
25
+
26
+ def initialize(filename, ost = nil) # TODO: Always pass in MiqVm
27
+ ost ||= OpenStruct.new
28
+ @ost = ost
29
+ @dataDir = ost.config.try(:dataDir)
30
+ ost.scanData = {} if ost.scanData.nil?
31
+ @xml_class = ost.xml_class.nil? ? XmlHash::Document : ost.xml_class
32
+
33
+ # TODO: Should all be subclasses of MiqVm.
34
+ # Going forward, we should only pass in an MiqVm - so the "else" will be removed.
35
+ if filename.respond_to?(:rootTrees)
36
+ @externalMount = true
37
+ @target = filename
38
+ @configFile = filename.respond_to?(:vmConfigFile) ? @target.vmConfigFile : nil
39
+
40
+ $log.info "MIQExtract using config file: [#{@configFile}] settings: [#{MiqPassword.sanitize_string(ost.scanData.inspect)}]"
41
+ else
42
+ @externalMount = false
43
+ @configFile = filename.gsub(/^"/, "").gsub(/"$/, "")
44
+
45
+ $log.info "MIQExtract using config file: [#{@configFile}] settings: [#{MiqPassword.sanitize_string(ost.scanData.inspect)}]"
46
+ ost.openParent = true if ost.scanData.fetch_path('snapshot', 'use_existing') == true
47
+ ost.force = false if ost.scanData.fetch_path('snapshot', 'forceFleeceDefault') == false
48
+ ost.snapshotDescription = ost.scanData.fetch_path('snapshot', 'description') if ost.scanData.fetch_path('snapshot', 'description')
49
+ ost.snapshot_create_free_space = ost.scanData.fetch_path('snapshot', 'create_free_percent') || 100
50
+ ost.snapshot_remove_free_space = ost.scanData.fetch_path('snapshot', 'remove_free_percent') || 100
51
+ @target = MiqVm.new(@configFile, ost)
52
+ end
53
+
54
+ # Set the system fs handle
55
+ begin
56
+ st = Time.now
57
+ $log.info "Loading disk files for VM [#{@configFile}]"
58
+ @systemFs = @target.rootTrees[0]
59
+ if @systemFs.nil?
60
+ raise MiqException::MiqVmMountError, "No root filesystem found." if @target.diskInitErrors.empty?
61
+
62
+ err_msg = ''
63
+ @target.diskInitErrors.each do |disk, err|
64
+ err = "#{err} - #{disk}" unless err.include?(disk)
65
+ err_msg += "#{err}\n"
66
+ end
67
+ raise err_msg.chomp
68
+ end
69
+
70
+ @systemFsMsg = "OS:[#{@systemFs.guestOS}] found on VM [#{@configFile}]. Loaded in [#{Time.now - st}] seconds"
71
+ $log.info @systemFsMsg
72
+ rescue => err
73
+ @systemFsMsg = "Unable to mount filesystem. Reason:[#{err}]"
74
+ $log.error "#{@systemFsMsg} for VM [#{@configFile}]"
75
+ log_level = err.kind_of?(MiqException::Error) ? :debug : :error
76
+ err.backtrace.each { |bt| $log.send(log_level, "MIQExtract.new #{bt}") }
77
+ close
78
+ end
79
+
80
+ # Load Scan Profiles
81
+ @scanProfiles = VmScanProfiles.new(ost.scanData['vmScanProfiles'], VmScanProfiles::SCAN_ITEM_CATEGORIES => ost.category, :xml_class => @xml_class)
82
+ end
83
+
84
+ def categories
85
+ @scanProfiles.get_categories
86
+ end
87
+
88
+ def split_registry(path)
89
+ y = path.tr("\\", "/").split("/")
90
+ return y[0].downcase, y[1..-1].join("/")
91
+ end
92
+
93
+ def getProfileData(&blk)
94
+ # First check for registry keys
95
+ if @systemFs.guestOS == "Windows"
96
+ reg_filters = @scanProfiles.get_registry_filters
97
+
98
+ if reg_filters
99
+ st = Time.now
100
+ $log.info "Scanning [Profile-Registry] information."
101
+ yield({:msg => 'Scanning Profile-Registry'}) if block_given?
102
+
103
+ filters = []
104
+ reg_filters[:HKCU].to_miq_a.each { |f| filters << {:key => split_registry(f['key']).join('/'), :depth => f['depth']} }
105
+ @scanProfiles.parse_data(@target, RemoteRegistry.new(@systemFs, @xml_class).loadCurrentUser(filters)) unless filters.empty?
106
+
107
+ filters = {}
108
+ reg_filters[:HKLM].each do |f|
109
+ hive, path = split_registry(f["key"])
110
+ filters[hive.downcase] = [] if filters[hive.downcase].nil?
111
+ filters[hive.downcase] << path
112
+ end unless reg_filters[:HKLM].nil?
113
+
114
+ filters.each_pair do |k, v|
115
+ regHnd = RemoteRegistry.new(@systemFs, @xml_class)
116
+ xml = regHnd.loadHive(k, v)
117
+ @scanProfiles.parse_data(@target, xml)
118
+ end unless filters.empty?
119
+ $log.info "Scanning [Profile-Registry] information ran for [#{Time.now - st}] seconds."
120
+ end
121
+ end
122
+
123
+ # Pass in the MiqVm handle to do file parsing
124
+ @scanProfiles.parse_data(@target, nil, &blk)
125
+
126
+ @scanProfiles.to_xml
127
+ end
128
+
129
+ def extract(category, &blk)
130
+ xml = nil
131
+ category.to_miq_a.each do |c|
132
+ c = c.downcase
133
+ xml = case c
134
+ when "accounts" then getAccounts(c)
135
+ when "services" then getServices(c)
136
+ when "software" then getSoftware(c)
137
+ when "system" then getSystem(c)
138
+ when "ntevents" then getEventLogs(c)
139
+ when "vmconfig" then getVMConfig(c)
140
+ # vmEvents are added to the blackbox externally, not extracted from the vm disks.
141
+ when "vmevents" then return nil
142
+ when "profiles" then getProfileData(&blk)
143
+ else
144
+ $log.warn "Warning: Category not processed [#{c}]"
145
+ nil
146
+ end
147
+
148
+ # Write XML to data directory for debugging
149
+ # File.open(File.join(@dataDir, "scan_#{c}.xml"),"w") {|f| xml.write(f,0)} if xml rescue nil
150
+ end
151
+ rescue => err
152
+ $log.error "MIQExtract.extract #{err}"
153
+ log_level = err.kind_of?(MiqException::Error) ? :debug : :error
154
+ err.backtrace.each { |bt| $log.send(log_level, "MIQExtract.extract #{bt}") }
155
+ raise err
156
+ ensure
157
+ return xml
158
+ end
159
+
160
+ def getVMConfig(_c)
161
+ # Get VM config in XML format
162
+ config_xml = @target.vmConfig.toXML(true, @target)
163
+
164
+ begin
165
+ # Log snapshot data for diagnostic purposes
166
+ config_xml.find_each("//vm/snapshots") do |s|
167
+ formattedXml = ""
168
+ s.write(formattedXml, 0)
169
+
170
+ # Dump the formated snapshot xml section
171
+ formattedXml.split("\n").each { |l| $log.debug l }
172
+
173
+ # Log the high level snapshot details
174
+ $log.info "Snapshot overview: Count:[#{s.attributes['numsnapshots']}] Current:[#{s.attributes['current']}]"
175
+
176
+ # Log each child snapshot element
177
+ s.find_each("child::snapshot") { |ss| $log.info "Snapshot details: id:[#{ss.attributes['uid']}] Name:[#{ss.attributes['displayname']}]" }
178
+ end
179
+ rescue # => e
180
+ # $log.error e
181
+ end
182
+
183
+ if config_xml.class != @xml_class
184
+ config_xml = @xml_class.load(config_xml.to_s)
185
+ end
186
+
187
+ config_xml
188
+ end
189
+
190
+ def xml_doc_node(category)
191
+ doc = @xml_class.createDoc(:miq)
192
+ node = doc.root.add_element(category)
193
+ return doc, node
194
+ end
195
+
196
+ def getAccounts(c)
197
+ return if @systemFs.nil?
198
+
199
+ doc, node = xml_doc_node(:accounts)
200
+ # doc.root.attributes["xsi:schemaLocation"] += " accounts.xsd"
201
+
202
+ case @systemFs.guestOS
203
+ when "Windows"
204
+ MiqWin32::Accounts.new(c, @systemFs).to_xml(node)
205
+ when "Linux"
206
+ MiqLinux::Users.new(@systemFs).to_xml(node)
207
+ end
208
+
209
+ doc
210
+ end
211
+
212
+ def getServices(c)
213
+ return if @systemFs.nil?
214
+
215
+ doc, node = xml_doc_node(:services)
216
+ # doc.root.attributes["xsi:schemaLocation"] += " services.xsd"
217
+
218
+ case @systemFs.guestOS
219
+ when "Windows"
220
+ MiqWin32::Services.new(c, @systemFs).to_xml(node)
221
+ when "Linux"
222
+ MiqLinux::Systemd.new(@systemFs).toXml(node) if MiqLinux::Systemd.detected?(@systemFs)
223
+ MiqLinux::InitProcs.new(@systemFs).toXml(node)
224
+ end
225
+
226
+ doc
227
+ end
228
+
229
+ def getSystem(c)
230
+ return if @systemFs.nil?
231
+
232
+ doc, node = xml_doc_node(:system)
233
+ # doc.root.attributes["xsi:schemaLocation"] += " system.xsd"
234
+
235
+ case @systemFs.guestOS
236
+ when "Windows"
237
+ MiqWin32::System.new(c, @systemFs).to_xml(node)
238
+ when "Linux"
239
+ MiqLinux::OSInfo.new(@systemFs).toXml(node)
240
+ end
241
+
242
+ doc
243
+ end
244
+
245
+ def getSoftware(c)
246
+ return if @systemFs.nil?
247
+
248
+ doc, node = xml_doc_node(:software)
249
+ # doc.root.attributes["xsi:schemaLocation"] += " software.xsd"
250
+
251
+ case @systemFs.guestOS
252
+ when "Windows"
253
+ MiqWin32::Software.new(c, @systemFs).to_xml(node)
254
+ when "Linux"
255
+ MiqLinux::Packages.new(@systemFs).toXml(node)
256
+ end
257
+
258
+ doc
259
+ end
260
+
261
+ def getEventLogs(_c)
262
+ ntevent = Win32EventLog.new(@systemFs)
263
+ ntevent.readAllLogs(Win32EventLog::SYSTEM_LOGS)
264
+ end
265
+
266
+ def scanMD5deep
267
+ # Produce file system XML with MD5 info
268
+ $log.debug "Starting Filesystem scan"
269
+ # scanPath = "c:/program files"
270
+ scanPath = "c:/program files/Java/jdk1.5.0_12/jre/lib"
271
+ md5 = MD5deep.new(@systemFs, 'versioninfo' => true, 'imports' => true)
272
+ md5.scan(scanPath, scanPath)
273
+ end
274
+
275
+ def getBaseConfigName
276
+ File.join(File.dirname(@configFile), File.basename(@configFile, ".*"))
277
+ end
278
+
279
+ def close
280
+ return if @externalMount
281
+ # Call Unmount command if drive was succesfully mounted
282
+ unless @target.nil?
283
+ $log.debug "Unmounting..."
284
+ begin
285
+ @target.unmount
286
+ $log.debug "Unmounting complete"
287
+ rescue => err
288
+ $log.error "Error during disk unmounting for VM:[#{@configFile}]"
289
+ $log.debug err.backtrace.join("\n")
290
+ ensure
291
+ @ost.miqVim.disconnect if @ost.miqVim
292
+ unmount_storage(@mount) unless @mount.blank?
293
+ set_process_permissions(:reset)
294
+ end
295
+ end
296
+ end # close
297
+ end # MIQExtract class
@@ -0,0 +1,41 @@
1
+ require 'metadata/MIQExtract/MIQExtract'
2
+ require 'log4r'
3
+ require 'MiqVm/MiqVm'
4
+
5
+ # vmDir = "v:"
6
+ vmDir = File.join(ENV.fetch("HOME", '.'), 'VMs')
7
+ puts "vmDir = #{vmDir}"
8
+
9
+ class ConsoleFormatter < Log4r::Formatter
10
+ def format(event)
11
+ (event.data.kind_of?(String) ? event.data : event.data.inspect) + "\n"
12
+ end
13
+ end
14
+
15
+ toplog = Log4r::Logger.new 'toplog'
16
+ Log4r::StderrOutputter.new('err_console', :level => Log4r::ERROR, :formatter => ConsoleFormatter)
17
+ toplog.add 'err_console'
18
+ $log = toplog if $log.nil?
19
+
20
+ #
21
+ # *** Test start
22
+ #
23
+
24
+ # vmCfgFile = File.join(vmDir, "UbuntuDev.vmwarevm/UbuntuDev.vmx")
25
+ # vmCfgFile = File.join(vmDir, "gentoo/gentoo.vmx")
26
+ # vmCfgFile = File.join(vmDir, "Ken_Linux/Ken_Linux.vmx")
27
+ # vmCfgFile = File.join(vmDir, "Metasploit VM/Metasploit VM.vmx")
28
+ # vmCfgFile = File.join(vmDir, "KnopDev.vmwarevm/KnopDev.vmx")
29
+ vmCfgFile = File.join(vmDir, "Red Hat Linux.vmwarevm/Red Hat Linux.vmx")
30
+ # vmCfgFile = File.join(vmDir, "MIQ Server Appliance - Ubuntu MD - small/MIQ Server Appliance - Ubuntu.vmx")
31
+ # vmCfgFile = File.join(vmDir, "winxpDev.vmwarevm/winxpDev.vmx")
32
+ puts "VM config file: #{vmCfgFile}"
33
+
34
+ ost = OpenStruct.new
35
+ vmCfg = MIQExtract.new(vmCfgFile, ost)
36
+ xml = vmCfg.extract(["software"])
37
+
38
+ xml.write($stdout, 4)
39
+ puts
40
+
41
+ vmCfg.close
@@ -0,0 +1,68 @@
1
+ require 'util/miq-logger'
2
+ require 'tempfile'
3
+ include Log4r
4
+
5
+ $log = MIQLogger.get_log(nil, __FILE__)
6
+ $log.level = INFO
7
+
8
+ require 'metadata/MIQExtract/MIQExtract'
9
+ require 'util/miq-process'
10
+
11
+ PROFILE_INIT = false
12
+ PROFILE_EXTRACT = false
13
+
14
+ begin
15
+ vmCfgFile = nil
16
+
17
+ startTime = Time.now
18
+ vms_path = File.join((Sys::Platform::IMPL == :macosx ? "/Volumes" : "/mnt"), "manageiq", "fleecing_test", "images", "virtual_machines")
19
+ vmCfgFile = File.join(vms_path, "vmware", "JanusVM", "JanusVM-17-sep-2007", "JanusVM", "JanusVM.vmx")
20
+
21
+ # Load VM config file
22
+ ost = OpenStruct.new
23
+ vmCfg = if PROFILE_INIT
24
+ profile_block(:file_prefix => "init_") { MIQExtract.new(vmCfgFile, ost) }
25
+ else
26
+ MIQExtract.new(vmCfgFile, ost)
27
+ end
28
+
29
+ $log.info "******************** Memory : [#{MiqProcess.processInfo.inspect}] ********************"
30
+ %w(vmconfig vmevents accounts software services system).each do |c|
31
+ $log.warn "Start fleece for [#{c}]"
32
+ stf = Time.now
33
+
34
+ xml = if PROFILE_EXTRACT
35
+ profile_block(:file_prefix => "#{c}_") { vmCfg.extract([c]) }
36
+ else
37
+ vmCfg.extract([c])
38
+ end
39
+
40
+ $log.warn "Fleece for [#{c}] completed [#{Time.now - stf}]"
41
+
42
+ $log.summary "[#{c}] extract return xml of type [#{xml.class}]" if xml
43
+ File.open(Tempfile.new("extract_#{c}.xml"), "w") { |f| xml.write(f, 2) } if xml
44
+ end
45
+ $log.info "******************** Memory : [#{MiqProcess.processInfo.inspect}] ********************"
46
+
47
+ # Unmounts the VM
48
+ vmCfg.close
49
+
50
+ $log.info "START TIME: [#{startTime}]"
51
+ $log.info "STOP TIME : [#{Time.now}]"
52
+ $log.info "Run time : [#{(Time.now - startTime)}] seconds"
53
+
54
+ # Use this time to check for memory usage through OS utilities
55
+ # $log.info "Sleeping for 5 seconds"
56
+ # sleep(5)
57
+
58
+ rescue NameError => err
59
+ unless err.to_s.include?("MiqVm")
60
+ $log.warn err
61
+ $log.fatal err.backtrace.join("\n")
62
+ end
63
+ rescue => err
64
+ $log.fatal err.to_s
65
+ err.backtrace.each { |e| $log.fatal e }
66
+ end
67
+
68
+ $log.info "MIQExtract ending."
@@ -0,0 +1,4 @@
1
+ require 'metadata/ScanProfile/ScanItemBase'
2
+
3
+ class HostScanItem < ScanItemBase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'metadata/ScanProfile/ScanProfileBase'
2
+
3
+ class HostScanProfile < ScanProfileBase
4
+ end
@@ -0,0 +1,41 @@
1
+ require 'metadata/ScanProfile/ScanProfilesBase'
2
+ require 'metadata/ScanProfile/HostScanProfile'
3
+ require 'metadata/ScanProfile/HostScanItem'
4
+
5
+ class HostScanProfiles < ScanProfilesBase
6
+ SCAN_TYPE_HOSTD = 'nteventlog'
7
+ SCAN_TYPE_FILE = 'file'
8
+
9
+ def get_hostd_scan_item
10
+ scan_item = nil
11
+ each_scan_item(SCAN_TYPE_HOSTD) do |si|
12
+ next unless si.scan_definition['content'][0][:name] == 'hostd'
13
+ scan_item = si
14
+ break
15
+ end
16
+ scan_item
17
+ end
18
+
19
+ def get_file_scan_item
20
+ scan_item = nil
21
+ each_scan_item(SCAN_TYPE_FILE) do |si|
22
+ scan_item = si
23
+ break
24
+ end
25
+ scan_item
26
+ end
27
+
28
+ def parse_data_hostd(vim)
29
+ si = get_hostd_scan_item
30
+ return if si.nil?
31
+ si.parse_data(vim, nil)
32
+ si.scan_definition[:data]
33
+ end
34
+
35
+ def parse_data_files(ssu)
36
+ si = get_file_scan_item
37
+ return if si.nil?
38
+ si.parse_data(ssu, nil)
39
+ si.scan_definition[:data]
40
+ end
41
+ end
@@ -0,0 +1,63 @@
1
+ class ScanItemBase
2
+ SCAN_TYPE_PROP = "item_type"
3
+
4
+ attr_accessor :scan_definition, :scan_item_type
5
+
6
+ def self.scan_profile_class; ScanProfilesBase.get_class('profile', self); end
7
+
8
+ def self.scan_profiles_class; ScanProfilesBase.get_class('profiles', self); end
9
+
10
+ def self.scan_item_class; self; end
11
+
12
+ def initialize(dataHash, options = {})
13
+ @params = dataHash
14
+ @options = options
15
+ @xml_class = @options[:xml_class] || XmlHash::Document
16
+
17
+ @scan_item_type = @params[SCAN_TYPE_PROP]
18
+ extend_scan_module(@scan_item_type)
19
+
20
+ @scan_definition = @params[ScanProfileBase::DEFINITION]
21
+ end
22
+
23
+ def extend_scan_module(type)
24
+ raise "Already set scan module" if @extend_scan_module
25
+ begin
26
+ m = "#{self.class.name}#{type.capitalize}"
27
+ require_relative "modules/#{m}"
28
+ extend Object.const_get(m)
29
+ rescue LoadError
30
+ end
31
+ @extend_scan_module = true
32
+ end
33
+
34
+ def with_scan_definition(type = nil)
35
+ yield scan_definition if type.nil? || type == scan_item_type
36
+ end
37
+
38
+ # THESE METHODS SHOULD BE OVER-RIDDEN BY THE REQUIRES IN THE INITIALIZER
39
+ def to_xml
40
+ xml = @xml_class.newNode("scan_item")
41
+ xml.add_attributes(
42
+ "guid" => @params["guid"],
43
+ "name" => @params["name"],
44
+ "item_type" => @params["item_type"])
45
+ xml
46
+ end
47
+
48
+ def to_hash
49
+ {
50
+ :guid => @params["guid"],
51
+ :name => @params["name"],
52
+ :item_type => @params["item_type"]
53
+ }
54
+ end
55
+
56
+ def to_yaml
57
+ YAML.dump(to_hash)
58
+ end
59
+
60
+ def parse_data(_obj, _data, &_blk)
61
+ nil
62
+ end
63
+ end
@@ -0,0 +1,51 @@
1
+ class ScanProfileBase
2
+ def self.scan_item_class; ScanProfilesBase.get_class('item', self); end
3
+
4
+ def self.scan_profiles_class; ScanProfilesBase.get_class('profiles', self); end
5
+
6
+ def self.scan_profile_class; self; end
7
+
8
+ include Enumerable
9
+
10
+ DEFINITION = "definition"
11
+
12
+ attr_accessor :scan_items
13
+
14
+ def initialize(dataHash, options = {})
15
+ @params = dataHash
16
+ @options = options
17
+ @xml_class = @options[:xml_class] || XmlHash::Document
18
+ @scan_items = @params[DEFINITION].collect { |s| self.class.scan_item_class.new(s, options) }
19
+ end
20
+
21
+ def each
22
+ scan_items.each { |si| yield si }
23
+ end
24
+
25
+ def each_scan_definition(type = nil, &blk)
26
+ scan_items.each { |si| si.with_scan_definition(type, &blk) if type.nil? || type == si.scan_item_type }
27
+ end
28
+
29
+ def each_scan_item(type = nil)
30
+ scan_items.each { |si| yield si if type.nil? || type == si.scan_item_type }
31
+ end
32
+
33
+ def to_xml
34
+ xml = @xml_class.newNode("scan_profile")
35
+ xml.add_attributes("guid" => @params["guid"], "name" => @params["name"])
36
+ each { |si| xml << si.to_xml }
37
+ xml
38
+ end
39
+
40
+ def to_hash
41
+ {
42
+ :guid => @params["guid"],
43
+ :name => @params["name"],
44
+ :scan_items => collect(&:to_hash)
45
+ }
46
+ end
47
+
48
+ def to_yaml
49
+ YAML.dump(to_hash)
50
+ end
51
+ end
@@ -0,0 +1,60 @@
1
+ require 'util/miq-xml'
2
+ require 'util/miq-logger'
3
+
4
+ class ScanProfilesBase
5
+ def self.get_class(type, from)
6
+ k = from.instance_variable_get("@scan_#{type}_class")
7
+ return k unless k.nil?
8
+
9
+ k = "#{from.name.underscore.split('_')[0..-2].join('_').camelize}#{type.camelize}"
10
+ require "metadata/ScanProfile/#{k}"
11
+ from.instance_variable_set("@scan_#{type}_class", Object.const_get(k))
12
+ end
13
+
14
+ def self.scan_item_class; get_class('item', self); end
15
+
16
+ def self.scan_profile_class; get_class('profile', self); end
17
+
18
+ def self.scan_profiles_class; self; end
19
+
20
+ include Enumerable
21
+
22
+ attr_accessor :profiles
23
+
24
+ def initialize(dataHash, options = {})
25
+ @params = dataHash
26
+ @options = options
27
+ @xml_class = @options[:xml_class] || XmlHash::Document
28
+ @profiles = @params.nil? ? [] : @params.collect { |p| self.class.scan_profile_class.new(p, @options) }
29
+ end
30
+
31
+ def each
32
+ profiles.each { |p| yield p }
33
+ end
34
+
35
+ def each_scan_definition(type = nil, &blk)
36
+ profiles.each { |p| p.each_scan_definition(type, &blk) }
37
+ end
38
+
39
+ def each_scan_item(type = nil, &blk)
40
+ profiles.each { |p| p.each_scan_item(type, &blk) }
41
+ end
42
+
43
+ def parse_data(obj, data, &blk)
44
+ each_scan_item { |si| si.parse_data(obj, data, &blk) }
45
+ end
46
+
47
+ def to_xml
48
+ xml = @xml_class.createDoc("<scan_profiles/>")
49
+ each { |p| xml.root << p.to_xml }
50
+ xml
51
+ end
52
+
53
+ def to_hash
54
+ {:scan_profiles => collect(&:to_hash)}
55
+ end
56
+
57
+ def to_yaml
58
+ YAML.dump(to_hash)
59
+ end
60
+ end
@@ -0,0 +1,4 @@
1
+ require 'metadata/ScanProfile/ScanItemBase'
2
+
3
+ class VmScanItem < ScanItemBase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'metadata/ScanProfile/ScanProfileBase'
2
+
3
+ class VmScanProfile < ScanProfileBase
4
+ end
@@ -0,0 +1,38 @@
1
+ require 'metadata/ScanProfile/ScanProfilesBase'
2
+ require 'metadata/ScanProfile/VmScanProfile'
3
+ require 'metadata/ScanProfile/VmScanItem'
4
+
5
+ class VmScanProfiles < ScanProfilesBase
6
+ SCAN_TYPE_CATEGORY = "category"
7
+ SCAN_TYPE_REGISTRY = "registry"
8
+
9
+ SCAN_ITEM_CATEGORIES = "categories"
10
+
11
+ def get_categories
12
+ categories = []
13
+ # Get data from each "category" scan item
14
+ each_scan_definition(SCAN_TYPE_CATEGORY) do |sd|
15
+ # Add the target items from the content array
16
+ sd["content"].each { |si| categories << si["target"] } unless sd["content"].nil?
17
+ end
18
+ if categories.empty?
19
+ categories = @options[SCAN_ITEM_CATEGORIES].split(",") if @options[SCAN_ITEM_CATEGORIES]
20
+ end
21
+ categories.each do |c|
22
+ c.delete!("\"")
23
+ c.strip!
24
+ end
25
+ categories << "profiles"
26
+ categories.uniq
27
+ end
28
+
29
+ def get_registry_filters
30
+ reg_filters = Hash.new { |h, k| h[k] = [] }
31
+ each_scan_definition(SCAN_TYPE_REGISTRY) do |sd|
32
+ # Add the target items from the content array and
33
+ # split the registry request into hive/key
34
+ sd["content"].each { |si| reg_filters[si["hive"].to_sym] << si }
35
+ end
36
+ reg_filters
37
+ end
38
+ end