1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

update schema with nic, hyperv, and process changes

This commit is contained in:
Jon Smith
2021-04-14 08:59:17 -05:00
parent af74047b81
commit 14838f7f5d
9 changed files with 953 additions and 113 deletions

View File

@ -18,7 +18,7 @@ Compatibility:
Examples: Examples:
$ systeminfo | jc --systeminfo -p $ systeminfo | jc --systeminfo -p -r
{ {
"host_name": "DESKTOP-WIN01", "host_name": "DESKTOP-WIN01",
"os_name": "Microsoft Windows 10 Enterprise", "os_name": "Microsoft Windows 10 Enterprise",
@ -50,11 +50,97 @@ Examples:
"page_file_locations": "C:\\pagefile.sys", "page_file_locations": "C:\\pagefile.sys",
"domain": "TEST.local", "domain": "TEST.local",
"logon_server": "\\\\WIN-AA1A1A11AAA", "logon_server": "\\\\WIN-AA1A1A11AAA",
"hotfixs": ["KB4578968", "KB4562830", "KB4570334", "KB4580325", "KB4586864", "KB4594440"], "hotfixs": [
"network_cards": "1 NIC(s) Installed.\n [01]: Int...", "KB4578968",
"hyperv_requirements": "A hypervisor has been detected. Features required fo..." "KB4562830",
"KB4570334",
"KB4580325",
"KB4586864",
"KB4594440"
],
"network_cards": [
{
"name": "Intel(R) 82574L Gigabit Network Connection",
"connection_name": "Ethernet0",
"status": "",
"dhcp_enabled": "Yes",
"dhcp_server": "192.168.133.250",
"ip_addresses": [
"192.168.133.3",
"fe80::192:eb64:1fcf:86eb"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": "Yes",
"virtualization_enabled_in_firmware": "Yes",
"second_level_address_translation": "No",
"data_execution_prevention_available": "Yes"
}
}
$ systeminfo | jc --systeminfo -p
{
"host_name": "DESKTOP-WIN01",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.19042 N/A Build 19042",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "User",
"registered_organization": "",
"product_id": "00111-12345-00001-AA111",
"original_install_date": 1613496027,
"system_boot_time": 1616163903,
"system_manufacturer": "VMware, Inc.",
"system_model": "VMware7,1",
"system_type": "x64-based PC",
"processors": ["Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2400 Mhz"],
"bios_version": "VMware, Inc. VMW71.00V.11111111.B64.2008100111, 8/10/2020",
"windows_directory": "C:\\Windows",
"system_directory": "C:\\Windows\\system32",
"boot_device": "\\Device\\HarddiskVolume1",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC-08:00) Pacific Time (US & Canada)",
"total_physical_memory": 2047,
"available_physical_memory": 1417,
"virtual_memory_max_size": 2687,
"virtual_memory_available": 1482,
"virtual_memory_in_use": 1205",
"page_file_locations": "C:\\pagefile.sys",
"domain": "TEST.local",
"logon_server": "\\\\WIN-AA1A1A11AAA",
"hotfixs": [
"KB4578968",
"KB4562830",
"KB4570334",
"KB4580325",
"KB4586864",
"KB4594440"
],
"network_cards": [
{
"name": "Intel(R) 82574L Gigabit Network Connection",
"connection_name": "Ethernet0",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "192.168.133.250",
"ip_addresses": [
"192.168.133.3",
"fe80::192:eb64:1fcf:86eb"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": "Yes",
"virtualization_enabled_in_firmware": "Yes",
"second_level_address_translation": "No",
"data_execution_prevention_available": "Yes"
}
} }
""" """
import re
import jc.utils import jc.utils
@ -79,53 +165,105 @@ def process(proc_data):
Parameters: Parameters:
proc_data: (List of Dictionaries) raw structured data to process proc_data: (Dictionary) raw structured data to process
Returns: Returns:
List of Dictionaries. Some keys are optional. Example: a non-virtualized server will not have Dictionary. Some keys are optional. Example: a non-virtualized server will an empty
the "hyperv_requirements" key. Structured data with the following schema: "hyperv_requirements" object. Structured data with the following schema:
[ {
{ "host_name": "string",
"host_name": "string", "os_name": "string",
"os_name": "string", "os_version": "string",
"os_version": "string", "os_manufacturer": "string",
"os_manufacturer": "string", "os_configuration": "string",
"os_configuration": "string", "os_build_type": "string",
"os_build_type": "string", "registered_owner": "string",
"registered_owner": "string", "registered_organization": "string",
"registered_organization": "string", "product_id": "string",
"product_id": "string", "original_install_date": integer, # naive timestamp
"original_install_date": "string", "system_boot_time": integer, # naive timestamp
"system_boot_time": "string", "system_manufacturer": "string",
"system_manufacturer": "string", "system_model": "string",
"system_model": "string", "system_type": "string",
"system_type": "string", "processors": ["string"],
"processors": ["string"], "bios_version": "string",
"bios_version": "string", "windows_directory": "string",
"windows_directory": "string", "system_directory": "string",
"system_directory": "string", "boot_device": "string",
"boot_device": "string", "system_locale": "string",
"system_locale": "string", "input_locale": "string",
"input_locale": "string", "time_zone": "string",
"time_zone": "string", "total_physical_memory": "string",
"total_physical_memory": "string", "available_physical_memory": integer,
"available_physical_memory": "string", "virtual_memory_max_size": integer,
"virtual_memory_max_size": "string", "virtual_memory_available": integer,
"virtual_memory_available": "string", "virtual_memory_in_use": integer,
"virtual_memory_in_use": "string", "page_file_locations": "string",
"page_file_locations": "string", "domain": "string",
"domain": "string", "logon_server": "string",
"logon_server": "string", "hotfixs": ["string"],
"hotfixs": ["string"], "network_cards": [
"network_cards": "string", {
"hyperv_requirements": "string" "name": "string",
"connection_name": "string",
"status": "string",
"dhcp_enabled": boolean,
"dhcp_server": "string",
"ip_addresses": ["string"]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": boolean,
"virtualization_enabled_in_firmware": boolean,
"second_level_address_translation": boolean,
"data_execution_prevention_available": boolean
} }
] }
""" """
# rebuild output for added semantic information # rebuild output for added semantic information
for i, nic in enumerate(proc_data["network_cards"]):
proc_data["network_cards"][i]["dhcp_enabled"] = convert_to_boolean(
nic["dhcp_enabled"]
)
int_list = [
"total_physical_memory",
"available_physical_memory",
"virtual_memory_max_size",
"virtual_memory_available",
"virtual_memory_in_use",
]
for key in int_list:
proc_data[key] = convert_to_int(proc_data.get(key))
dt_list = ["original_install_date", "system_boot_time"]
for key in dt_list:
tz = proc_data.get("time_zone", "")
if tz:
# convert
# from: (UTC-08:00) Pacific Time (US & Canada)
# to: (UTC-0800)
tz_fields = tz.split(" ")
tz = " " + tz_fields[0].replace(":", "")
proc_data[key] = jc.utils.timestamp(f"{proc_data.get(key)}{tz}").naive
hyperv_key = "hyperv_requirements"
hyperv_subkey_list = [
"vm_monitor_mode_extensions",
"virtualization_enabled_in_firmware",
"second_level_address_translation",
"data_execution_prevention_available",
]
if hyperv_key in proc_data:
for key in hyperv_subkey_list:
if key in proc_data[hyperv_key]:
proc_data[hyperv_key][key] = convert_to_boolean(
proc_data[hyperv_key][key]
)
return proc_data return proc_data
@ -176,12 +314,7 @@ def parse(data, raw=False, quiet=False):
# clean up keys; strip values # clean up keys; strip values
raw_output = {} raw_output = {}
for k, v in raw_data.items(): for k, v in raw_data.items():
# lowercase and replace spaces with underscores k = transform_key(k)
k = k.strip().lower().replace(" ", "_")
# remove invalid key characters
for c in ";:!@#$%^&*()-":
k = k.replace(c, "")
# since we split on start_value_pos, the delimiter # since we split on start_value_pos, the delimiter
# is still in the key field. Remove it. # is still in the key field. Remove it.
@ -189,6 +322,10 @@ def parse(data, raw=False, quiet=False):
if k in ["hotfixs", "processors"]: if k in ["hotfixs", "processors"]:
raw_output[k] = parse_hotfixs_or_processors(v) raw_output[k] = parse_hotfixs_or_processors(v)
elif k in ["network_cards"]:
raw_output[k] = parse_network_cards(v)
elif k in ["hyperv_requirements"]:
raw_output[k] = parse_hyperv_requirements(v)
else: else:
raw_output[k] = v.strip() raw_output[k] = v.strip()
@ -227,9 +364,113 @@ def parse_hotfixs_or_processors(data):
return arr_output return arr_output
def parse_hyperv_requirements(data):
"""
Turns a list of key/value settings for hyperv
into an object
Parameters:
data: (string) Input string
"""
output = {}
for i, l in enumerate(data.splitlines()):
if ":" in l:
k, v = l.split(":")
# discard the number sequence
output[transform_key(k)] = v.strip()
return output
def parse_network_cards(data):
"""
Turns a list of network_cards into an array of objects
Parameters:
data: (string) Input string
"""
delim = ":"
arr_output = []
cur_nic = None
is_ip = False
nic_value_pos = 0
for i, line in enumerate(data.splitlines()):
# skip first line
if i == 0:
continue
if "IP address(es)" in line:
is_ip = True
continue
cur_value_pos = len(line) - len(line.lstrip())
line = line.strip()
m = re.match(r"\[(\d+)\]" + delim + "(.+)", line)
if m and is_ip and cur_value_pos > nic_value_pos:
cur_nic["ip_addresses"].append(m.group(2).strip())
elif m:
if cur_nic:
arr_output.append(cur_nic)
cur_nic = default_nic()
cur_nic["name"] = m.group(2).strip()
nic_value_pos = cur_value_pos
is_ip = False
elif delim in line:
k, v = line.split(delim)
k = transform_key(k)
cur_nic[k] = v.strip()
if cur_nic:
arr_output.append(cur_nic)
return arr_output
def convert_to_boolean(value):
"""
Converts string input to boolean assuming "Yes/No" inputs
Parameters:
value: (string) Input value
"""
return value == "Yes"
def convert_to_int(value):
"""
Converts string input to integer by stripping all non-numeric characters
Parameters:
value: (string) Input value
"""
try:
value = int(re.sub("[^0-9]", "", value))
except ValueError:
pass
return value
def default_nic():
"""
Returns a default network card object
"""
return {
"name": "",
"connection_name": "",
"status": "",
"dhcp_enabled": "No",
"dhcp_server": "",
"ip_addresses": [],
}
def get_value_pos(line, delim): def get_value_pos(line, delim):
""" """
Finds the first non-whitespace character after the delimiter Finds the first non-whitespace character after the delimiter
Parameters: Parameters:
line: (string) Input string line: (string) Input string
delim: (string) The data delimiter delim: (string) The data delimiter
@ -239,3 +480,19 @@ def get_value_pos(line, delim):
raise Exception(f"Expected a '{delim}' delimited field. Actual: {line}") raise Exception(f"Expected a '{delim}' delimited field. Actual: {line}")
return len(line) - len(fields[1].lstrip()) return len(line) - len(fields[1].lstrip())
def transform_key(key):
"""
Converts a given key to a valid json key that plays nice with jq
Parameters:
key: (string) Input value
"""
# lowercase and replace spaces with underscores
key = key.strip().lower().replace(" ", "_")
# remove invalid key characters
for c in ";:!@#$%^&*()-":
key = key.replace(c, "")
return key

View File

@ -177,6 +177,7 @@ class timestamp:
{'id': 8100, 'format': '%a %d %b %Y %H:%M:%S', 'locale': ''}, # current locale format with non-UTC tz (found in upower cli output): # mar. 23 mars 2021 19:12:11 EDT {'id': 8100, 'format': '%a %d %b %Y %H:%M:%S', 'locale': ''}, # current locale format with non-UTC tz (found in upower cli output): # mar. 23 mars 2021 19:12:11 EDT
{'id': 8200, 'format': '%A %d %B %Y, %H:%M:%S UTC%z', 'locale': ''}, # fr_FR.utf8 locale format (found in date cli output): vendredi 26 mars 2021, 13:26:46 (UTC+0000) {'id': 8200, 'format': '%A %d %B %Y, %H:%M:%S UTC%z', 'locale': ''}, # fr_FR.utf8 locale format (found in date cli output): vendredi 26 mars 2021, 13:26:46 (UTC+0000)
{'id': 8300, 'format': '%A %d %B %Y, %H:%M:%S', 'locale': ''}, # fr_FR.utf8 locale format with non-UTC tz (found in date cli output): vendredi 26 mars 2021, 13:26:46 (UTC-0400) {'id': 8300, 'format': '%A %d %B %Y, %H:%M:%S', 'locale': ''}, # fr_FR.utf8 locale format with non-UTC tz (found in date cli output): vendredi 26 mars 2021, 13:26:46 (UTC-0400)
{'id': 8400, 'format': '%m/%d/%Y, %I:%M:%S %p', 'locale': ''}, # Windows english format (found in systeminfo cli output): 3/22/2021, 1:15:51 PM (UTC-0600)
{'id': 9000, 'format': '%c', 'locale': ''} # locally configured locale format conversion: Could be anything :) this is a last-gasp attempt {'id': 9000, 'format': '%c', 'locale': ''} # locally configured locale format conversion: Could be anything :) this is a last-gasp attempt
] ]

View File

@ -0,0 +1,111 @@
{
"host_name": "TESTLAPTOP",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.17134 N/A Build 17134",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Test, Inc.",
"registered_organization": "Test, Inc.",
"product_id": "11111-11111-11111-AA111",
"original_install_date": 1553633490,
"system_boot_time": 1617102839,
"system_manufacturer": "Dell Inc.",
"system_model": "Precision 5530",
"system_type": "x64-based PC",
"processors": [
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
],
"bios_version": "Dell Inc. 1.16.2, 4/21/2020",
"windows_directory": "C:\\WINDOWS",
"system_directory": "C:\\WINDOWS\\system32",
"boot_device": "\\Device\\HarddiskVolume2",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC-06:00) Central Time (US & Canada)",
"total_physical_memory": 32503,
"available_physical_memory": 19743,
"virtual_memory_max_size": 37367,
"virtual_memory_available": 22266,
"virtual_memory_in_use": 15101,
"page_file_locations": "C:\\pagefile.sys",
"domain": "test.com",
"logon_server": "\\\\TESTDC01",
"hotfixs": [
"KB2693643",
"KB4601054",
"KB4230204",
"KB4346084",
"KB4485449",
"KB4486153",
"KB4509094",
"KB4535680",
"KB4580325",
"KB4580398",
"KB4534293"
],
"network_cards": [
{
"name": "Intel(R) Wireless-AC 9260 160MHz",
"connection_name": "Wi-Fi",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "192.168.2.1",
"ip_addresses": [
"192.168.2.219"
]
},
{
"name": "Bluetooth Device (Personal Area Network)",
"connection_name": "Bluetooth Network Connection",
"status": "Media disconnected",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
},
{
"name": "Microsoft KM-TEST Loopback Adapter",
"connection_name": "Npcap Loopback Adapter",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "255.255.255.255",
"ip_addresses": [
"169.254.161.245"
]
},
{
"name": "Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64",
"connection_name": "Ethernet 5",
"status": "Hardware not present",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
},
{
"name": "Hyper-V Virtual Ethernet Adapter",
"connection_name": "vEthernet (InternalVM)",
"status": "",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": [
"172.16.32.1"
]
},
{
"name": "Hyper-V Virtual Ethernet Adapter",
"connection_name": "vEthernet (Default Switch) 2",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "255.255.255.255",
"ip_addresses": [
"172.26.251.65"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": true,
"virtualization_enabled_in_firmware": true,
"second_level_address_translation": false,
"data_execution_prevention_available": true
}
}

View File

@ -0,0 +1,79 @@
Host Name: TESTLAPTOP
OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17134 N/A Build 17134
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Registered Owner: Test, Inc.
Registered Organization: Test, Inc.
Product ID: 11111-11111-11111-AA111
Original Install Date: 3/26/2019, 3:51:30 PM
System Boot Time: 3/30/2021, 6:13:59 AM
System Manufacturer: Dell Inc.
System Model: Precision 5530
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz
BIOS Version: Dell Inc. 1.16.2, 4/21/2020
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
Boot Device: \Device\HarddiskVolume2
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC-06:00) Central Time (US & Canada)
Total Physical Memory: 32,503 MB
Available Physical Memory: 19,743 MB
Virtual Memory: Max Size: 37,367 MB
Virtual Memory: Available: 22,266 MB
Virtual Memory: In Use: 15,101 MB
Page File Location(s): C:\pagefile.sys
Domain: test.com
Logon Server: \\TESTDC01
Hotfix(s): 11 Hotfix(s) Installed.
[01]: KB2693643
[02]: KB4601054
[03]: KB4230204
[04]: KB4346084
[05]: KB4485449
[06]: KB4486153
[07]: KB4509094
[08]: KB4535680
[09]: KB4580325
[10]: KB4580398
[11]: KB4534293
Network Card(s): 6 NIC(s) Installed.
[01]: Intel(R) Wireless-AC 9260 160MHz
Connection Name: Wi-Fi
DHCP Enabled: Yes
DHCP Server: 192.168.2.1
IP address(es)
[01]: 192.168.2.219
[02]: Bluetooth Device (Personal Area Network)
Connection Name: Bluetooth Network Connection
Status: Media disconnected
[03]: Microsoft KM-TEST Loopback Adapter
Connection Name: Npcap Loopback Adapter
DHCP Enabled: Yes
DHCP Server: 255.255.255.255
IP address(es)
[01]: 169.254.161.245
[04]: Cisco AnyConnect Secure Mobility Client Virtual Miniport Adapter for Windows x64
Connection Name: Ethernet 5
Status: Hardware not present
[05]: Hyper-V Virtual Ethernet Adapter
Connection Name: vEthernet (InternalVM)
DHCP Enabled: No
IP address(es)
[01]: 172.16.32.1
[06]: Hyper-V Virtual Ethernet Adapter
Connection Name: vEthernet (Default Switch) 2
DHCP Enabled: Yes
DHCP Server: 255.255.255.255
IP address(es)
[01]: 172.26.251.65
Hyper-V Requirements: VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes
Second Level Address Translation: No
Data Execution Prevention Available: Yes

View File

@ -8,12 +8,14 @@
"registered_owner": "User", "registered_owner": "User",
"registered_organization": "", "registered_organization": "",
"product_id": "00111-12345-00001-AA111", "product_id": "00111-12345-00001-AA111",
"original_install_date": "2/16/2021, 11:20:27 AM", "original_install_date": 1613496027,
"system_boot_time": "3/19/2021, 9:25:03 AM", "system_boot_time": 1616163903,
"system_manufacturer": "VMware, Inc.", "system_manufacturer": "VMware, Inc.",
"system_model": "VMware7,1", "system_model": "VMware7,1",
"system_type": "x64-based PC", "system_type": "x64-based PC",
"processors": ["Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2400 Mhz"], "processors": [
"Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~2400 Mhz"
],
"bios_version": "VMware, Inc. VMW71.00V.11111111.B64.2008100111, 8/10/2020", "bios_version": "VMware, Inc. VMW71.00V.11111111.B64.2008100111, 8/10/2020",
"windows_directory": "C:\\Windows", "windows_directory": "C:\\Windows",
"system_directory": "C:\\Windows\\system32", "system_directory": "C:\\Windows\\system32",
@ -21,15 +23,34 @@
"system_locale": "en-us;English (United States)", "system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)", "input_locale": "en-us;English (United States)",
"time_zone": "(UTC-08:00) Pacific Time (US & Canada)", "time_zone": "(UTC-08:00) Pacific Time (US & Canada)",
"total_physical_memory": "2,047 MB", "total_physical_memory": 2047,
"available_physical_memory": "1,417 MB", "available_physical_memory": 1417,
"virtual_memory_max_size": "2,687 MB", "virtual_memory_max_size": 2687,
"virtual_memory_available": "1,482 MB", "virtual_memory_available": 1482,
"virtual_memory_in_use": "1,205 MB", "virtual_memory_in_use": 1205,
"page_file_locations": "C:\\pagefile.sys", "page_file_locations": "C:\\pagefile.sys",
"domain": "TEST.local", "domain": "TEST.local",
"logon_server": "\\\\WIN-AA1A1A11AAA", "logon_server": "\\\\WIN-AA1A1A11AAA",
"hotfixs": ["KB4578968", "KB4562830", "KB4570334", "KB4580325", "KB4586864", "KB4594440"], "hotfixs": [
"network_cards": "1 NIC(s) Installed.\n [01]: Intel(R) 82574L Gigabit Network Connection\n Connection Name: Ethernet0\n DHCP Enabled: Yes\n DHCP Server: 192.168.133.250\n IP address(es)\n [01]: 192.168.133.3\n [02]: fe80::192:eb64:1fcf:86eb", "KB4578968",
"hyperv_requirements": "A hypervisor has been detected. Features required for Hyper-V will not be displayed." "KB4562830",
"KB4570334",
"KB4580325",
"KB4586864",
"KB4594440"
],
"network_cards": [
{
"name": "Intel(R) 82574L Gigabit Network Connection",
"connection_name": "Ethernet0",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "192.168.133.250",
"ip_addresses": [
"192.168.133.3",
"fe80::192:eb64:1fcf:86eb"
]
}
],
"hyperv_requirements": {}
} }

