mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
fix(KeyError): Handle service key errors (#1819)
Co-authored-by: sergargar <sergargar@users.noreply.github.com>
This commit is contained in:
@@ -51,9 +51,11 @@ class Lambda:
|
||||
function["FunctionArn"], self.audit_resources
|
||||
)
|
||||
):
|
||||
lambda_runtime = None
|
||||
if "Runtime" in function:
|
||||
lambda_runtime = function["Runtime"]
|
||||
lambda_name = function["FunctionName"]
|
||||
lambda_arn = function["FunctionArn"]
|
||||
lambda_runtime = function["Runtime"]
|
||||
self.functions[lambda_name] = Function(
|
||||
name=lambda_name,
|
||||
arn=lambda_arn,
|
||||
|
||||
@@ -43,11 +43,14 @@ class CloudWatch:
|
||||
if not self.audit_resources or (
|
||||
is_resource_filtered(alarm["AlarmArn"], self.audit_resources)
|
||||
):
|
||||
metric_name = None
|
||||
if "MetricName" in alarm:
|
||||
metric_name = alarm["MetricName"]
|
||||
self.metric_alarms.append(
|
||||
MetricAlarm(
|
||||
alarm["AlarmArn"],
|
||||
alarm["AlarmName"],
|
||||
alarm["MetricName"],
|
||||
metric_name,
|
||||
alarm["Namespace"],
|
||||
regional_client.region,
|
||||
)
|
||||
|
||||
@@ -64,6 +64,7 @@ class EC2:
|
||||
http_endpoint = None
|
||||
public_dns = None
|
||||
public_ip = None
|
||||
private_ip = None
|
||||
instance_profile = None
|
||||
if "MetadataOptions" in instance:
|
||||
http_tokens = instance["MetadataOptions"]["HttpTokens"]
|
||||
@@ -76,6 +77,8 @@ class EC2:
|
||||
):
|
||||
public_dns = instance["PublicDnsName"]
|
||||
public_ip = instance["PublicIpAddress"]
|
||||
if "PrivateIpAddress" in instance:
|
||||
private_ip = instance["PrivateIpAddress"]
|
||||
if "IamInstanceProfile" in instance:
|
||||
instance_profile = instance["IamInstanceProfile"]
|
||||
|
||||
@@ -89,7 +92,7 @@ class EC2:
|
||||
instance["ImageId"],
|
||||
instance["LaunchTime"],
|
||||
instance["PrivateDnsName"],
|
||||
instance["PrivateIpAddress"],
|
||||
private_ip,
|
||||
public_dns,
|
||||
public_ip,
|
||||
http_tokens,
|
||||
|
||||
@@ -79,9 +79,14 @@ class EMR:
|
||||
master_node_security_group = cluster_info["Cluster"][
|
||||
"Ec2InstanceAttributes"
|
||||
]["EmrManagedMasterSecurityGroup"]
|
||||
master_node_additional_security_groups = cluster_info["Cluster"][
|
||||
"Ec2InstanceAttributes"
|
||||
]["AdditionalMasterSecurityGroups"]
|
||||
master_node_additional_security_groups = None
|
||||
if (
|
||||
"AdditionalMasterSecurityGroups"
|
||||
in cluster_info["Cluster"]["Ec2InstanceAttributes"]
|
||||
):
|
||||
master_node_additional_security_groups = cluster_info[
|
||||
"Cluster"
|
||||
]["Ec2InstanceAttributes"]["AdditionalMasterSecurityGroups"]
|
||||
self.clusters[cluster.id].master = Node(
|
||||
security_group_id=master_node_security_group,
|
||||
additional_security_groups_id=master_node_additional_security_groups,
|
||||
|
||||
@@ -40,8 +40,8 @@ class S3:
|
||||
|
||||
def __list_buckets__(self, audit_info):
|
||||
logger.info("S3 - Listing buckets...")
|
||||
buckets = []
|
||||
try:
|
||||
buckets = []
|
||||
list_buckets = self.client.list_buckets()
|
||||
for bucket in list_buckets["Buckets"]:
|
||||
try:
|
||||
@@ -67,11 +67,11 @@ class S3:
|
||||
logger.error(
|
||||
f"{bucket_region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return buckets
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return buckets
|
||||
|
||||
def __get_bucket_versioning__(self, bucket):
|
||||
logger.info("S3 - Get buckets versioning...")
|
||||
|
||||
Reference in New Issue
Block a user