Skip to content

Commit

Permalink
Merge branch 'dev' into fix/spaces_in_program_name
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjonbrazil authored Oct 20, 2024
2 parents 51e2829 + a8f769e commit 7bdfc8d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 611 deletions.
39 changes: 20 additions & 19 deletions jc/parsers/ipconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ip_routing_enabled": boolean,
"wins_proxy_enabled": boolean,
"dns_suffix_search_list": [
string
string
],
"adapters": [
{
Expand Down Expand Up @@ -51,7 +51,7 @@
{
"address": string,
"status": string,
"prefix_length": int,
"prefix_length": integer,
}
],
"ipv4_addresses": [
Expand All @@ -72,22 +72,25 @@
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>: string
]
}
],
"extras": []
}
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
Expand Down Expand Up @@ -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", [])]
Expand Down
1 change: 1 addition & 0 deletions jc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
134 changes: 1 addition & 133 deletions tests/fixtures/windows/windows-10/ipconfig.json
Original file line number Diff line number Diff line change
@@ -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":[]}
Loading

0 comments on commit 7bdfc8d

Please sign in to comment.