fix(list-checks): handle listing checks when -s (#2540)

This commit is contained in:
Sergio Garcia
2023-07-03 11:48:40 +02:00
committed by GitHub
parent ead592a0bf
commit 47736910ca
2 changed files with 15 additions and 24 deletions

View File

@@ -12,7 +12,6 @@ from prowler.lib.check.check import (
exclude_services_to_run,
execute_checks,
list_categories,
list_checks,
list_services,
parse_checks_from_folder,
print_categories,
@@ -101,18 +100,6 @@ def prowler():
)
sys.exit()
# If -l/--list-checks passed as argument, print checks to execute and quit
if args.list_checks:
print_checks(provider, list_checks(provider), bulk_checks_metadata)
sys.exit()
# Set the audit info based on the selected provider
audit_info = set_provider_audit_info(provider, args.__dict__)
# Import custom checks from folder
if checks_folder:
parse_checks_from_folder(audit_info, checks_folder, provider)
# Load checks to execute
checks_to_execute = load_checks_to_execute(
bulk_checks_metadata,
@@ -126,6 +113,18 @@ def prowler():
provider,
)
# If -l/--list-checks passed as argument, print checks to execute and quit
if args.list_checks:
print_checks(provider, sorted(checks_to_execute), bulk_checks_metadata)
sys.exit()
# Set the audit info based on the selected provider
audit_info = set_provider_audit_info(provider, args.__dict__)
# Import custom checks from folder
if checks_folder:
parse_checks_from_folder(audit_info, checks_folder, provider)
# Exclude checks if -e/--excluded-checks
if excluded_checks:
checks_to_execute = exclude_checks_to_run(checks_to_execute, excluded_checks)
@@ -136,14 +135,14 @@ def prowler():
checks_to_execute, excluded_services, provider
)
# Sort final check list
checks_to_execute = sorted(checks_to_execute)
# Once the audit_info is set and we have the eventual checks based on the resource identifier,
# it is time to check what Prowler's checks are going to be executed
if audit_info.audit_resources:
checks_to_execute = set_provider_execution_parameters(provider, audit_info)
# Sort final check list
checks_to_execute = sorted(checks_to_execute)
# Parse Allowlist
allowlist_file = set_provider_allowlist(provider, audit_info, args)

View File

@@ -196,14 +196,6 @@ def list_services(provider: str) -> set():
return sorted(available_services)
def list_checks(provider: str) -> set():
available_checks = set()
checks_tuple = recover_checks_from_provider(provider)
for check_name, _ in checks_tuple:
available_checks.add(check_name)
return sorted(available_checks)
def list_categories(bulk_checks_metadata: dict) -> set():
available_categories = set()
for check in bulk_checks_metadata.values():