Skip to content

Commit

Permalink
Merge pull request #54 from cisagov/metadata-refresh-11-17-23
Browse files Browse the repository at this point in the history
Metadata refresh 11 17 23
  • Loading branch information
Dbones202 authored Nov 17, 2023
2 parents afa9734 + d2a8143 commit c89078d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/network-architecture-verification-and-validation.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/navv/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""This file defines the version of this module."""
__version__ = "3.3.1"
__version__ = "3.3.2"
44 changes: 26 additions & 18 deletions src/navv/spreadsheet_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def get_inventory_data(ws, **kwargs):
ip=row[0].value,
name=row[1].value,
color=(copy(row[0].fill), copy(row[0].font)),
mac_address="",
vendor=""
)
return inventory

Expand Down Expand Up @@ -262,14 +264,17 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
* DHCP Broadcasting
* Multicast
* Within Segments identified
* Within Inventory, not within an Identified Segment
* Resolution by DNS, then Inventory, and then Unknown
* Appends name if External IP
* Private Network
* Resolution by DNS, Inventory, then Unknown
* External (Public IP space) or Internet
* Resolution by DNS, Unknown
This will capture the name description and the color coding identified within the worksheet.
"""
segment_ips = [segment.network for segment in segments]
desc_to_change = ("Unknown IP Address", IPV6_CELL_COLOR)
desc_to_change = ("Not Triggered IP", IPV6_CELL_COLOR)
if ip_to_check == str("0.0.0.0"):
desc_to_change = (
"Unassigned IPv4",
Expand All @@ -288,39 +293,42 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
IPV6_CELL_COLOR,
)
elif ip_to_check in segment_ips:
for segment in segments[:-1]:
if ip_to_check not in segment.network:
continue
elif ip_to_check in dns_data:
desc_to_change = (dns_data[ip_to_check] , segment.color)
elif ip_to_check in inventory:
desc_to_change = (inventory[ip_to_check].name, segment.color)
else:
for x in range(0, len(segments[:-1])):
if segments[x].network == ip_to_check:
if ip_to_check in dns_data:
resolution = dns_data[ip_to_check].name
elif ip_to_check in inventory:
resolution = inventory[ip_to_check].name
else:
resolution = f"Unknown device in {segments[x].name} network"
unk_int_IPs.add(ip_to_check)
if not netaddr.IPAddress(ip_to_check).is_private():
resolution = resolution + " {Non-Priv IP}"
desc_to_change = (
f"Unknown device in {segment.name} network",
segment.color,
)
unk_int_IPs.add(ip_to_check)
elif ip_to_check in inventory:
desc_to_change = (inventory[ip_to_check].name, inventory[ip_to_check].color)
resolution,
segments[x].color,
)
elif netaddr.IPAddress(ip_to_check).is_private():
if ip_to_check in dns_data:
desc_to_change = (dns_data[ip_to_check], INTERNAL_NETWORK_CELL_COLOR)
elif ip_to_check in inventory:
desc_to_change = (inventory[ip_to_check].name, INTERNAL_NETWORK_CELL_COLOR)
else:
desc_to_change = ("Unknown Internal address", INTERNAL_NETWORK_CELL_COLOR)
unk_int_IPs.add(ip_to_check)
else:
ext_IPs.add(ip_to_check)
resolution = "Unresolved external address"
if ip_to_check in dns_data:
resolution = dns_data[ip_to_check]
elif ip_to_check in inventory:
resolution = inventory[ip_to_check].name + " {Non-Priv IP}"
else:
try:
resolution = socket.gethostbyaddr(ip_to_check)[0]
except socket.herror:
ALREADY_UNRESOLVED.append(ip_to_check)
finally:
dns_data[ip_to_check] = resolution
resolution = "Unresolved external address"
desc_to_change = (resolution, EXTERNAL_NETWORK_CELL_COLOR)
return desc_to_change

Expand Down

0 comments on commit c89078d

Please sign in to comment.