From fc826da50c13ff9b815d2513598e40c2954e8dc9 Mon Sep 17 00:00:00 2001 From: Daniel Barranquero Date: Tue, 3 Jun 2025 17:38:09 +0200 Subject: [PATCH] chore(azure): add changes to azure fixers --- ...function_ftps_deployment_disabled_fixer.py | 24 ++++++++++--------- .../azure/services/app/app_service.py | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/prowler/providers/azure/services/app/app_function_ftps_deployment_disabled/app_function_ftps_deployment_disabled_fixer.py b/prowler/providers/azure/services/app/app_function_ftps_deployment_disabled/app_function_ftps_deployment_disabled_fixer.py index 59bd96deb5..ad69194da0 100644 --- a/prowler/providers/azure/services/app/app_function_ftps_deployment_disabled/app_function_ftps_deployment_disabled_fixer.py +++ b/prowler/providers/azure/services/app/app_function_ftps_deployment_disabled/app_function_ftps_deployment_disabled_fixer.py @@ -1,5 +1,7 @@ from typing import Optional +from azure.mgmt.web.models import SiteConfigResource + from prowler.lib.check.models import Check_Report_Azure from prowler.providers.azure.lib.fix.fixer import AzureFixer from prowler.providers.azure.services.app.app_client import app_client @@ -31,10 +33,14 @@ class AppFunctionFtpsDeploymentDisabledFixer(AzureFixer): bool: True if FTP/FTPS is disabled, False otherwise """ try: - # Get region and resource_id either from finding or kwargs + # First call parent fix method to handle common Azure fix operations + if not super().fix(finding, **kwargs): + return False + + # Get values either from finding or kwargs if finding: - resource_group = finding.resource.resource_group_name - app_name = finding.resource_id + resource_group = finding.resource.get("resource_group_name") + app_name = finding.resource_name suscription_name = finding.subscription else: resource_group = kwargs.get("resource_group") @@ -46,21 +52,17 @@ class AppFunctionFtpsDeploymentDisabledFixer(AzureFixer): "Resource group, app name and subscription name are required" ) - # Call parent fix method to handle common Azure fix operations - super().fix( - resource_group=resource_group, - app_name=app_name, - suscription_name=suscription_name, - ) - # Get the Azure client for this subscription client = app_client.clients[suscription_name] + # Create the SiteConfigResource object + site_config = SiteConfigResource(ftps_state="Disabled") + # Update the function configuration to disable FTP/FTPS client.web_apps.update_configuration( resource_group_name=resource_group, name=app_name, - site_config={"ftps_state": "Disabled"}, + site_config=site_config, ) return True diff --git a/prowler/providers/azure/services/app/app_service.py b/prowler/providers/azure/services/app/app_service.py index 584555e2ad..131b6a52c9 100644 --- a/prowler/providers/azure/services/app/app_service.py +++ b/prowler/providers/azure/services/app/app_service.py @@ -164,6 +164,7 @@ class App(AzureService): ftps_state=getattr( function_config, "ftps_state", None ), + resource_group_name=function.resource_group, ) } ) @@ -275,3 +276,4 @@ class FunctionApp: public_access: bool vnet_subnet_id: str ftps_state: Optional[str] + resource_group_name: str