View File

@ -0,0 +1,54 @@
{
"host_name": "WIN-1A1A1AA11AA",
"os_name": "Microsoft Windows Server 2012 R2 Standard",
"os_version": "6.3.9600 N/A Build 9600",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Standalone Server",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Windows User",
"registered_organization": "",
"product_id": "11111-11111-11111-AA111",
"original_install_date": 1544685348,
"system_boot_time": 1616960084,
"system_manufacturer": "Microsoft Corporation",
"system_model": "Virtual Machine",
"system_type": "x64-based PC",
"processors": [
"Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz"
],
"bios_version": "Microsoft Corporation Hyper-V UEFI Release v3.0, 3/2/2018",
"windows_directory": "C:\\Windows",
"system_directory": "C:\\Windows\\system32",
"boot_device": "\\Device\\HarddiskVolume2",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC+03:00) Kuwait, Riyadh",
"total_physical_memory": 3555,
"available_physical_memory": 771,
"virtual_memory_max_size": 5731,
"virtual_memory_available": 2751,
"virtual_memory_in_use": 2980,
"page_file_locations": "C:\\pagefile.sys",
"domain": "WORKGROUP",
"logon_server": "\\\\WIN-1A1A1AA11AA",
"hotfixs": [
"KB2919355",
"KB2975061",
"KB2999226",
"KB3151864",
"KB4054566"
],
"network_cards": [
{
"name": "Microsoft Hyper-V Network Adapter",
"connection_name": "Ethernet 2",
"status": "",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": [
"172.16.32.10"
]
}
],
"hyperv_requirements": {}
}

