manageiq-smartstate 0.5.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.codeclimate.yml +34 -35
- data/.rubocop.yml +3 -3
- data/.rubocop_cc.yml +3 -4
- data/.rubocop_local.yml +1 -1
- data/.travis.yml +2 -3
- data/lib/MiqVm/MiqRhevmVm.rb +1 -1
- data/lib/MiqVm/MiqVm.rb +0 -140
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +0 -1
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +0 -1
- data/lib/VolumeManager/MiqLdm.rb +1 -1
- data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +2 -3
- data/lib/disk/modules/MSCommon.rb +3 -1
- data/lib/disk/modules/VhdxDisk.rb +3 -1
- data/lib/fs/MiqMountManager.rb +2 -29
- data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +1 -6
- data/lib/fs/ext3/superblock.rb +1 -1
- data/lib/fs/ext4/superblock.rb +2 -2
- data/lib/fs/fat32/directory_entry.rb +60 -60
- data/lib/fs/iso9660/boot_sector.rb +3 -2
- data/lib/fs/iso9660/directory_entry.rb +3 -2
- data/lib/fs/iso9660/rock_ridge.rb +3 -1
- data/lib/fs/modules/LinuxMount.rb +3 -3
- data/lib/fs/ntfs/attrib_attribute_list.rb +3 -1
- data/lib/fs/ntfs/attrib_file_name.rb +3 -1
- data/lib/fs/ntfs/attrib_header.rb +3 -1
- data/lib/fs/ntfs/attrib_index_root.rb +3 -1
- data/lib/fs/ntfs/attrib_object_id.rb +1 -1
- data/lib/fs/ntfs/attrib_volume_name.rb +3 -1
- data/lib/fs/xfs/allocation_group.rb +1 -1
- data/lib/fs/xfs/bmap_btree_block.rb +1 -1
- data/lib/fs/xfs/superblock.rb +1 -1
- data/lib/manageiq/smartstate/util.rb +18 -0
- data/lib/manageiq/smartstate/version.rb +1 -1
- data/lib/metadata/MIQExtract/MIQExtract.rb +2 -3
- data/lib/metadata/VmConfig/GetNativeCfg.rb +2 -4
- data/lib/metadata/VmConfig/VmConfig.rb +7 -5
- data/lib/metadata/VmConfig/cfgConfig.rb +4 -0
- data/lib/metadata/VmConfig/xmlConfig.rb +3 -3
- data/lib/metadata/linux/MiqRpmPackages.rb +3 -1
- data/lib/metadata/util/md5deep.rb +4 -2
- data/lib/metadata/util/win32/Win32Accounts.rb +3 -0
- data/lib/metadata/util/win32/Win32EventLog.rb +5 -3
- data/lib/metadata/util/win32/Win32Software.rb +5 -3
- data/lib/metadata/util/win32/decode.rb +0 -0
- data/lib/metadata/util/win32/fleece_hives.rb +0 -8
- data/lib/metadata/util/win32/ms-registry.rb +3 -1
- data/lib/metadata/util/win32/peheader.rb +7 -8
- data/lib/miq_unicode.rb +45 -0
- data/manageiq-smartstate.gemspec +9 -7
- metadata +76 -33
- data/lib/fs/MetakitFS/MetakitFS.rb +0 -530
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'binary_struct'
|
2
|
-
require '
|
2
|
+
require 'miq_unicode'
|
3
3
|
|
4
4
|
module Iso9660
|
5
|
+
using ManageIQ::UnicodeString
|
6
|
+
|
5
7
|
# SUSP extensions are present if the first two characters of the SUA of
|
6
8
|
# the first directory entry are "SP". After SUSP is identified, if the
|
7
9
|
# first two characters of any directory entry's SUA are "RR" a Rock Ridge
|
@@ -321,9 +321,9 @@ module LinuxMount
|
|
321
321
|
#
|
322
322
|
no_more_links = false
|
323
323
|
until no_more_links
|
324
|
-
filesys,
|
325
|
-
if filesys.fileSymLink?(
|
326
|
-
symlink = getSymLink(filesys,
|
324
|
+
filesys, tmp_link_ptr = getFsPathBase(link_ptr)
|
325
|
+
if filesys.fileSymLink?(tmp_link_ptr)
|
326
|
+
symlink = getSymLink(filesys, tmp_link_ptr)
|
327
327
|
link_ptr = symlink[0, 1] == '/' ? symlink : File.join(File.dirname(link_ptr), symlink)
|
328
328
|
else
|
329
329
|
no_more_links = true
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'fs/ntfs/utils'
|
2
2
|
require 'util/win32/nt_util'
|
3
3
|
require 'binary_struct'
|
4
|
-
require '
|
4
|
+
require 'miq_unicode'
|
5
5
|
require 'fs/ntfs/attrib_standard_information'
|
6
6
|
|
7
7
|
module NTFS
|
8
|
+
using ManageIQ::UnicodeString
|
9
|
+
|
8
10
|
#
|
9
11
|
# FILE_NAME_ATTR - Attribute: Filename (0x30)
|
10
12
|
#
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'binary_struct'
|
2
|
-
require '
|
2
|
+
require 'miq_unicode'
|
3
3
|
require 'fs/ntfs/utils'
|
4
4
|
require 'fs/ntfs/attrib_type'
|
5
5
|
|
6
6
|
module NTFS
|
7
|
+
using ManageIQ::UnicodeString
|
8
|
+
|
7
9
|
# Standard attribute header.
|
8
10
|
# Each attribute begins with one of these.
|
9
11
|
STANDARD_ATTRIBUTE_HEADER = BinaryStruct.new([
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'binary_struct'
|
2
|
-
require '
|
2
|
+
require 'miq_unicode'
|
3
3
|
require 'fs/ntfs/index_node_header'
|
4
4
|
require 'fs/ntfs/directory_index_node'
|
5
5
|
require 'fs/ntfs/index_record_header'
|
6
6
|
|
7
7
|
module NTFS
|
8
|
+
using ManageIQ::UnicodeString
|
9
|
+
|
8
10
|
#
|
9
11
|
# INDEX_ROOT - Attribute: Index root (0x90).
|
10
12
|
#
|
data/lib/fs/xfs/superblock.rb
CHANGED
@@ -13,6 +13,24 @@ module ManageIQ
|
|
13
13
|
rescue
|
14
14
|
return uri_path
|
15
15
|
end
|
16
|
+
|
17
|
+
def self.base24_decode(byte_array)
|
18
|
+
digits = %w(B C D F G H J K M P Q R T V W X Y 2 3 4 6 7 8 9)
|
19
|
+
out = " " * 29
|
20
|
+
out.length.downto(0) do |i|
|
21
|
+
if i.modulo(6) == 0
|
22
|
+
out[i, 1] = "-"
|
23
|
+
else
|
24
|
+
map_index = 0
|
25
|
+
15.downto(0) do |j|
|
26
|
+
byte_value = (map_index << 8) | byte_array[j]
|
27
|
+
byte_array[j], map_index = byte_value.divmod(24)
|
28
|
+
out[i, 1] = digits[map_index]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
out[1..-1]
|
33
|
+
end
|
16
34
|
end
|
17
35
|
end
|
18
36
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'MiqVm/MiqVm'
|
2
1
|
require 'metadata/util/md5deep'
|
3
2
|
require 'util/miq-xml'
|
4
3
|
require 'ostruct'
|
@@ -100,7 +99,7 @@ class MIQExtract
|
|
100
99
|
yield({:msg => 'Scanning Profile-Registry'}) if block_given?
|
101
100
|
|
102
101
|
filters = []
|
103
|
-
reg_filters[:HKCU].
|
102
|
+
Array.wrap(reg_filters[:HKCU]).each { |f| filters << {:key => split_registry(f['key']).join('/'), :depth => f['depth']} }
|
104
103
|
@scanProfiles.parse_data(@target, RemoteRegistry.new(@systemFs, @xml_class).loadCurrentUser(filters)) unless filters.empty?
|
105
104
|
|
106
105
|
filters = {}
|
@@ -127,7 +126,7 @@ class MIQExtract
|
|
127
126
|
|
128
127
|
def extract(category, &blk)
|
129
128
|
xml = nil
|
130
|
-
category.
|
129
|
+
Array.wrap(category.presence).each do |c|
|
131
130
|
c = c.downcase
|
132
131
|
xml = case c
|
133
132
|
when "accounts" then getAccounts(c)
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'util/miq-xml'
|
2
|
-
require 'util/runcmd'
|
3
2
|
require 'metadata/VmConfig/VmConfig'
|
3
|
+
require 'awesome_spawn'
|
4
4
|
|
5
5
|
class GetNativeCfg
|
6
|
-
LSHW = "lshw"
|
7
|
-
|
8
6
|
def self.new
|
9
|
-
lshwXml =
|
7
|
+
lshwXml = AwesomeSpawn.run!("lshw", :params => ["-xml"], :combined_output => true).output
|
10
8
|
nodeHash = Hash.new { |h, k| h[k] = [] }
|
11
9
|
doc = MiqXml.load(lshwXml)
|
12
10
|
doc.find_match("//node").each { |n| nodeHash[n.attributes["id"].split(':', 2)[0]] << n }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'metadata/VMMount/VMMount'
|
3
|
-
require '
|
3
|
+
require 'miq_unicode'
|
4
4
|
require 'util/miq-xml'
|
5
5
|
require 'VMwareWebService/MiqVimInventory'
|
6
6
|
require 'timeout'
|
@@ -8,6 +8,8 @@ require 'util/miq-extensions'
|
|
8
8
|
require 'VMwareWebService/MiqVimBroker'
|
9
9
|
|
10
10
|
class VmConfig
|
11
|
+
using ManageIQ::UnicodeString
|
12
|
+
|
11
13
|
attr_reader :configFile
|
12
14
|
|
13
15
|
def initialize(filename)
|
@@ -364,7 +366,7 @@ class VmConfig
|
|
364
366
|
|
365
367
|
def resolve_ds_path(filename)
|
366
368
|
# TODO: Determine if we need to do any work here.
|
367
|
-
ds,
|
369
|
+
ds, _dir, _name = split_filename(filename)
|
368
370
|
return filename unless ds.nil?
|
369
371
|
|
370
372
|
@ds_replace ||= {}
|
@@ -373,7 +375,7 @@ class VmConfig
|
|
373
375
|
end
|
374
376
|
|
375
377
|
ds_filename = resolve_ds_path_with_vim(filename)
|
376
|
-
ds, dir,
|
378
|
+
ds, dir, _name = split_filename(ds_filename)
|
377
379
|
unless ds.nil?
|
378
380
|
idx = filename.index(dir)
|
379
381
|
replaced_str = filename[0, idx]
|
@@ -498,7 +500,7 @@ class VmConfig
|
|
498
500
|
end
|
499
501
|
|
500
502
|
def rhevm_disk_file_entry(disk)
|
501
|
-
storage_id = disk.storage_domains
|
503
|
+
storage_id = disk.storage_domains&.first&.id
|
502
504
|
disk_id = disk.image_id || disk.id
|
503
505
|
full_path = storage_id && File.join('/dev', storage_id, disk_id)
|
504
506
|
{:path => full_path, :name => disk_id, :size => disk.actual_size.to_i}
|
@@ -550,7 +552,7 @@ class VmConfig
|
|
550
552
|
elsif miqvm.rhevmVm
|
551
553
|
disks = miqvm.rhevm.collect_vm_disks(miqvm.rhevmVm)
|
552
554
|
disks.each do |disk|
|
553
|
-
storage_id = disk.storage_domains
|
555
|
+
storage_id = disk.storage_domains&.first&.id
|
554
556
|
disk_id = disk.image_id || disk.id
|
555
557
|
full_path = storage_id && File.join('/dev', storage_id, disk_id)
|
556
558
|
d = {:path => full_path, :name => disk.name.to_s, :size => disk.actual_size.to_i}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'util/miq-xml'
|
2
|
-
require '
|
2
|
+
require 'awesome_spawn'
|
3
3
|
|
4
4
|
module XmlConfig
|
5
5
|
def convert(filename)
|
@@ -12,9 +12,9 @@ module XmlConfig
|
|
12
12
|
if Sys::Platform::IMPL == :linux
|
13
13
|
begin
|
14
14
|
# First check to see if the command is available
|
15
|
-
|
15
|
+
AwesomeSpawn.run!("virsh", :params => ["list"])
|
16
16
|
begin
|
17
|
-
xml_data =
|
17
|
+
xml_data = AwesomeSpawn.run!("virsh", :params => ["dumpxml", File.basename(filename, ".*")], :combined_output => true).output
|
18
18
|
rescue => err
|
19
19
|
$log.error "#{err}\n#{err.backtrace.join("\n")}"
|
20
20
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'binary_struct'
|
2
2
|
require 'util/miq-hash_struct'
|
3
3
|
require 'db/MiqBdb/MiqBdb'
|
4
|
-
require '
|
4
|
+
require 'miq_unicode'
|
5
5
|
|
6
6
|
# RPM Specification located at: http://jrpm.sourceforge.net/rpmspec/index.html
|
7
7
|
|
8
8
|
class MiqRpmPackages
|
9
|
+
using ManageIQ::UnicodeString
|
10
|
+
|
9
11
|
#
|
10
12
|
# The data types we support.
|
11
13
|
#
|
@@ -13,6 +13,8 @@ class MD5deep
|
|
13
13
|
def initialize(fs = nil, options = {})
|
14
14
|
@fullFileCount = 0
|
15
15
|
@fullDirCount = 0
|
16
|
+
@drive_letter = nil
|
17
|
+
|
16
18
|
# Create XML document
|
17
19
|
@xml = XmlHash.createDoc(:filesystem)
|
18
20
|
@fs = fs.kind_of?(MiqFS) ? fs : nil
|
@@ -179,9 +181,9 @@ class MD5deep
|
|
179
181
|
|
180
182
|
def fileOpen(currFile)
|
181
183
|
if @fs
|
182
|
-
|
184
|
+
@fs.fileOpen(currFile)
|
183
185
|
else
|
184
|
-
|
186
|
+
File.open(currFile)
|
185
187
|
end
|
186
188
|
end
|
187
189
|
|
@@ -19,13 +19,15 @@ require 'digest/md5'
|
|
19
19
|
|
20
20
|
# Common utilities.
|
21
21
|
require 'binary_struct'
|
22
|
-
require '
|
22
|
+
require 'miq_unicode'
|
23
23
|
require 'util/miq-xml'
|
24
24
|
require 'util/miq-exception'
|
25
25
|
|
26
26
|
require 'metadata/util/event_log_filter'
|
27
27
|
|
28
28
|
class Win32EventLog
|
29
|
+
using ManageIQ::UnicodeString
|
30
|
+
|
29
31
|
# Standard file log names
|
30
32
|
SYSTEM_LOGS = %w(Application System Security)
|
31
33
|
BUFFER_READ_SIZE = 10485760 # 10 MB buffer
|
@@ -684,8 +686,8 @@ class Win32EventLog
|
|
684
686
|
reg.each_key do |subKey, _wtime|
|
685
687
|
subpath = "#{src}\\#{subKey}"
|
686
688
|
subKey.downcase!
|
687
|
-
Win32::Registry::HKEY_LOCAL_MACHINE.open(subpath) do |
|
688
|
-
|
689
|
+
Win32::Registry::HKEY_LOCAL_MACHINE.open(subpath) do |subreg|
|
690
|
+
subreg.each_value do |name, _type, data|
|
689
691
|
case name
|
690
692
|
when 'EventMessageFile', 'ParameterMessageFile', 'CategoryMessageFile' then
|
691
693
|
fn = data.to_s
|
@@ -251,11 +251,13 @@ module MiqWin32
|
|
251
251
|
end
|
252
252
|
|
253
253
|
def self.DecodeProductKey(product_key)
|
254
|
-
|
255
|
-
|
256
|
-
|
254
|
+
parts = product_key.to_s.split(",")
|
255
|
+
return if parts.length < 67
|
256
|
+
|
257
|
+
ManageIQ::Smartstate::Util.base24_decode(parts[52..67].map(&:hex))
|
257
258
|
rescue => err
|
258
259
|
$log.error "MIQ(DecodeProductKey): [#{err}]"
|
260
|
+
nil
|
259
261
|
end
|
260
262
|
|
261
263
|
private
|
File without changes
|
@@ -92,14 +92,6 @@ class FleeceHives
|
|
92
92
|
xmlCol
|
93
93
|
end
|
94
94
|
|
95
|
-
def self.DecodeProductKey(product_key)
|
96
|
-
return if product_key.blank? || product_key.length < 67
|
97
|
-
y = []; product_key.split(",")[52..67].each { |b| y << b.hex }
|
98
|
-
return MIQEncode.base24Decode(y)
|
99
|
-
rescue => err
|
100
|
-
$log.error "MIQ(OS-DecodeProductKey): [#{err}]"
|
101
|
-
end
|
102
|
-
|
103
95
|
def self.collectProductKeys(_xml, xmlCol, regHnd)
|
104
96
|
prodKeys = MIQRexml.findElement("software/productkeys", xmlCol.root)
|
105
97
|
regHnd.digitalProductKeys.each do |e|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: US-ASCII
|
2
2
|
|
3
3
|
require 'binary_struct'
|
4
|
-
require '
|
4
|
+
require 'miq_unicode'
|
5
5
|
require 'enumerator'
|
6
6
|
require 'util/miq-xml'
|
7
7
|
require 'util/xml/xml_hash'
|
@@ -13,6 +13,8 @@ DEBUG_LOG_PERFORMANCE = false
|
|
13
13
|
DEBUG_FILE_READS = false
|
14
14
|
|
15
15
|
class MSRegHive
|
16
|
+
using ManageIQ::UnicodeString
|
17
|
+
|
16
18
|
attr_reader :fileLoadTime, :fileParseTime, :digitalProductKeys, :xmlNode
|
17
19
|
|
18
20
|
# Size of the HBIN data (as well as initiale REGF) segments
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# encoding: US-ASCII
|
2
2
|
|
3
3
|
require 'stringio'
|
4
|
-
|
5
4
|
require 'binary_struct'
|
6
|
-
require '
|
5
|
+
require 'miq_unicode'
|
7
6
|
|
8
7
|
# Notes:
|
9
8
|
# The peheader object member 'icons' is an array of icons in the file. Sub 0 is the application
|
@@ -12,11 +11,11 @@ require 'util/miq-unicode'
|
|
12
11
|
# to open them and display each resolution contained in the icon (if more than one).
|
13
12
|
|
14
13
|
class PEheader
|
14
|
+
using ManageIQ::UnicodeString
|
15
|
+
|
15
16
|
IMAGE_NT_SIGNATURE = "PE\0\0"
|
16
17
|
IMAGE_DOS_SIGNATURE = "MZ"
|
17
18
|
|
18
|
-
attr_reader :imports, :icons, :messagetables, :versioninfo
|
19
|
-
|
20
19
|
def initialize(path)
|
21
20
|
@fname = path
|
22
21
|
@dataDirs = []
|
@@ -91,19 +90,19 @@ class PEheader
|
|
91
90
|
end
|
92
91
|
|
93
92
|
def imports
|
94
|
-
@
|
93
|
+
@imports ||= getImports
|
95
94
|
end
|
96
95
|
|
97
96
|
def icons
|
98
|
-
@
|
97
|
+
@icons ||= getIcons(@fBuf)
|
99
98
|
end
|
100
99
|
|
101
100
|
def messagetables
|
102
|
-
@
|
101
|
+
@messagetables ||= getMessagetables
|
103
102
|
end
|
104
103
|
|
105
104
|
def versioninfo
|
106
|
-
@
|
105
|
+
@versioninfo ||= getVersioninfo
|
107
106
|
end
|
108
107
|
|
109
108
|
# //////////////////////////////////////////////////////////////////////////
|