manageiq-smartstate 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/db/MiqBdb/MiqBdb.rb +0 -2
- data/lib/db/MiqBdb/MiqBdbPage.rb +0 -2
- data/lib/db/MiqSqlite/MiqSqlite3.rb +0 -2
- data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +0 -2
- data/lib/db/MiqSqlite/MiqSqlite3Page.rb +0 -2
- data/lib/db/MiqSqlite/MiqSqlite3Table.rb +0 -2
- 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/fat32/directory_entry.rb +540 -540
- 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/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_volume_name.rb +3 -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 -6
- 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/win32/Win32Accounts.rb +3 -1
- data/lib/metadata/util/win32/Win32EventLog.rb +3 -1
- 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 -9
- data/lib/metadata/util/win32/ms-registry.rb +3 -2
- data/lib/metadata/util/win32/peheader.rb +3 -2
- data/lib/metadata/util/win32/system_path_win.rb +0 -2
- data/lib/miq_unicode.rb +45 -0
- data/manageiq-smartstate.gemspec +8 -6
- metadata +66 -23
- data/lib/fs/MetakitFS/MetakitFS.rb +0 -530
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'fs/iso9660/util'
|
2
|
-
|
3
2
|
require 'sys-uname'
|
4
3
|
require 'binary_struct'
|
5
|
-
require '
|
4
|
+
require 'miq_unicode'
|
6
5
|
|
7
6
|
module Iso9660
|
8
7
|
class BootSector
|
8
|
+
using ManageIQ::UnicodeString
|
9
|
+
|
9
10
|
# Universal Volume Descriptor ID.
|
10
11
|
DESCRIPTOR_ID = "CD001"
|
11
12
|
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'fs/iso9660/util'
|
2
2
|
require 'fs/iso9660/rock_ridge'
|
3
|
-
|
4
3
|
require 'binary_struct'
|
5
|
-
require '
|
4
|
+
require 'miq_unicode'
|
6
5
|
|
7
6
|
module Iso9660
|
7
|
+
using ManageIQ::UnicodeString
|
8
|
+
|
8
9
|
# FlagBits: FB_
|
9
10
|
FB_HIDDEN = 0x01 # 0 if not hidden.
|
10
11
|
FB_DIRECTORY = 0x02 # 0 if file.
|
@@ -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
|
@@ -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
|
#
|
@@ -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
|
@@ -16,7 +16,6 @@ require 'metadata/ScanProfile/VmScanProfiles'
|
|
16
16
|
require 'VMwareWebService/MiqVim'
|
17
17
|
require 'OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage'
|
18
18
|
require 'OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance'
|
19
|
-
require 'VMwareWebService/MiqVimBroker'
|
20
19
|
|
21
20
|
class MIQExtract
|
22
21
|
attr_reader :systemFsMsg, :systemFs, :vm
|
@@ -99,7 +98,7 @@ class MIQExtract
|
|
99
98
|
yield({:msg => 'Scanning Profile-Registry'}) if block_given?
|
100
99
|
|
101
100
|
filters = []
|
102
|
-
reg_filters[:HKCU].
|
101
|
+
Array.wrap(reg_filters[:HKCU]).each { |f| filters << {:key => split_registry(f['key']).join('/'), :depth => f['depth']} }
|
103
102
|
@scanProfiles.parse_data(@target, RemoteRegistry.new(@systemFs, @xml_class).loadCurrentUser(filters)) unless filters.empty?
|
104
103
|
|
105
104
|
filters = {}
|
@@ -126,7 +125,7 @@ class MIQExtract
|
|
126
125
|
|
127
126
|
def extract(category, &blk)
|
128
127
|
xml = nil
|
129
|
-
category.
|
128
|
+
Array.wrap(category.presence).each do |c|
|
130
129
|
c = c.downcase
|
131
130
|
xml = case c
|
132
131
|
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,13 +1,14 @@
|
|
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'
|
7
7
|
require 'util/miq-extensions'
|
8
|
-
require 'VMwareWebService/MiqVimBroker'
|
9
8
|
|
10
9
|
class VmConfig
|
10
|
+
using ManageIQ::UnicodeString
|
11
|
+
|
11
12
|
attr_reader :configFile
|
12
13
|
|
13
14
|
def initialize(filename)
|
@@ -412,7 +413,7 @@ class VmConfig
|
|
412
413
|
require 'VMwareWebService/MiqVim'
|
413
414
|
|
414
415
|
password_decrypt = ManageIQ::Password.decrypt(ems_host['password'])
|
415
|
-
hostVim = MiqVim.new(ems_host['host'], ems_host['user'], password_decrypt)
|
416
|
+
hostVim = MiqVim.new(:server => ems_host['host'], :username => ems_host['user'], :password => password_decrypt)
|
416
417
|
$log.info "#{conn_reason}: Connection to [#{ems_display_text}] completed for VM:[#{vmCfgFile}] in [#{Time.now - st}] seconds"
|
417
418
|
return hostVim
|
418
419
|
rescue Timeout::Error => err
|
@@ -430,7 +431,7 @@ class VmConfig
|
|
430
431
|
|
431
432
|
password_decrypt = ManageIQ::Password.decrypt(ems['password'])
|
432
433
|
$log.debug "resolve_path_names: emsHost = #{ems['host']}, emsUser = #{ems['user']}" if $log
|
433
|
-
vi = MiqVimInventory.new(ems['host'], ems['user'], password_decrypt)
|
434
|
+
vi = MiqVimInventory.new(:server => ems['host'], :username => ems['user'], :password => password_decrypt)
|
434
435
|
return getDsName(filename, vi)
|
435
436
|
|
436
437
|
rescue
|
@@ -498,7 +499,7 @@ class VmConfig
|
|
498
499
|
end
|
499
500
|
|
500
501
|
def rhevm_disk_file_entry(disk)
|
501
|
-
storage_id = disk.storage_domains
|
502
|
+
storage_id = disk.storage_domains&.first&.id
|
502
503
|
disk_id = disk.image_id || disk.id
|
503
504
|
full_path = storage_id && File.join('/dev', storage_id, disk_id)
|
504
505
|
{:path => full_path, :name => disk_id, :size => disk.actual_size.to_i}
|
@@ -550,7 +551,7 @@ class VmConfig
|
|
550
551
|
elsif miqvm.rhevmVm
|
551
552
|
disks = miqvm.rhevm.collect_vm_disks(miqvm.rhevmVm)
|
552
553
|
disks.each do |disk|
|
553
|
-
storage_id = disk.storage_domains
|
554
|
+
storage_id = disk.storage_domains&.first&.id
|
554
555
|
disk_id = disk.image_id || disk.id
|
555
556
|
full_path = storage_id && File.join('/dev', storage_id, disk_id)
|
556
557
|
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
|
#
|
@@ -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
|
@@ -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
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'util/miq-xml'
|
2
2
|
require 'digest/md5'
|
3
3
|
require 'metadata/util/win32/remote-registry'
|
4
|
-
require 'enumerator'
|
5
4
|
require 'util/miq-encode'
|
6
5
|
|
7
6
|
class FleeceHives
|
@@ -92,14 +91,6 @@ class FleeceHives
|
|
92
91
|
xmlCol
|
93
92
|
end
|
94
93
|
|
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
94
|
def self.collectProductKeys(_xml, xmlCol, regHnd)
|
104
95
|
prodKeys = MIQRexml.findElement("software/productkeys", xmlCol.root)
|
105
96
|
regHnd.digitalProductKeys.each do |e|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# encoding: US-ASCII
|
2
2
|
|
3
3
|
require 'binary_struct'
|
4
|
-
require '
|
5
|
-
require 'enumerator'
|
4
|
+
require 'miq_unicode'
|
6
5
|
require 'util/miq-xml'
|
7
6
|
require 'util/xml/xml_hash'
|
8
7
|
|
@@ -13,6 +12,8 @@ DEBUG_LOG_PERFORMANCE = false
|
|
13
12
|
DEBUG_FILE_READS = false
|
14
13
|
|
15
14
|
class MSRegHive
|
15
|
+
using ManageIQ::UnicodeString
|
16
|
+
|
16
17
|
attr_reader :fileLoadTime, :fileParseTime, :digitalProductKeys, :xmlNode
|
17
18
|
|
18
19
|
# 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,6 +11,8 @@ 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
|
|
data/lib/miq_unicode.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module ManageIQ
|
2
|
+
module UnicodeString
|
3
|
+
refine String do
|
4
|
+
def UnicodeToUtf8
|
5
|
+
dup.UnicodeToUtf8!
|
6
|
+
end
|
7
|
+
|
8
|
+
def UnicodeToUtf8!
|
9
|
+
force_encoding("UTF-16LE").encode!("UTF-8")
|
10
|
+
end
|
11
|
+
|
12
|
+
def Utf8ToUnicode
|
13
|
+
dup.Utf8ToUnicode!
|
14
|
+
end
|
15
|
+
|
16
|
+
def Utf8ToUnicode!
|
17
|
+
force_encoding("UTF-8").encode!("UTF-16LE")
|
18
|
+
end
|
19
|
+
|
20
|
+
def AsciiToUtf8
|
21
|
+
dup.AsciiToUtf8!
|
22
|
+
end
|
23
|
+
|
24
|
+
def AsciiToUtf8!
|
25
|
+
force_encoding("ISO-8859-1").encode!("UTF-8")
|
26
|
+
end
|
27
|
+
|
28
|
+
def Utf8ToAscii
|
29
|
+
dup.Utf8ToAscii!
|
30
|
+
end
|
31
|
+
|
32
|
+
def Utf8ToAscii!
|
33
|
+
force_encoding("UTF-8").encode!("ISO-8859-1")
|
34
|
+
end
|
35
|
+
|
36
|
+
def Ucs2ToAscii
|
37
|
+
dup.Ucs2ToAscii!
|
38
|
+
end
|
39
|
+
|
40
|
+
def Ucs2ToAscii!
|
41
|
+
force_encoding("UTF-16LE").encode!("ISO-8859-1")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|