View File

@ -0,0 +1,45 @@
Host Name: WIN-1A1A1AA11AA
OS Name: Microsoft Windows Server 2012 R2 Standard
OS Version: 6.3.9600 N/A Build 9600
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
Registered Owner: Windows User
Registered Organization:
Product ID: 11111-11111-11111-AA111
Original Install Date: 12/13/2018, 1:15:48 AM
System Boot Time: 3/28/2021, 2:34:44 PM
System Manufacturer: Microsoft Corporation
System Model: Virtual Machine
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz
BIOS Version: Microsoft Corporation Hyper-V UEFI Release v3.0, 3/2/2018
Windows Directory: C:\Windows
System Directory: C:\Windows\system32
Boot Device: \Device\HarddiskVolume2
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC+03:00) Kuwait, Riyadh
Total Physical Memory: 3,555 MB
Available Physical Memory: 771 MB
Virtual Memory: Max Size: 5,731 MB
Virtual Memory: Available: 2,751 MB
Virtual Memory: In Use: 2,980 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP
Logon Server: \\WIN-1A1A1AA11AA
Hotfix(s): 5 Hotfix(s) Installed.
[01]: KB2919355
[02]: KB2975061
[03]: KB2999226
[04]: KB3151864
[05]: KB4054566
Network Card(s): 1 NIC(s) Installed.
[01]: Microsoft Hyper-V Network Adapter
Connection Name: Ethernet 2
DHCP Enabled: No
IP address(es)
[01]: 172.16.32.10
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.

