diff --git a/prowler/__main__.py b/prowler/__main__.py index a6151dec98..c53e0dbeff 100644 --- a/prowler/__main__.py +++ b/prowler/__main__.py @@ -325,7 +325,8 @@ def prowler(): remove_custom_checks_module(checks_folder, provider) # clean local directories - clean_provider_local_output_directories(args) + if args.clean_local_output_directories: + clean_provider_local_output_directories(args) # If there are failed findings exit code 3, except if -z is input if not args.ignore_exit_code_3 and stats["total_fail"] > 0: diff --git a/prowler/lib/cli/parser.py b/prowler/lib/cli/parser.py index 8db0782174..c9dfc14030 100644 --- a/prowler/lib/cli/parser.py +++ b/prowler/lib/cli/parser.py @@ -166,6 +166,12 @@ Detailed documentation at https://docs.prowler.cloud default=False, help="Set the output timestamp format as unix timestamps instead of iso format timestamps (default mode).", ) + common_outputs_parser.add_argument( + "--clean-local-output-directories", + action="store_true", + default=False, + help="Deletes local output directories when output reports are sent to external entities (i.e. S3 bucket)", + ) def __init_logging_parser__(self): # Logging Options diff --git a/tests/lib/cli/parser_test.py b/tests/lib/cli/parser_test.py index a307c541f6..ec0e8c6e76 100644 --- a/tests/lib/cli/parser_test.py +++ b/tests/lib/cli/parser_test.py @@ -78,6 +78,7 @@ class Test_Parser: assert not parsed.allowlist_file assert not parsed.resource_tags assert not parsed.ignore_unused_services + assert not parsed.clean_local_output_directories def test_default_parser_no_arguments_azure(self): provider = "azure" @@ -298,6 +299,11 @@ class Test_Parser: parsed = self.parser.parse(command) assert parsed.unix_timestamp + def test_root_parser_clean_local_output_directories(self): + command = [prowler_command, "--clean-local-output-directories"] + parsed = self.parser.parse(command) + assert parsed.clean_local_output_directories + def test_logging_parser_only_logs_set(self): command = [prowler_command, "--only-logs"] parsed = self.parser.parse(command)