mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-04 02:04:06 +00:00
fix(app): change api call for ftps_state (#7923)
This commit is contained in:
@@ -38,6 +38,7 @@ All notable changes to the **Prowler SDK** are documented in this file.
|
||||
- Handle `0` at the start and end of account uids in Prowler Dashboard [(#7955)](https://github.com/prowler-cloud/prowler/pull/7955)
|
||||
- Typo in PCI 4.0 for K8S provider [(#7971)](https://github.com/prowler-cloud/prowler/pull/7971)
|
||||
- AWS root credentials checks always verify if root credentials are enabled [(#7967)](https://github.com/prowler-cloud/prowler/pull/7967)
|
||||
- Update SDK Azure call for ftps_state in the App Service [(#7923)](https://github.com/prowler-cloud/prowler/pull/7923)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -132,10 +132,16 @@ class App(AzureService):
|
||||
else:
|
||||
function_keys = None
|
||||
|
||||
function_config = self._get_function_config(
|
||||
application_settings = self._list_application_settings(
|
||||
subscription_name, function.resource_group, function.name
|
||||
)
|
||||
|
||||
function_config = self._get_function_config(
|
||||
subscription_name,
|
||||
function.resource_group,
|
||||
function.name,
|
||||
)
|
||||
|
||||
functions[subscription_name].update(
|
||||
{
|
||||
function.id: FunctionApp(
|
||||
@@ -145,7 +151,7 @@ class App(AzureService):
|
||||
kind=function.kind,
|
||||
function_keys=function_keys,
|
||||
enviroment_variables=getattr(
|
||||
function_config, "properties", None
|
||||
application_settings, "properties", None
|
||||
),
|
||||
identity=getattr(function, "identity", None),
|
||||
public_access=(
|
||||
@@ -218,7 +224,7 @@ class App(AzureService):
|
||||
|
||||
def _get_function_config(self, subscription, resource_group, name):
|
||||
try:
|
||||
return self.clients[subscription].web_apps.list_application_settings(
|
||||
return self.clients[subscription].web_apps.get_configuration(
|
||||
resource_group_name=resource_group,
|
||||
name=name,
|
||||
)
|
||||
@@ -228,6 +234,18 @@ class App(AzureService):
|
||||
)
|
||||
return None
|
||||
|
||||
def _list_application_settings(self, subscription, resource_group, name):
|
||||
try:
|
||||
return self.clients[subscription].web_apps.list_application_settings(
|
||||
resource_group_name=resource_group,
|
||||
name=name,
|
||||
)
|
||||
except Exception as error:
|
||||
logger.error(
|
||||
f"Error getting application settings for {name} in {resource_group}: {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
@dataclass
|
||||
class ManagedServiceIdentity:
|
||||
|
||||
@@ -200,3 +200,47 @@ class Test_App_Service:
|
||||
.name
|
||||
== "name_diagnostic_setting2"
|
||||
)
|
||||
|
||||
def test_app_service_get_functions(self):
|
||||
with (
|
||||
patch(
|
||||
"prowler.providers.common.provider.Provider.get_global_provider",
|
||||
return_value=set_mocked_azure_provider(),
|
||||
),
|
||||
patch(
|
||||
"prowler.providers.azure.services.monitor.monitor_service.Monitor",
|
||||
new=MagicMock(),
|
||||
),
|
||||
):
|
||||
from prowler.providers.azure.services.app.app_service import FunctionApp
|
||||
|
||||
mock_function = FunctionApp(
|
||||
id="/subscriptions/resource_id",
|
||||
name="functionapp-1",
|
||||
location="West Europe",
|
||||
kind="functionapp",
|
||||
function_keys=None,
|
||||
enviroment_variables=None,
|
||||
identity=ManagedServiceIdentity(type="SystemAssigned"),
|
||||
public_access=True,
|
||||
vnet_subnet_id="",
|
||||
ftps_state="FtpsOnly",
|
||||
)
|
||||
|
||||
app_service = MagicMock()
|
||||
app_service.functions = {
|
||||
"mock-subscription": {"/subscriptions/resource_id": mock_function}
|
||||
}
|
||||
|
||||
assert (
|
||||
app_service.functions["mock-subscription"][
|
||||
"/subscriptions/resource_id"
|
||||
].ftps_state
|
||||
== "FtpsOnly"
|
||||
)
|
||||
assert (
|
||||
app_service.functions["mock-subscription"][
|
||||
"/subscriptions/resource_id"
|
||||
].name
|
||||
== "functionapp-1"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user