View File

@ -8,12 +8,14 @@
"registered_owner": "jdoe", "registered_owner": "jdoe",
"registered_organization": "", "registered_organization": "",
"product_id": "00000-111-1111111-11111", "product_id": "00000-111-1111111-11111",
"original_install_date": "01/01/2015, 12:00:00 PM", "original_install_date": 1420135200,
"system_boot_time": "3/22/2021, 1:15:51 PM", "system_boot_time": 1616436951,
"system_manufacturer": "LENOVO", "system_manufacturer": "LENOVO",
"system_model": "11111AA", "system_model": "11111AA",
"system_type": "x64-based PC", "system_type": "x64-based PC",
"processors": ["Intel64 Family 6 Model 42 Stepping 7 GenuineIntel ~2501 Mhz"], "processors": [
"Intel64 Family 6 Model 42 Stepping 7 GenuineIntel ~2501 Mhz"
],
"bios_version": "LENOVO 83ET67WW (1.37 ), 11/28/2011", "bios_version": "LENOVO 83ET67WW (1.37 ), 11/28/2011",
"windows_directory": "C:\\Windows", "windows_directory": "C:\\Windows",
"system_directory": "C:\\Windows\\system32", "system_directory": "C:\\Windows\\system32",
@ -21,14 +23,303 @@
"system_locale": "en-us;English (United States)", "system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)", "input_locale": "en-us;English (United States)",
"time_zone": "(UTC-06:00) Central Time (US & Canada)", "time_zone": "(UTC-06:00) Central Time (US & Canada)",
"total_physical_memory": "8,075 MB", "total_physical_memory": 8075,
"available_physical_memory": "1,620 MB", "available_physical_memory": 1620,
"virtual_memory_max_size": "16,149 MB", "virtual_memory_max_size": 16149,
"virtual_memory_available": "6,468 MB", "virtual_memory_available": 6468,
"virtual_memory_in_use": "9,681 MB", "virtual_memory_in_use": 9681,
"page_file_locations": "C:\\pagefile.sys", "page_file_locations": "C:\\pagefile.sys",
"domain": "WORKGROUP", "domain": "WORKGROUP",
"logon_server": "\\\\TEST", "logon_server": "\\\\TEST",
"hotfixs": ["KB2849697", "KB2849696", "KB2841134", "KB2670838", "KB2830477", "KB2592687", "KB971033", "KB2479943", "KB2491683", "KB2506014", "KB2506212", "KB2506928", "KB2509553", "KB2511455", "KB2515325", "KB2532531", "KB2533552", "KB2533623", "KB2534366", "KB2536275", "KB2536276", "KB2544893", "KB2545698", "KB2547666", "KB2552343", "KB2560656", "KB2562937", "KB2563227", "KB2564958", "KB2570947", "KB2574819", "KB2579686", "KB2585542", "KB2603229", "KB2604115", "KB2619339", "KB2620704", "KB2621440", "KB2631813", "KB2639308", "KB2640148", "KB2647753", "KB2653956", "KB2654428", "KB2656356", "KB2660075", "KB2667402", "KB2676562", "KB2685811", "KB2685813", "KB2685939", "KB2690533", "KB2698365", "KB2705219", "KB2706045", "KB2709630", "KB2712808", "KB2718704", "KB2719857", "KB2726535", "KB2727528", "KB2729094", "KB2729452", "KB2731771", "KB2732059", "KB2732487", "KB2732500", "KB2736422", "KB2742599", "KB2750841", "KB2758857", "KB2761217", "KB2763523", "KB2770660", "KB2773072", "KB2786081", "KB2789645", "KB2791765", "KB2798162", "KB2799926", "KB2800095", "KB2803821", "KB2807986", "KB2808679", "KB2813347", "KB2813430", "KB2820331", "KB2832414", "KB2834140", "KB2836942", "KB2836943", "KB2839894", "KB2840149", "KB2840631", "KB2843630", "KB2846960", "KB2847077", "KB2847311", "KB2847927", "KB2852386", "KB2853952", "KB2855844", "KB2857650", "KB2861191", "KB2861698", "KB2862152", "KB2862330", "KB2862335", "KB2862966", "KB2862973", "KB2864058", "KB2864202", "KB2868038", "KB2868116", "KB2868626", "KB2871997", "KB2872339", "KB2882822", "KB2884256", "KB2887069", "KB2888049", "KB2891804", "KB2892074", "KB2893294", "KB2893519", "KB2894844", "KB2900986", "KB2908783", "KB2911501", "KB2912390", "KB2913152", "KB2918077", "KB2918614", "KB2919469", "KB2922229", "KB2923545", "KB2926765", "KB2928562", "KB2929733", "KB2931356", "KB2937610", "KB2939576", "KB2943357", "KB2952664", "KB2957189", "KB2957503", "KB2957509", "KB2961072", "KB2965788", "KB2966583", "KB2968294", "KB2970228", "KB2971850", "KB2972100", "KB2972211", "KB2972280", "KB2973112", "KB2973201", "KB2973351", "KB2976627", "KB2976897", "KB2977292", "KB2977728", "KB2978092", "KB2978120", "KB2978668", "KB2978742", "KB2979570", "KB2980245", "KB2984972", "KB2984976", "KB2984981", "KB2985461", "KB2991963", "KB2992611", "KB2993651", "KB2993958", "KB2994023", "KB2999226", "KB3001554", "KB3002885", "KB3003057", "KB3003743", "KB3004361", "KB3004375", "KB3005607", "KB3006121", "KB3006226", "KB3006625", "KB3008627", "KB3008923", "KB3009736", "KB3010788", "KB3011780", "KB3012176", "KB3013126", "KB3013410", "KB3014406", "KB3019215", "KB3020369", "KB3020388", "KB3021674", "KB3022777", "KB3023215", "KB3025390", "KB3030377", "KB3031432", "KB3032655", "KB3033889", "KB3033890", "KB3033929", "KB3035126", "KB3035132", "KB3037574", "KB3042058", "KB3042553", "KB3045685", "KB3046017", "KB3046269", "KB3055642", "KB3059317", "KB3060716", "KB3061518", "KB3067903", "KB3069114", "KB3069392", "KB3069762", "KB3071756", "KB3072305", "KB3072630", "KB3072633", "KB3074543", "KB3075226", "KB3076895", "KB3076949", "KB3077715", "KB3078601", "KB3080446", "KB3081320", "KB3083710", "KB3084135", "KB3086255", "KB3087039", "KB3087918", "KB3088195"], "hotfixs": [
"network_cards": "5 NIC(s) Installed.\n [01]: Bluetooth Device (Personal Area Network)\n Connection Name: Bluetooth Network Connection\n Status: Media disconnected\n [02]: Intel(R) 82579LM Gigabit Network Connection\n Connection Name: Local Area Connection\n Status: Media disconnected\n [03]: Intel(R) Centrino(R) Advanced-N 6205\n Connection Name: Wireless Network Connection\n DHCP Enabled: Yes\n DHCP Server: 192.168.2.1\n IP address(es)\n [01]: 192.168.2.2\n [04]: Microsoft Virtual WiFi Miniport Adapter\n Connection Name: Wireless Network Connection 2\n Status: Hardware not present\n [05]: Microsoft Virtual WiFi Miniport Adapter\n Connection Name: Wireless Network Connection 3\n Status: Hardware not present" "KB2849697",
"KB2849696",
"KB2841134",
"KB2670838",
"KB2830477",
"KB2592687",
"KB971033",
"KB2479943",
"KB2491683",
"KB2506014",
"KB2506212",
"KB2506928",
"KB2509553",
"KB2511455",
"KB2515325",
"KB2532531",
"KB2533552",
"KB2533623",
"KB2534366",
"KB2536275",
"KB2536276",
"KB2544893",
"KB2545698",
"KB2547666",
"KB2552343",
"KB2560656",
"KB2562937",
"KB2563227",
"KB2564958",
"KB2570947",
"KB2574819",
"KB2579686",
"KB2585542",
"KB2603229",
"KB2604115",
"KB2619339",
"KB2620704",
"KB2621440",
"KB2631813",
"KB2639308",
"KB2640148",
"KB2647753",
"KB2653956",
"KB2654428",
"KB2656356",
"KB2660075",
"KB2667402",
"KB2676562",
"KB2685811",
"KB2685813",
"KB2685939",
"KB2690533",
"KB2698365",
"KB2705219",
"KB2706045",
"KB2709630",
"KB2712808",
"KB2718704",
"KB2719857",
"KB2726535",
"KB2727528",
"KB2729094",
"KB2729452",
"KB2731771",
"KB2732059",
"KB2732487",
"KB2732500",
"KB2736422",
"KB2742599",
"KB2750841",
"KB2758857",
"KB2761217",
"KB2763523",
"KB2770660",
"KB2773072",
"KB2786081",
"KB2789645",
"KB2791765",
"KB2798162",
"KB2799926",
"KB2800095",
"KB2803821",
"KB2807986",
"KB2808679",
"KB2813347",
"KB2813430",
"KB2820331",
"KB2832414",
"KB2834140",
"KB2836942",
"KB2836943",
"KB2839894",
"KB2840149",
"KB2840631",
"KB2843630",
"KB2846960",
"KB2847077",
"KB2847311",
"KB2847927",
"KB2852386",
"KB2853952",
"KB2855844",
"KB2857650",
"KB2861191",
"KB2861698",
"KB2862152",
"KB2862330",
"KB2862335",
"KB2862966",
"KB2862973",
"KB2864058",
"KB2864202",
"KB2868038",
"KB2868116",
"KB2868626",
"KB2871997",
"KB2872339",
"KB2882822",
"KB2884256",
"KB2887069",
"KB2888049",
"KB2891804",
"KB2892074",
"KB2893294",
"KB2893519",
"KB2894844",
"KB2900986",
"KB2908783",
"KB2911501",
"KB2912390",
"KB2913152",
"KB2918077",
"KB2918614",
"KB2919469",
"KB2922229",
"KB2923545",
"KB2926765",
"KB2928562",
"KB2929733",
"KB2931356",
"KB2937610",
"KB2939576",
"KB2943357",
"KB2952664",
"KB2957189",
"KB2957503",
"KB2957509",
"KB2961072",
"KB2965788",
"KB2966583",
"KB2968294",
"KB2970228",
"KB2971850",
"KB2972100",
"KB2972211",
"KB2972280",
"KB2973112",
"KB2973201",
"KB2973351",
"KB2976627",
"KB2976897",
"KB2977292",
"KB2977728",
"KB2978092",
"KB2978120",
"KB2978668",
"KB2978742",
"KB2979570",
"KB2980245",
"KB2984972",
"KB2984976",
"KB2984981",
"KB2985461",
"KB2991963",
"KB2992611",
"KB2993651",
"KB2993958",
"KB2994023",
"KB2999226",
"KB3001554",
"KB3002885",
"KB3003057",
"KB3003743",
"KB3004361",
"KB3004375",
"KB3005607",
"KB3006121",
"KB3006226",
"KB3006625",
"KB3008627",
"KB3008923",
"KB3009736",
"KB3010788",
"KB3011780",
"KB3012176",
"KB3013126",
"KB3013410",
"KB3014406",
"KB3019215",
"KB3020369",
"KB3020388",
"KB3021674",
"KB3022777",
"KB3023215",
"KB3025390",
"KB3030377",
"KB3031432",
"KB3032655",
"KB3033889",
"KB3033890",
"KB3033929",
"KB3035126",
"KB3035132",
"KB3037574",
"KB3042058",
"KB3042553",
"KB3045685",
"KB3046017",
"KB3046269",
"KB3055642",
"KB3059317",
"KB3060716",
"KB3061518",
"KB3067903",
"KB3069114",
"KB3069392",
"KB3069762",
"KB3071756",
"KB3072305",
"KB3072630",
"KB3072633",
"KB3074543",
"KB3075226",
"KB3076895",
"KB3076949",
"KB3077715",
"KB3078601",
"KB3080446",
"KB3081320",
"KB3083710",
"KB3084135",
"KB3086255",
"KB3087039",
"KB3087918",
"KB3088195"
],
"network_cards": [
{
"name": "Bluetooth Device (Personal Area Network)",
"connection_name": "Bluetooth Network Connection",
"status": "Media disconnected",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
},
{
"name": "Intel(R) 82579LM Gigabit Network Connection",
"connection_name": "Local Area Connection",
"status": "Media disconnected",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
},
{
"name": "Intel(R) Centrino(R) Advanced-N 6205",
"connection_name": "Wireless Network Connection",
"status": "",
"dhcp_enabled": true,
"dhcp_server": "192.168.2.1",
"ip_addresses": [
"192.168.2.2"
]
},
{
"name": "Microsoft Virtual WiFi Miniport Adapter",
"connection_name": "Wireless Network Connection 2",
"status": "Hardware not present",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
},
{
"name": "Microsoft Virtual WiFi Miniport Adapter",
"connection_name": "Wireless Network Connection 3",
"status": "Hardware not present",
"dhcp_enabled": false,
"dhcp_server": "",
"ip_addresses": []
}
]
} }

