mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-11 15:25:10 +00:00
feat(list-services): List Prowler available services by provider (#1222)
This commit is contained in:
@@ -82,8 +82,24 @@ def parse_checks_from_file(input_file: str, provider: str) -> set:
|
||||
return checks_to_execute
|
||||
|
||||
|
||||
def list_services(provider: str) -> set:
|
||||
available_services = set()
|
||||
checks = recover_checks_from_provider(provider)
|
||||
for check_name in checks:
|
||||
# Format: "providers.{provider}.services.{service}.{check_name}.{check_name}"
|
||||
service_name = check_name.split(".")[3]
|
||||
available_services.add(service_name)
|
||||
return available_services
|
||||
|
||||
|
||||
def print_services(service_list: set):
|
||||
print(f"Available Services:")
|
||||
for service in service_list:
|
||||
print(f"- {service}")
|
||||
|
||||
|
||||
# List available groups
|
||||
def list_groups(provider: str) -> list:
|
||||
def list_groups(provider: str):
|
||||
groups = parse_groups_from_file(groups_file)
|
||||
print(f"Available Groups:")
|
||||
|
||||
|
||||
18
prowler
18
prowler
@@ -14,6 +14,8 @@ from lib.check.check import (
|
||||
exclude_services_to_run,
|
||||
import_check,
|
||||
list_groups,
|
||||
list_services,
|
||||
print_services,
|
||||
run_check,
|
||||
set_output_options,
|
||||
)
|
||||
@@ -33,14 +35,22 @@ if __name__ == "__main__":
|
||||
group.add_argument("-C", "--checks-file", nargs="?", help="List of checks")
|
||||
group.add_argument("-s", "--services", nargs="+", help="List of services")
|
||||
group.add_argument("-g", "--groups", nargs="+", help="List of groups")
|
||||
group.add_argument("-L", "--list-groups", action="store_true", help="List groups")
|
||||
parser.add_argument("-e", "--excluded-checks", nargs="+", help="Checks to exclude")
|
||||
parser.add_argument("-E", "--excluded-groups", nargs="+", help="Groups to exclude")
|
||||
parser.add_argument(
|
||||
"-S", "--excluded-services", nargs="+", help="Services to exclude"
|
||||
)
|
||||
|
||||
parser.add_argument("-l", "--list-checks", action="store_true", help="List checks")
|
||||
list_group = parser.add_mutually_exclusive_group()
|
||||
list_group.add_argument(
|
||||
"-L", "--list-groups", action="store_true", help="List groups"
|
||||
)
|
||||
list_group.add_argument(
|
||||
"-l", "--list-checks", action="store_true", help="List checks"
|
||||
)
|
||||
list_group.add_argument(
|
||||
"--list-services", action="store_true", help="List services"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-b", "--no-banner", action="store_false", help="Hide Prowler Banner"
|
||||
@@ -135,6 +145,10 @@ if __name__ == "__main__":
|
||||
list_groups(provider)
|
||||
sys.exit()
|
||||
|
||||
if args.list_services:
|
||||
print_services(list_services(provider))
|
||||
sys.exit()
|
||||
|
||||
# Load checks metadata
|
||||
logger.debug("Loading checks metadata from .metadata.json files")
|
||||
bulk_checks_metadata = bulk_load_checks_metadata(provider)
|
||||
|
||||
Reference in New Issue
Block a user