diff --git a/jc/parsers/ipconfig.py b/jc/parsers/ipconfig.py index 318b1353..4687cea8 100644 --- a/jc/parsers/ipconfig.py +++ b/jc/parsers/ipconfig.py @@ -20,7 +20,7 @@ "ip_routing_enabled": boolean, "wins_proxy_enabled": boolean, "dns_suffix_search_list": [ - string + string ], "adapters": [ { @@ -51,7 +51,7 @@ { "address": string, "status": string, - "prefix_length": int, + "prefix_length": integer, } ], "ipv4_addresses": [ @@ -72,12 +72,16 @@ string ], "primary_wins_server": string, - "lease_expires": string, # [0] - "lease_obtained": string, # [0] + "lease_expires": string, + "lease_expires_epoch": integer, # [0] + "lease_expires_iso": string, + "lease_obtained": string, + "lease_obtained_epoch": integer, # [0] + "lease_obtained_iso": string, "netbios_over_tcpip": boolean, "media_state": string, "extras": [ - string: string + : string ] } ], @@ -85,9 +89,8 @@ } Notes: - [0] - 'lease_expires' and 'lease_obtained' are parsed to ISO8601 - format date strings. if the value was unable to be parsed by - datetime, the fields will be in their raw form + [0] - The epoch calculated timestamp field is naive. (i.e. based on + the local time of the system the parser is run on) [1] - 'autoconfigured' under 'ipv4_address' is only providing indication if the ipv4 address was labeled as "Autoconfiguration IPv4 Address" vs "IPv4 Address". It does not infer any @@ -529,17 +532,15 @@ def _process(proc_data): if "netbios_over_tcpip" in adapter and adapter["netbios_over_tcpip"] is not None: adapter["netbios_over_tcpip"] = (adapter["netbios_over_tcpip"].lower() == "enabled") - if "lease_expires" in adapter and adapter["lease_expires"] is not None and adapter["lease_expires"] != "": - try: - adapter["lease_expires"] = datetime.strptime(adapter["lease_expires"], "%A, %B %d, %Y %I:%M:%S %p").isoformat() - except: - pass # Leave date in raw format if not parseable - - if "lease_obtained" in adapter and adapter["lease_obtained"] is not None and adapter["lease_obtained"] != "": - try: - adapter["lease_obtained"] = datetime.strptime(adapter["lease_obtained"], "%A, %B %d, %Y %I:%M:%S %p").isoformat() - except: - pass # Leave date in raw format if not parseable + if "lease_expires" in adapter and adapter["lease_expires"]: + ts = jc.utils.timestamp(adapter['lease_expires'], format_hint=(1720,)) + adapter["lease_expires_epoch"] = ts.naive + adapter["lease_expires_iso"] = ts.iso + + if "lease_obtained" in adapter and adapter["lease_obtained"]: + ts = jc.utils.timestamp(adapter['lease_obtained'], format_hint=(1720,)) + adapter["lease_obtained_epoch"] = ts.naive + adapter["lease_obtained_iso"] = ts.iso adapter["link_local_ipv6_addresses"] = [_process_ipv6_address(address) for address in adapter.get("link_local_ipv6_addresses", [])] adapter["ipv4_addresses"] = [_process_ipv4_address(address) for address in adapter.get("ipv4_addresses", [])] diff --git a/jc/utils.py b/jc/utils.py index cdd26e52..4b190142 100644 --- a/jc/utils.py +++ b/jc/utils.py @@ -696,6 +696,7 @@ def _parse_dt( {'id': 1700, 'format': '%m/%d/%Y, %I:%M:%S %p', 'locale': None}, # Windows english format wint non-UTC tz (found in systeminfo cli output): 3/22/2021, 1:15:51 PM (UTC-0600) {'id': 1705, 'format': '%m/%d/%Y, %I:%M:%S %p %Z', 'locale': None}, # Windows english format with UTC tz (found in systeminfo cli output): 3/22/2021, 1:15:51 PM (UTC) {'id': 1710, 'format': '%m/%d/%Y, %I:%M:%S %p UTC%z', 'locale': None}, # Windows english format with UTC tz (found in systeminfo cli output): 3/22/2021, 1:15:51 PM (UTC+0000) + {'id': 1720, 'format': '%A, %B %d, %Y %I:%M:%S %p', 'locale': None}, # ipconfig cli output format: Thursday, June 22, 2023 10:39:04 AM {'id': 1750, 'format': '%Y/%m/%d-%H:%M:%S.%f', 'locale': None}, # Google Big Table format with no timezone: 1970/01/01-01:00:00.000000 {'id': 1755, 'format': '%Y/%m/%d-%H:%M:%S.%f%z', 'locale': None}, # Google Big Table format with timezone: 1970/01/01-01:00:00.000000+00:00 {'id': 1760, 'format': '%Y-%m-%d %H:%M:%S%z', 'locale': None}, # certbot format with timezone: 2023-06-12 01:35:30+00:00 diff --git a/tests/fixtures/windows/windows-10/ipconfig.json b/tests/fixtures/windows/windows-10/ipconfig.json index e9fbd94c..942de7f0 100644 --- a/tests/fixtures/windows/windows-10/ipconfig.json +++ b/tests/fixtures/windows/windows-10/ipconfig.json @@ -1,133 +1 @@ -{ - "host_name": "DESKTOP-WIN10-PRO", - "primary_dns_suffix": null, - "node_type": "Hybrid", - "ip_routing_enabled": false, - "wins_proxy_enabled": false, - "dns_suffix_search_list": [ - "tailff123.ts.net", - "internal.companyname.com" - ], - "adapters": [ - { - "name_long": "Unknown adapter Tailscale", - "name": "Tailscale", - "type": "Unknown", - "connection_specific_dns_suffix": "tailff123.ts.net", - "connection_specific_dns_suffix_search_list": [ - "tailff123.ts.net" - ], - "description": "Tailscale Tunnel", - "physical_address": null, - "dhcp_enabled": false, - "autoconfiguration_enabled": true, - "ipv6_addresses": [ - { - "address": "fd7a:115c:a1e0:ab12:4843:cd96:6293:47b2", - "status": "Preferred" - } - ], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [ - { - "address": "fe80::99d0:ec2d:b2e7:536b", - "prefix_length": 8, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "100.115.71.66", - "subnet_mask": "255.255.255.255", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [ - "fec0:0:0:ffff::1%1", - "fec0:0:0:ffff::2%1", - "fec0:0:0:ffff::3%1" - ], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Ethernet adapter Ethernet 2", - "name": "Ethernet 2", - "type": "Ethernet", - "connection_specific_dns_suffix": "internal.companyname.com", - "connection_specific_dns_suffix_search_list": [], - "description": "ASIX AX88179 USB 3.0 to Gigabit Ethernet Adapter #2", - "physical_address": "F8-E4-3B-AD-F2-6D", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [ - { - "address": "fe80::c936:c2db:79ad:e1c6", - "prefix_length": 16, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "10.50.13.132", - "subnet_mask": "255.255.255.0", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [ - "10.50.13.1" - ], - "dhcp_server": "10.50.13.1", - "dhcpv6_iaid": "351866565", - "dhcpv6_client_duid": "00-01-00-01-2A-15-C3-11-1C-D3-05-F1-58-E1", - "dns_servers": [ - "10.50.13.1" - ], - "primary_wins_server": null, - "lease_expires": "2024-09-23T02:31:46", - "lease_obtained": "2023-06-22T10:39:04", - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Ethernet adapter Bluetooth Network Connection", - "name": "Bluetooth Network Connection", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Bluetooth Device (Personal Area Network)", - "physical_address": "1C-C1-0C-C3-25-B4", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - } - ], - "extras": [] -} +{"host_name":"DESKTOP-WIN10-PRO","primary_dns_suffix":null,"node_type":"Hybrid","ip_routing_enabled":false,"wins_proxy_enabled":false,"dns_suffix_search_list":["tailff123.ts.net","internal.companyname.com"],"adapters":[{"name_long":"Unknown adapter Tailscale","name":"Tailscale","type":"Unknown","connection_specific_dns_suffix":"tailff123.ts.net","connection_specific_dns_suffix_search_list":["tailff123.ts.net"],"description":"Tailscale Tunnel","physical_address":null,"dhcp_enabled":false,"autoconfiguration_enabled":true,"ipv6_addresses":[{"address":"fd7a:115c:a1e0:ab12:4843:cd96:6293:47b2","status":"Preferred"}],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[{"address":"fe80::99d0:ec2d:b2e7:536b","prefix_length":8,"status":"Preferred"}],"ipv4_addresses":[{"address":"100.115.71.66","subnet_mask":"255.255.255.255","status":"Preferred","autoconfigured":false}],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":["fec0:0:0:ffff::1%1","fec0:0:0:ffff::2%1","fec0:0:0:ffff::3%1"],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":true,"media_state":null,"extras":[]},{"name_long":"Ethernet adapter Ethernet 2","name":"Ethernet 2","type":"Ethernet","connection_specific_dns_suffix":"internal.companyname.com","connection_specific_dns_suffix_search_list":[],"description":"ASIX AX88179 USB 3.0 to Gigabit Ethernet Adapter #2","physical_address":"F8-E4-3B-AD-F2-6D","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[{"address":"fe80::c936:c2db:79ad:e1c6","prefix_length":16,"status":"Preferred"}],"ipv4_addresses":[{"address":"10.50.13.132","subnet_mask":"255.255.255.0","status":"Preferred","autoconfigured":false}],"default_gateways":["10.50.13.1"],"dhcp_server":"10.50.13.1","dhcpv6_iaid":"351866565","dhcpv6_client_duid":"00-01-00-01-2A-15-C3-11-1C-D3-05-F1-58-E1","dns_servers":["10.50.13.1"],"primary_wins_server":null,"lease_expires":"Monday, September 23, 2024 2:31:46 AM","lease_obtained":"Thursday, June 22, 2023 10:39:04 AM","netbios_over_tcpip":true,"media_state":null,"extras":[],"lease_expires_epoch":1727083906,"lease_expires_iso":"2024-09-23T02:31:46","lease_obtained_epoch":1687455544,"lease_obtained_iso":"2023-06-22T10:39:04"},{"name_long":"Ethernet adapter Bluetooth Network Connection","name":"Bluetooth Network Connection","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Bluetooth Device (Personal Area Network)","physical_address":"1C-C1-0C-C3-25-B4","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]}],"extras":[]} diff --git a/tests/fixtures/windows/windows-11/ipconfig.json b/tests/fixtures/windows/windows-11/ipconfig.json index 5976d916..3a1257ec 100644 --- a/tests/fixtures/windows/windows-11/ipconfig.json +++ b/tests/fixtures/windows/windows-11/ipconfig.json @@ -1,326 +1 @@ -{ - "host_name": "DESKTOP-WIN11-HOME", - "primary_dns_suffix": null, - "node_type": "Hybrid", - "ip_routing_enabled": false, - "wins_proxy_enabled": false, - "dns_suffix_search_list": [ - "localdomain" - ], - "adapters": [ - { - "name_long": "Ethernet adapter Ethernet", - "name": "Ethernet", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Intel(R) I211 Gigabit Network Connection", - "physical_address": "24-4B-FE-AB-43-C3", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Ethernet adapter Ethernet 2", - "name": "Ethernet 2", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Realtek PCIe 2.5GbE Family Controller", - "physical_address": "24-4B-FE-57-3D-F2", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Unknown adapter OpenVPN Data Channel Offload for NordVPN", - "name": "OpenVPN Data Channel Offload for NordVPN", - "type": "Unknown", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "OpenVPN Data Channel Offload", - "physical_address": null, - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Unknown adapter Local Area Connection", - "name": "Local Area Connection", - "type": "Unknown", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "TAP-NordVPN Windows Adapter V9", - "physical_address": "00-FF-4C-F4-5E-49", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Wireless LAN adapter Local Area Connection* 1", - "name": "Local Area Connection* 1", - "type": "Wireless LAN", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Microsoft Wi-Fi Direct Virtual Adapter", - "physical_address": "A8-7E-EA-5A-7F-DE", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Wireless LAN adapter Local Area Connection* 2", - "name": "Local Area Connection* 2", - "type": "Wireless LAN", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Microsoft Wi-Fi Direct Virtual Adapter #2", - "physical_address": "AA-7E-EA-F3-64-C3", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - }, - { - "name_long": "Ethernet adapter VMware Network Adapter VMnet1", - "name": "VMware Network Adapter VMnet1", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "VMware Virtual Ethernet Adapter for VMnet1", - "physical_address": "00-50-56-CC-27-73", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [ - { - "address": "fe80::f47d:9c7f:69dc:591e", - "prefix_length": 8, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "192.168.181.1", - "subnet_mask": "255.255.255.0", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [], - "dhcp_server": "192.168.181.254", - "dhcpv6_iaid": "771772502", - "dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6", - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": "2024-09-19T18:01:29", - "lease_obtained": "2024-09-19T08:31:29", - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Ethernet adapter VMware Network Adapter VMnet8", - "name": "VMware Network Adapter VMnet8", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "VMware Virtual Ethernet Adapter for VMnet8", - "physical_address": "00-50-56-C9-A3-78", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [ - { - "address": "fe80::4551:bf0d:59dd:a4f0", - "prefix_length": 10, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "192.168.213.1", - "subnet_mask": "255.255.255.0", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [], - "dhcp_server": "192.168.213.254", - "dhcpv6_iaid": "788549718", - "dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6", - "dns_servers": [], - "primary_wins_server": "192.168.213.2", - "lease_expires": "2024-09-19T18:01:29", - "lease_obtained": "2024-09-19T08:31:29", - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Wireless LAN adapter Wi-Fi", - "name": "Wi-Fi", - "type": "Wireless LAN", - "connection_specific_dns_suffix": "localdomain", - "connection_specific_dns_suffix_search_list": [], - "description": "Intel(R) Wi-Fi 6 AX200 160MHz", - "physical_address": "A8-7E-EA-55-26-B0", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [ - { - "address": "fd63:cc9c:65eb:3f95:57c2:aa:10d8:db08", - "status": "Preferred" - } - ], - "temporary_ipv6_addresses": [ - { - "address": "fd63:cc9c:65eb:3f95:8928:348e:d692:b7ef", - "status": "Preferred" - } - ], - "link_local_ipv6_addresses": [ - { - "address": "fe80::4fae:1380:5a1b:8b6b", - "prefix_length": 11, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "192.168.1.169", - "subnet_mask": "255.255.255.0", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [ - "192.168.1.1" - ], - "dhcp_server": "192.168.1.1", - "dhcpv6_iaid": "162037482", - "dhcpv6_client_duid": "00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6", - "dns_servers": [ - "192.168.1.1" - ], - "primary_wins_server": null, - "lease_expires": "2024-09-20T08:31:30", - "lease_obtained": "2024-09-19T08:31:30", - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Ethernet adapter Bluetooth Network Connection", - "name": "Bluetooth Network Connection", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Bluetooth Device (Personal Area Network)", - "physical_address": "A8-7E-EA-43-23-14", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - } - ], - "extras": [] -} +{"host_name":"DESKTOP-WIN11-HOME","primary_dns_suffix":null,"node_type":"Hybrid","ip_routing_enabled":false,"wins_proxy_enabled":false,"dns_suffix_search_list":["localdomain"],"adapters":[{"name_long":"Ethernet adapter Ethernet","name":"Ethernet","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Intel(R) I211 Gigabit Network Connection","physical_address":"24-4B-FE-AB-43-C3","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Ethernet adapter Ethernet 2","name":"Ethernet 2","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Realtek PCIe 2.5GbE Family Controller","physical_address":"24-4B-FE-57-3D-F2","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Unknown adapter OpenVPN Data Channel Offload for NordVPN","name":"OpenVPN Data Channel Offload for NordVPN","type":"Unknown","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"OpenVPN Data Channel Offload","physical_address":null,"dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Unknown adapter Local Area Connection","name":"Local Area Connection","type":"Unknown","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"TAP-NordVPN Windows Adapter V9","physical_address":"00-FF-4C-F4-5E-49","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Wireless LAN adapter Local Area Connection* 1","name":"Local Area Connection* 1","type":"Wireless LAN","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Microsoft Wi-Fi Direct Virtual Adapter","physical_address":"A8-7E-EA-5A-7F-DE","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Wireless LAN adapter Local Area Connection* 2","name":"Local Area Connection* 2","type":"Wireless LAN","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Microsoft Wi-Fi Direct Virtual Adapter #2","physical_address":"AA-7E-EA-F3-64-C3","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]},{"name_long":"Ethernet adapter VMware Network Adapter VMnet1","name":"VMware Network Adapter VMnet1","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"VMware Virtual Ethernet Adapter for VMnet1","physical_address":"00-50-56-CC-27-73","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[{"address":"fe80::f47d:9c7f:69dc:591e","prefix_length":8,"status":"Preferred"}],"ipv4_addresses":[{"address":"192.168.181.1","subnet_mask":"255.255.255.0","status":"Preferred","autoconfigured":false}],"default_gateways":[],"dhcp_server":"192.168.181.254","dhcpv6_iaid":"771772502","dhcpv6_client_duid":"00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6","dns_servers":[],"primary_wins_server":null,"lease_expires":"Thursday, September 19, 2024 6:01:29 PM","lease_obtained":"Thursday, September 19, 2024 8:31:29 AM","netbios_over_tcpip":true,"media_state":null,"extras":[],"lease_expires_epoch":1726794089,"lease_expires_iso":"2024-09-19T18:01:29","lease_obtained_epoch":1726759889,"lease_obtained_iso":"2024-09-19T08:31:29"},{"name_long":"Ethernet adapter VMware Network Adapter VMnet8","name":"VMware Network Adapter VMnet8","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"VMware Virtual Ethernet Adapter for VMnet8","physical_address":"00-50-56-C9-A3-78","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[{"address":"fe80::4551:bf0d:59dd:a4f0","prefix_length":10,"status":"Preferred"}],"ipv4_addresses":[{"address":"192.168.213.1","subnet_mask":"255.255.255.0","status":"Preferred","autoconfigured":false}],"default_gateways":[],"dhcp_server":"192.168.213.254","dhcpv6_iaid":"788549718","dhcpv6_client_duid":"00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6","dns_servers":[],"primary_wins_server":"192.168.213.2","lease_expires":"Thursday, September 19, 2024 6:01:29 PM","lease_obtained":"Thursday, September 19, 2024 8:31:29 AM","netbios_over_tcpip":true,"media_state":null,"extras":[],"lease_expires_epoch":1726794089,"lease_expires_iso":"2024-09-19T18:01:29","lease_obtained_epoch":1726759889,"lease_obtained_iso":"2024-09-19T08:31:29"},{"name_long":"Wireless LAN adapter Wi-Fi","name":"Wi-Fi","type":"Wireless LAN","connection_specific_dns_suffix":"localdomain","connection_specific_dns_suffix_search_list":[],"description":"Intel(R) Wi-Fi 6 AX200 160MHz","physical_address":"A8-7E-EA-55-26-B0","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[{"address":"fd63:cc9c:65eb:3f95:57c2:aa:10d8:db08","status":"Preferred"}],"temporary_ipv6_addresses":[{"address":"fd63:cc9c:65eb:3f95:8928:348e:d692:b7ef","status":"Preferred"}],"link_local_ipv6_addresses":[{"address":"fe80::4fae:1380:5a1b:8b6b","prefix_length":11,"status":"Preferred"}],"ipv4_addresses":[{"address":"192.168.1.169","subnet_mask":"255.255.255.0","status":"Preferred","autoconfigured":false}],"default_gateways":["192.168.1.1"],"dhcp_server":"192.168.1.1","dhcpv6_iaid":"162037482","dhcpv6_client_duid":"00-01-00-01-2C-CF-19-EB-24-4B-FE-5B-9B-E6","dns_servers":["192.168.1.1"],"primary_wins_server":null,"lease_expires":"Friday, September 20, 2024 8:31:30 AM","lease_obtained":"Thursday, September 19, 2024 8:31:30 AM","netbios_over_tcpip":true,"media_state":null,"extras":[],"lease_expires_epoch":1726846290,"lease_expires_iso":"2024-09-20T08:31:30","lease_obtained_epoch":1726759890,"lease_obtained_iso":"2024-09-19T08:31:30"},{"name_long":"Ethernet adapter Bluetooth Network Connection","name":"Bluetooth Network Connection","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Bluetooth Device (Personal Area Network)","physical_address":"A8-7E-EA-43-23-14","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]}],"extras":[]} diff --git a/tests/fixtures/windows/windows-7/ipconfig.json b/tests/fixtures/windows/windows-7/ipconfig.json index 53b15bed..a16abe8f 100644 --- a/tests/fixtures/windows/windows-7/ipconfig.json +++ b/tests/fixtures/windows/windows-7/ipconfig.json @@ -1,82 +1 @@ -{ - "host_name": "DESKTOP-WIN7", - "primary_dns_suffix": "somecompany.corp", - "node_type": "Hybrid", - "ip_routing_enabled": false, - "wins_proxy_enabled": false, - "dns_suffix_search_list": [ - "somecompany.corp" - ], - "adapters": [ - { - "name_long": "Ethernet adapter Local Area Connection", - "name": "Local Area Connection", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Intel(R) PRO/1000 MT Network Connection", - "physical_address": "00-0C-29-37-3B-4E", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [ - { - "address": "fe80::c447:d1ef:c29f:c44c", - "prefix_length": 10, - "status": "Preferred" - } - ], - "ipv4_addresses": [ - { - "address": "192.168.22.33", - "subnet_mask": "255.255.255.0", - "status": "Preferred", - "autoconfigured": false - } - ], - "default_gateways": [ - "192.168.22.1" - ], - "dhcp_server": "192.168.22.1", - "dhcpv6_iaid": "234881473", - "dhcpv6_client_duid": "00-01-00-01-29-4E-8F-8A-00-0C-29-88-1B-1F", - "dns_servers": [ - "192.168.22.151" - ], - "primary_wins_server": null, - "lease_expires": "2024-09-24T07:02:58", - "lease_obtained": "2024-09-20T12:13:59", - "netbios_over_tcpip": true, - "media_state": null, - "extras": [] - }, - { - "name_long": "Tunnel adapter isatap.{E24F3EA8-436E-3B26-8BB9-CED33928744B}", - "name": "isatap.{E24F3EA8-436E-3B26-8BB9-CED33928744B}", - "type": "Tunnel", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Microsoft ISATAP Adapter", - "physical_address": "00-00-00-00-00-00-00-E0", - "dhcp_enabled": false, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [], - "default_gateways": [], - "dhcp_server": null, - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [], - "primary_wins_server": null, - "lease_expires": null, - "lease_obtained": null, - "netbios_over_tcpip": null, - "media_state": "Media disconnected", - "extras": [] - } - ], - "extras": [] -} +{"host_name":"DESKTOP-WIN7","primary_dns_suffix":"somecompany.corp","node_type":"Hybrid","ip_routing_enabled":false,"wins_proxy_enabled":false,"dns_suffix_search_list":["somecompany.corp"],"adapters":[{"name_long":"Ethernet adapter Local Area Connection","name":"Local Area Connection","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Intel(R) PRO/1000 MT Network Connection","physical_address":"00-0C-29-37-3B-4E","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[{"address":"fe80::c447:d1ef:c29f:c44c","prefix_length":10,"status":"Preferred"}],"ipv4_addresses":[{"address":"192.168.22.33","subnet_mask":"255.255.255.0","status":"Preferred","autoconfigured":false}],"default_gateways":["192.168.22.1"],"dhcp_server":"192.168.22.1","dhcpv6_iaid":"234881473","dhcpv6_client_duid":"00-01-00-01-29-4E-8F-8A-00-0C-29-88-1B-1F","dns_servers":["192.168.22.151"],"primary_wins_server":null,"lease_expires":"Tuesday, September 24, 2024 7:02:58 AM","lease_obtained":"Friday, September 20, 2024 12:13:59 PM","netbios_over_tcpip":true,"media_state":null,"extras":[],"lease_expires_epoch":1727186578,"lease_expires_iso":"2024-09-24T07:02:58","lease_obtained_epoch":1726859639,"lease_obtained_iso":"2024-09-20T12:13:59"},{"name_long":"Tunnel adapter isatap.{E24F3EA8-436E-3B26-8BB9-CED33928744B}","name":"isatap.{E24F3EA8-436E-3B26-8BB9-CED33928744B}","type":"Tunnel","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Microsoft ISATAP Adapter","physical_address":"00-00-00-00-00-00-00-E0","dhcp_enabled":false,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[],"default_gateways":[],"dhcp_server":null,"dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":[],"primary_wins_server":null,"lease_expires":null,"lease_obtained":null,"netbios_over_tcpip":null,"media_state":"Media disconnected","extras":[]}],"extras":[]} diff --git a/tests/fixtures/windows/windows-xp/ipconfig.json b/tests/fixtures/windows/windows-xp/ipconfig.json index 5cf60b4a..d0c9a9db 100644 --- a/tests/fixtures/windows/windows-xp/ipconfig.json +++ b/tests/fixtures/windows/windows-xp/ipconfig.json @@ -1,51 +1 @@ -{ - "host_name": "DESKTOP-PC4", - "primary_dns_suffix": "somecompany.corp", - "node_type": "Unknown", - "ip_routing_enabled": false, - "wins_proxy_enabled": false, - "dns_suffix_search_list": [ - "somecompany.corp", - "somecompany.xyz" - ], - "adapters": [ - { - "name_long": "Ethernet adapter Local Area Connection", - "name": "Local Area Connection", - "type": "Ethernet", - "connection_specific_dns_suffix": null, - "connection_specific_dns_suffix_search_list": [], - "description": "Intel(R) PRO/1000 MT Network Connection", - "physical_address": "00-0C-29-25-B6-4D", - "dhcp_enabled": true, - "autoconfiguration_enabled": true, - "ipv6_addresses": [], - "temporary_ipv6_addresses": [], - "link_local_ipv6_addresses": [], - "ipv4_addresses": [ - { - "address": "192.168.22.135", - "subnet_mask": "255.255.255.0", - "status": null, - "autoconfigured": false - } - ], - "default_gateways": [ - "192.168.22.1" - ], - "dhcp_server": "192.168.22.1", - "dhcpv6_iaid": null, - "dhcpv6_client_duid": null, - "dns_servers": [ - "192.168.22.151" - ], - "primary_wins_server": null, - "lease_expires": "2024-09-22T22:31:26", - "lease_obtained": "2024-09-21T22:31:26", - "netbios_over_tcpip": null, - "media_state": null, - "extras": [] - } - ], - "extras": [] -} +{"host_name":"DESKTOP-PC4","primary_dns_suffix":"somecompany.corp","node_type":"Unknown","ip_routing_enabled":false,"wins_proxy_enabled":false,"dns_suffix_search_list":["somecompany.corp","somecompany.xyz"],"adapters":[{"name_long":"Ethernet adapter Local Area Connection","name":"Local Area Connection","type":"Ethernet","connection_specific_dns_suffix":null,"connection_specific_dns_suffix_search_list":[],"description":"Intel(R) PRO/1000 MT Network Connection","physical_address":"00-0C-29-25-B6-4D","dhcp_enabled":true,"autoconfiguration_enabled":true,"ipv6_addresses":[],"temporary_ipv6_addresses":[],"link_local_ipv6_addresses":[],"ipv4_addresses":[{"address":"192.168.22.135","subnet_mask":"255.255.255.0","status":null,"autoconfigured":false}],"default_gateways":["192.168.22.1"],"dhcp_server":"192.168.22.1","dhcpv6_iaid":null,"dhcpv6_client_duid":null,"dns_servers":["192.168.22.151"],"primary_wins_server":null,"lease_expires":"Sunday, September 22, 2024 10:31:26 PM","lease_obtained":"Saturday, September 21, 2024 10:31:26 PM","netbios_over_tcpip":null,"media_state":null,"extras":[],"lease_expires_epoch":1727069486,"lease_expires_iso":"2024-09-22T22:31:26","lease_obtained_epoch":1726983086,"lease_obtained_iso":"2024-09-21T22:31:26"}],"extras":[]} diff --git a/tests/test_jc_utils.py b/tests/test_jc_utils.py index 7d50c102..4370a50f 100644 --- a/tests/test_jc_utils.py +++ b/tests/test_jc_utils.py @@ -37,6 +37,8 @@ def test_utils_timestamp(self): '3/22/2021, 1:15:51 PM (Coordinated Universal Time)': {'string': '3/22/2021, 1:15:51 PM (Coordinated Universal Time)', 'format': 1705, 'naive': 1616444151, 'utc': 1616418951}, # Windows english format with UTC tz (found in systeminfo cli output) '3/22/2021, 1:15:51 PM (UTC+0000)': {'string': '3/22/2021, 1:15:51 PM (UTC+0000)', 'format': 1710, 'naive': 1616444151, 'utc': 1616418951}, + # Windows ipconfig cli output format + 'Thursday, June 22, 2023 10:39:04 AM': {'string': 'Thursday, June 22, 2023 10:39:04 AM', 'format': 1720, 'naive': 1687455544, 'utc': None}, # Google Big Table format with no timezone: '2000/01/01-01:00:00.000000': {'string': '2000/01/01-01:00:00.000000', 'format': 1750, 'naive': 946717200, 'utc': None}, # Google Big Table format with timezone: