mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
fix(key_error): remove KeyError. (#1326)
This commit is contained in:
@@ -17,22 +17,18 @@ class iam_disable_30_days_credentials(Check):
|
||||
report.resource_arn = user.arn
|
||||
report.region = iam_client.region
|
||||
if user.password_last_used and user.password_last_used != "":
|
||||
try:
|
||||
time_since_insertion = (
|
||||
datetime.datetime.now()
|
||||
- datetime.datetime.strptime(
|
||||
str(user.password_last_used), "%Y-%m-%d %H:%M:%S+00:00"
|
||||
)
|
||||
time_since_insertion = (
|
||||
datetime.datetime.now()
|
||||
- datetime.datetime.strptime(
|
||||
str(user.password_last_used), "%Y-%m-%d %H:%M:%S+00:00"
|
||||
)
|
||||
if time_since_insertion.days > maximum_expiration_days:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = f"User {user.name} has not logged into the console in the past 30 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"User {user.name} has logged into the console in the past 30 days."
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
)
|
||||
if time_since_insertion.days > maximum_expiration_days:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = f"User {user.name} has not logged into the console in the past 30 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"User {user.name} has logged into the console in the past 30 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = (
|
||||
|
||||
@@ -17,22 +17,18 @@ class iam_disable_90_days_credentials(Check):
|
||||
report.resource_id = user.name
|
||||
report.resource_arn = user.arn
|
||||
if user.password_last_used and user.password_last_used != "":
|
||||
try:
|
||||
time_since_insertion = (
|
||||
datetime.datetime.now()
|
||||
- datetime.datetime.strptime(
|
||||
str(user.password_last_used), "%Y-%m-%d %H:%M:%S+00:00"
|
||||
)
|
||||
time_since_insertion = (
|
||||
datetime.datetime.now()
|
||||
- datetime.datetime.strptime(
|
||||
str(user.password_last_used), "%Y-%m-%d %H:%M:%S+00:00"
|
||||
)
|
||||
if time_since_insertion.days > maximum_expiration_days:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = f"User {user.name} has not logged into the console in the past 90 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"User {user.name} has logged into the console in the past 90 days."
|
||||
|
||||
except KeyError:
|
||||
pass
|
||||
)
|
||||
if time_since_insertion.days > maximum_expiration_days:
|
||||
report.status = "FAIL"
|
||||
report.status_extended = f"User {user.name} has not logged into the console in the past 90 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
report.status_extended = f"User {user.name} has logged into the console in the past 90 days."
|
||||
else:
|
||||
report.status = "PASS"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user