diff --git a/prowler/providers/aws/lib/service/service.py b/prowler/providers/aws/lib/service/service.py index 847502a191..75194d018e 100644 --- a/prowler/providers/aws/lib/service/service.py +++ b/prowler/providers/aws/lib/service/service.py @@ -104,18 +104,22 @@ class AWSService: # Make the task disappear once completed # self.progress.remove_task(task_id) - def progress_decorator(self, func): + @staticmethod + def progress_decorator(func): """Decorator to update the progress bar before and after a function call.""" @wraps(func) - def wrapper(*args, **kwargs): - task_name = func.__name__.replace("_", " ").capitalize() + def wrapper(self, *args, **kwargs): + # Trim leading and trailing underscores from the call's name + func_name = func.__name__.strip("_") + # Add Capitalization + func_name = " ".join([x.capitalize() for x in func_name.split("_")]) task_id = self.task_progress_bar.add_task( - f"- {task_name}...", total=1, task_type="Service" + f"- {func_name}...", total=1, task_type="Service" ) self.progress_tasks.append(task_id) - result = func(*args, **kwargs) # Execute the function + result = func(self, *args, **kwargs) # Execute the function self.task_progress_bar.update(task_id, advance=1) # self.task_progress_bar.remove_task(task_id) # Uncomment if you want to remove the task on completion diff --git a/prowler/providers/aws/services/cloudfront/cloudfront_service.py b/prowler/providers/aws/services/cloudfront/cloudfront_service.py index a31fb107f2..64d39ce5d6 100644 --- a/prowler/providers/aws/services/cloudfront/cloudfront_service.py +++ b/prowler/providers/aws/services/cloudfront/cloudfront_service.py @@ -53,7 +53,6 @@ class CloudFront(AWSService): f"{region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" ) - @AWSService.progress_decorator def __get_distribution_config__(self, distribution_id, client, region) -> dict: try: distribution_config = client.get_distribution_config(Id=distribution_id)