Skip to content

Commit

Permalink
Merge pull request #195 from carlosmmatos/carlosmmatos/issue194
Browse files Browse the repository at this point in the history
fix(aws): check for network interfaces before trying to process
  • Loading branch information
carlosmmatos authored Oct 9, 2024
2 parents b9deaad + ccec772 commit aa15e41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions fig/backends/aws/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ def find_instance(self, instance_id, mac_address):
ec2instance = ec2.Instance(instance_id)
found = False
# Confirm the mac address matches
for iface in ec2instance.network_interfaces:
det_mac = mac_address.lower().replace(":", "").replace("-", "")
ins_mac = iface.mac_address.lower().replace(":", "").replace("-", "")
if det_mac == ins_mac:
found = True
if ec2instance.network_interfaces:
for iface in ec2instance.network_interfaces:
det_mac = mac_address.lower().replace(":", "").replace("-", "")
ins_mac = iface.mac_address.lower().replace(":", "").replace("-", "")
if det_mac == ins_mac:
found = True
if found: # pylint: disable=R1723
return region, ec2instance
except ClientError:
Expand Down Expand Up @@ -75,9 +76,10 @@ def submit(self):
self.event.instance_id, self.event.device_details["mac_address"])
return
try:
for _ in instance.network_interfaces:
# Only send alerts for instances we can find
send = True
if instance.network_interfaces:
for _ in instance.network_interfaces:
# Only send alerts for instances we can find
send = True

except ClientError:
# Not our instance
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ disable=
C0114,C0115,C0116,C0209,C0103,
R0903,R0912,R0915,
W0511,W0613,C0301,
W0719
W0719,R0917,R1702

[pylint.DESIGN]
max-parents=15
Expand Down

0 comments on commit aa15e41

Please sign in to comment.