From 021aeeca63157291d57c882e8f8a88da289728b8 Mon Sep 17 00:00:00 2001 From: Carlos Matos Date: Sat, 21 Sep 2024 18:53:40 -0400 Subject: [PATCH 1/2] fix(aws): check for network interfaces before trying to process --- fig/backends/aws/__init__.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fig/backends/aws/__init__.py b/fig/backends/aws/__init__.py index 430d33f..8bc58b2 100644 --- a/fig/backends/aws/__init__.py +++ b/fig/backends/aws/__init__.py @@ -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: @@ -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 From ccec77252836878d25df7c966086d6a08d5e3864 Mon Sep 17 00:00:00 2001 From: Carlos Matos Date: Wed, 9 Oct 2024 11:50:27 -0400 Subject: [PATCH 2/2] chore: update lint to ignore current warning --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 9caa5ff..bfe7a81 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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