Skip to content

Commit 06d72ef

Browse files
authored
Merge pull request #53 from cisagov/hotfix/fixed-error-in-metadata-on-ip-addresses
Update spreadsheet_tools.py to address error with desc_to_change vari…
2 parents 3d1f468 + 7b4e379 commit 06d72ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/navv/spreadsheet_tools.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
269269
This will capture the name description and the color coding identified within the worksheet.
270270
"""
271271
segment_ips = [segment.network for segment in segments]
272+
desc_to_change = ("Unknown IP Address", IPV6_CELL_COLOR)
272273
if ip_to_check == str("0.0.0.0"):
273274
desc_to_change = (
274275
"Unassigned IPv4",
@@ -290,9 +291,9 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
290291
for segment in segments[:-1]:
291292
if ip_to_check not in segment.network:
292293
continue
293-
if ip_to_check in dns_data:
294-
desc_to_change = (dns_data[ip_to_check], segment.color)
295-
if ip_to_check in inventory:
294+
elif ip_to_check in dns_data:
295+
desc_to_change = (dns_data[ip_to_check] , segment.color)
296+
elif ip_to_check in inventory:
296297
desc_to_change = (inventory[ip_to_check].name, segment.color)
297298
else:
298299
desc_to_change = (
@@ -310,13 +311,13 @@ def handle_ip(ip_to_check, dns_data, inventory, segments, ext_IPs, unk_int_IPs):
310311
unk_int_IPs.add(ip_to_check)
311312
else:
312313
ext_IPs.add(ip_to_check)
314+
resolution = "Unresolved external address"
313315
if ip_to_check in dns_data:
314316
resolution = dns_data[ip_to_check]
315317
else:
316318
try:
317319
resolution = socket.gethostbyaddr(ip_to_check)[0]
318320
except socket.herror:
319-
resolution = "Unresolved external address"
320321
ALREADY_UNRESOLVED.append(ip_to_check)
321322
finally:
322323
dns_data[ip_to_check] = resolution

0 commit comments

Comments
 (0)