Skip to content

Commit

Permalink
fix(compliance): check if custom check has compliance metadata (#4208)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergargar committed Jun 7, 2024
1 parent 2a139e3 commit 1d64ca4
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions prowler/lib/outputs/compliance/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,28 @@ def get_check_compliance_frameworks_in_input(
):
"""get_check_compliance_frameworks_in_input returns a list of Compliance for the given check if the compliance framework is present in the input compliance to execute"""
check_compliances = []
if bulk_checks_metadata and bulk_checks_metadata[check_id]:
for compliance in bulk_checks_metadata[check_id].Compliance:
compliance_name = ""
if compliance.Version:
compliance_name = (
compliance.Framework.lower()
+ "_"
+ compliance.Version.lower()
+ "_"
+ compliance.Provider.lower()
)
else:
compliance_name = (
compliance.Framework.lower() + "_" + compliance.Provider.lower()
)
if compliance_name.replace("-", "_") in input_compliance_frameworks:
check_compliances.append(compliance)
try:
if bulk_checks_metadata and bulk_checks_metadata.get(check_id):
for compliance in bulk_checks_metadata[check_id].Compliance:
compliance_name = ""
if compliance.Version:
compliance_name = (
compliance.Framework.lower()
+ "_"
+ compliance.Version.lower()
+ "_"
+ compliance.Provider.lower()
)
else:
compliance_name = (
compliance.Framework.lower() + "_" + compliance.Provider.lower()
)
if compliance_name.replace("-", "_") in input_compliance_frameworks:
check_compliances.append(compliance)
except Exception as error:
logger.error(
f"{error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
)
return check_compliances


Expand Down

0 comments on commit 1d64ca4

Please sign in to comment.