View File

@ -7,58 +7,39 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
class MyTests(unittest.TestCase): class MyTests(unittest.TestCase):
test_files = [
"tests/fixtures/windows/windows-7/systeminfo",
"tests/fixtures/windows/windows-10/systeminfo",
"tests/fixtures/windows/windows-10/systeminfo-hyperv",
"tests/fixtures/windows/windows-2012r2/systeminfo",
]
def setUp(self): def setUp(self):
# input for tf in MyTests.test_files:
with open( in_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.out")
os.path.join( out_file = os.path.join(THIS_DIR, os.pardir, f"{tf}.json")
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-10/systeminfo.out"
),
"r",
encoding="utf-8",
) as f:
self.windows_10_systeminfo = f.read()
with open( with open(in_file, "r", encoding="utf-8") as f:
os.path.join( setattr(self, self.varName(tf), f.read())
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-7/systeminfo.out" with open(out_file, "r", encoding="utf-8") as f:
), setattr(self, self.varName(tf) + "_json", json.loads(f.read()))
"r",
encoding="utf-8",
) as f:
self.windows_7_systeminfo = f.read()
# output def varName(self, path):
with open( return (
os.path.join( path.replace("tests/fixtures/windows", "")
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-10/systeminfo.json" .replace("-", "_")
), .replace("/", "_")
"r", )
encoding="utf-8",
) as f:
self.windows_10_systeminfo_json = json.loads(f.read())
with open(
os.path.join(
THIS_DIR, os.pardir, "tests/fixtures/windows/windows-7/systeminfo.json"
),
"r",
encoding="utf-8",
) as f:
self.windows_7_systeminfo_json = json.loads(f.read())
def test_windows_systeminfo(self): def test_windows_systeminfo(self):
""" """
Test a sample Windows "systeminfo" command output Test a sample Windows "systeminfo" command output
""" """
self.assertEqual( for tf in MyTests.test_files:
jc.parsers.systeminfo.parse(self.windows_10_systeminfo, quiet=True), in_var = getattr(self, self.varName(tf))
self.windows_10_systeminfo_json, out_var = getattr(self, self.varName(tf) + "_json")
)
self.assertEqual( self.assertEqual(jc.parsers.systeminfo.parse(in_var, quiet=True), out_var)
jc.parsers.systeminfo.parse(self.windows_7_systeminfo, quiet=True),
self.windows_7_systeminfo_json,
)
if __name__ == "__main__": if __name__ == "__main__":