Skip to content

Commit

Permalink
Update spreadsheet_tools.py to address error with desc_to_change vari…
Browse files Browse the repository at this point in the history
…able. Bump version to 3.3.1
  • Loading branch information
Dbones202 committed Nov 17, 2023
1 parent afa9734 commit 338728c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 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"
43 changes: 26 additions & 17 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 @@ -269,7 +271,7 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
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 +290,46 @@ 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 ip_to_check in inventory:
# desc_to_change = (inventory[ip_to_check].name, inventory[ip_to_check].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 338728c

Please sign in to comment.