Files
prowler/lib/outputs.py
Sergio Garcia ecefda11c7 feat(quiet): Add -q option. (#1211)
Co-authored-by: sergargar <sergio@verica.io>
2022-06-22 09:45:03 +02:00

31 lines
970 B
Python

from colorama import Fore, Style
def report(check_findings, output_options):
check_findings.sort(key=lambda x: x.region)
for finding in check_findings:
color = set_report_color(finding.status)
if output_options.is_quiet and "FAIL" in finding.status:
print(
f"{color}{finding.status}{Style.RESET_ALL} {finding.region}: {finding.result_extended}"
)
elif not output_options.is_quiet:
print(
f"{color}{finding.status}{Style.RESET_ALL} {finding.region}: {finding.result_extended}"
)
def set_report_color(status):
color = ""
if status == "PASS":
color = Fore.GREEN
elif status == "FAIL":
color = Fore.RED
elif status == "ERROR":
color = Fore.BLACK
elif status == "WARNING":
color = Fore.YELLOW
else:
raise Exception("Invalid Report Status. Must be PASS, FAIL, ERROR or WARNING")
return color