Skip to content

Commit

Permalink
feat(aisearch): use Check_Report_Azure constructor properly in AISear…
Browse files Browse the repository at this point in the history
…ch checks (#6506)
  • Loading branch information
puchy22 authored Jan 14, 2025
1 parent 1c4426e commit c056d39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions prowler/providers/azure/services/aisearch/aisearch_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from dataclasses import dataclass

from azure.mgmt.search import SearchManagementClient
from pydantic import BaseModel

from prowler.lib.logger import logger
from prowler.providers.azure.azure_provider import AzureProvider
Expand All @@ -23,6 +22,7 @@ def _get_aisearch_services(self):
aisearch_services[subscription].update(
{
aisearch_service.id: AISearchService(
id=aisearch_service.id,
name=aisearch_service.name,
location=aisearch_service.location,
public_network_access=(
Expand All @@ -41,8 +41,8 @@ def _get_aisearch_services(self):
return aisearch_services


@dataclass
class AISearchService:
class AISearchService(BaseModel):
id: str
name: str
location: str
public_network_access: bool
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ def execute(self) -> List[Check_Report_Azure]:
subscription_name,
aisearch_services,
) in aisearch_client.aisearch_services.items():
for aisearch_service_id, aisearch_service in aisearch_services.items():
report = Check_Report_Azure(self.metadata())
for aisearch_service in aisearch_services.values():
report = Check_Report_Azure(
metadata=self.metadata(), resource_metadata=aisearch_service
)
report.subscription = subscription_name
report.resource_name = aisearch_service.name
report.resource_id = aisearch_service_id
report.location = aisearch_service.location
report.status = "FAIL"
report.status_extended = f"AISearch Service {aisearch_service.name} from subscription {subscription_name} allows public access."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_aisearch_service_not_publicly_accessible_enabled(self):
aisearch_client.aisearch_services = {
AZURE_SUBSCRIPTION_ID: {
aisearch_service_id: AISearchService(
id=aisearch_service_id,
name=aisearch_service_name,
location="westeurope",
public_network_access=True,
Expand All @@ -61,6 +62,7 @@ def test_aisearch_service_not_publicly_accessible_enabled(self):
result[0].status_extended
== f"AISearch Service {aisearch_service_name} from subscription {AZURE_SUBSCRIPTION_ID} allows public access."
)
assert result[0].resource_id == aisearch_service_id
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
assert result[0].resource_name == aisearch_service_name
assert result[0].location == "westeurope"
Expand All @@ -72,6 +74,7 @@ def test_aisearch_service_not_publicly_accessible_disabled(self):
aisearch_client.aisearch_services = {
AZURE_SUBSCRIPTION_ID: {
aisearch_service_id: AISearchService(
id=aisearch_service_id,
name=aisearch_service_name,
location="westeurope",
public_network_access=False,
Expand All @@ -98,6 +101,7 @@ def test_aisearch_service_not_publicly_accessible_disabled(self):
result[0].status_extended
== f"AISearch Service {aisearch_service_name} from subscription {AZURE_SUBSCRIPTION_ID} does not allows public access."
)
assert result[0].resource_id == aisearch_service_id
assert result[0].subscription == AZURE_SUBSCRIPTION_ID
assert result[0].resource_name == aisearch_service_name
assert result[0].resource_id == aisearch_service_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def mock_storage_get_aisearch_services(_):
return {
AZURE_SUBSCRIPTION_ID: {
"aisearch_service_id-1": AISearchService(
id="aisearch_service_id-1",
name="name",
location="westeurope",
public_network_access=True,
Expand Down

0 comments on commit c056d39

Please sign in to comment.