chore(azure): add changes to azure fixers

This commit is contained in:
Daniel Barranquero
2025-06-03 17:38:09 +02:00
parent b30ee077da
commit fc826da50c
2 changed files with 15 additions and 11 deletions
@@ -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
@@ -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