Repository: prowler-cloud/prowler
Pull request: fix(azure): containerregistry_not_publicly_accesible is not accurate
### Context

Fixes #5937

### Description

The check is indicating that it is FAIL when it is really Disabled.

### Checklist

- Are there new checks included in this PR? No
    - If so, do we need to update permissions for the provider? Please review this carefully.
- [x] Review if the code is being covered by tests.
- [x] Review if code is being documented following this specification https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings
- [x] Review if backport is needed.

### License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Problem statement:
AZURE check registry_not_publicly_accessible is working badly
### Steps to Reproduce

 python prowler.py azure --az-cli-auth    --subscription-id  XXXXXX --check registry_not_publicly_accessible

### Expected behavior

The check is indicating that it is FAIL when it is really Disabled. 
Line 23 , file containerregistry_not_publicly_accessible.py, it is being used network_rule_set property instead of public_network_access

### Actual Result with Screenshots or Logs

It does not generate a code error but rather a bad status result

### How did you install Prowler?

Cloning the repository from github.com (git clone)

### Environment Resource

WSL2 (Ubuntu)

### OS used

Windows

### Prowler version

Prowler 5.0.0 (You are running the latest version, yay!)

### Pip version

pip 24.0 from /home/xxxxxxx/.cache/pypoetry/virtualenvs/prowler-voSyvL3c-py3.12/lib/python3.12/site-packages/pip (python 3.12)

### Context

_No response_

Hints from issue discussion:

Commit message: fix(AZURE): containerregistry_not_publicly_accesible is working badly fix #5937

Patch to review:
diff --git a/prowler/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible.py b/prowler/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible.py
index d8a6a41da4..d63d1a5e28 100644
--- a/prowler/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible.py
+++ b/prowler/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible.py
@@ -18,12 +18,7 @@ def execute(self) -> list[Check_Report_Azure]:
                 report.status = "FAIL"
                 report.status_extended = f"Container Registry {container_registry_info.name} from subscription {subscription} allows unrestricted network access."
 
-                if (
-                    getattr(
-                        container_registry_info.network_rule_set, "default_action", ""
-                    ).lower()
-                    == "deny"
-                ):
+                if not container_registry_info.public_network_access:
                     report.status = "PASS"
                     report.status_extended = f"Container Registry {container_registry_info.name} from subscription {subscription} does not allow unrestricted network access."
 
diff --git a/prowler/providers/azure/services/containerregistry/containerregistry_service.py b/prowler/providers/azure/services/containerregistry/containerregistry_service.py
index 6c3840febc..b7df1f6394 100644
--- a/prowler/providers/azure/services/containerregistry/containerregistry_service.py
+++ b/prowler/providers/azure/services/containerregistry/containerregistry_service.py
@@ -37,8 +37,10 @@ def _get_container_registries(self):
                                 resource_group=resource_group,
                                 sku=getattr(registry.sku, "name", ""),
                                 login_server=getattr(registry, "login_server", ""),
-                                public_network_access=getattr(
-                                    registry, "public_network_access", ""
+                                public_network_access=(
+                                    False
+                                    if registry.public_network_access == "Disabled"
+                                    else True
                                 ),
                                 admin_user_enabled=getattr(
                                     registry, "admin_user_enabled", False
@@ -93,7 +95,7 @@ class ContainerRegistryInfo:
     resource_group: str
     sku: str
     login_server: str
-    public_network_access: str
+    public_network_access: bool
     admin_user_enabled: bool
     network_rule_set: NetworkRuleSet
     monitor_diagnostic_settings: list[DiagnosticSetting]
diff --git a/tests/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible_test.py b/tests/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible_test.py
index 827c889b73..8239aa5b70 100644
--- a/tests/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible_test.py
+++ b/tests/providers/azure/services/containerregistry/containerregistry_not_publicly_accessible/containerregistry_not_publicly_accessible_test.py
@@ -57,7 +57,7 @@ def test_container_registry_network_access_unrestricted(self):
                         resource_group="mock_resource_group",
                         sku="Basic",
                         login_server="mock_login_server.azurecr.io",
-                        public_network_access="Enabled",
+                        public_network_access=True,
                         admin_user_enabled=True,
                         network_rule_set=NetworkRuleSet(default_action="Allow"),
                         private_endpoint_connections=[],
@@ -131,7 +131,7 @@ def test_container_registry_network_access_restricted(self):
                         resource_group="mock_resource_group",
                         sku="Basic",
                         login_server="mock_login_server.azurecr.io",
-                        public_network_access="Enabled",
+                        public_network_access=False,
                         admin_user_enabled=False,
                         network_rule_set=NetworkRuleSet(default_action="Deny"),
                         private_endpoint_connections=[],
diff --git a/tests/providers/azure/services/containerregistry/containerregistry_service_test.py b/tests/providers/azure/services/containerregistry/containerregistry_service_test.py
index 31ca7cea9a..69017234df 100644
--- a/tests/providers/azure/services/containerregistry/containerregistry_service_test.py
+++ b/tests/providers/azure/services/containerregistry/containerregistry_service_test.py
@@ -32,7 +32,7 @@ def test_get_container_registry(self):
                         resource_group="mock_resource_group",
                         sku="Basic",
                         login_server="mock_login_server.azurecr.io",
-                        public_network_access="Enabled",
+                        public_network_access=False,
                         admin_user_enabled=True,
                         network_rule_set=None,
                         private_endpoint_connections=[],
@@ -71,7 +71,7 @@ def test_get_container_registry(self):
             assert registry_info.resource_group == "mock_resource_group"
             assert registry_info.sku == "Basic"
             assert registry_info.login_server == "mock_login_server.azurecr.io"
-            assert registry_info.public_network_access == "Enabled"
+            assert registry_info.public_network_access is False
             assert registry_info.admin_user_enabled is True
             assert isinstance(registry_info.monitor_diagnostic_settings, list)
 


Code review comments:
diff_hunk: @@ -37,8 +37,10 @@ def _get_container_registries(self):
                                 resource_group=resource_group,
                                 sku=getattr(registry.sku, "name", ""),
                                 login_server=getattr(registry, "login_server", ""),
-                                public_network_access=getattr(
-                                    registry, "public_network_access", ""
+                                public_network_access=(
+                                    False
+                                    if registry.public_network_access == "Disabled"
path: prowler/providers/azure/services/containerregistry/containerregistry_service.py
text: @user1:
```suggestion
                                    if getattr(registry, "public_network_access" "Enabled") == "Disabled"
```
Please add this, as according to [Microsoft documentation](https://learn.microsoft.com/en-us/python/api/azure-mgmt-containerregistry/azure.mgmt.containerregistry.v2023_11_01_preview.models.registry?view=azure-python) `public_network_access` is not mandatory and could be None.

diff_hunk: @@ -71,7 +71,7 @@ def test_get_container_registry(self):
             assert registry_info.resource_group == "mock_resource_group"
             assert registry_info.sku == "Basic"
             assert registry_info.login_server == "mock_login_server.azurecr.io"
-            assert registry_info.public_network_access == "Enabled"
+            assert registry_info.public_network_access is False
path: tests/providers/azure/services/containerregistry/containerregistry_service_test.py
text: @user1:
```suggestion
            assert not registry_info.public_network_access
```