From 2679ca41a0ff4cd9daa8a50b591671abd6c029af Mon Sep 17 00:00:00 2001 From: TOUFIKI Zakarya Date: Thu, 2 Nov 2023 17:34:03 +0100 Subject: [PATCH 1/2] fix async class and secret field --- AzureActiveDirectory/azure_ad/base.py | 21 +++++++++++++++++++-- AzureActiveDirectory/tests/test_actions.py | 1 - 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AzureActiveDirectory/azure_ad/base.py b/AzureActiveDirectory/azure_ad/base.py index 26f1fadf2..d9c7fad96 100644 --- a/AzureActiveDirectory/azure_ad/base.py +++ b/AzureActiveDirectory/azure_ad/base.py @@ -8,11 +8,15 @@ from sekoia_automation.action import Action from sekoia_automation.module import Module +import sentry_sdk +from traceback import format_exc +import asyncio + class AzureADConfiguration(BaseModel): tenant_id: str = Field(..., description="ID of the Azure AD tenant") username: str = Field(..., description="") - password: str = Field(..., description="") + password: str = Field(secret=True, description="") client_id: str = Field( ..., description="Client ID. An application needs to be created in the Azure Portal and assigned relevent permissions. Its Client ID should then be used in this configuration.", # noqa: E501 @@ -27,7 +31,20 @@ class AzureADModule(Module): configuration: AzureADConfiguration -class MicrosoftGraphAction(Action): +class AsyncAction(Action): + def execute(self) -> None: + try: + self._ensure_data_path_set() + self.set_task_as_running() + self._results = asyncio.run(self.run(self.arguments)) + except Exception: + self.error(f"An unexpected error occured: {format_exc()}") + sentry_sdk.capture_exception() + + self.send_results() + + +class MicrosoftGraphAction(AsyncAction): module: AzureADModule @cached_property diff --git a/AzureActiveDirectory/tests/test_actions.py b/AzureActiveDirectory/tests/test_actions.py index 8e4d03d7e..90b6cc358 100644 --- a/AzureActiveDirectory/tests/test_actions.py +++ b/AzureActiveDirectory/tests/test_actions.py @@ -5,7 +5,6 @@ from azure_ad.delete_app import DeleteApplicationAction from unittest.mock import AsyncMock, patch -import asyncio import pytest import requests import json From 02b36e724bd040d6fd459674d107471ab0ddb052 Mon Sep 17 00:00:00 2001 From: TOUFIKI Zakarya Date: Thu, 2 Nov 2023 17:36:03 +0100 Subject: [PATCH 2/2] Change version --- AzureActiveDirectory/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AzureActiveDirectory/manifest.json b/AzureActiveDirectory/manifest.json index b0112bc01..5dfb269df 100644 --- a/AzureActiveDirectory/manifest.json +++ b/AzureActiveDirectory/manifest.json @@ -43,5 +43,5 @@ "name": "Azure Active Directory", "uuid": "3abf7928-65ef-4a5f-ba3e-5fbe56123d0c", "slug": "azure-ad", - "version": "2.5.1" + "version": "2.5.2" } \ No newline at end of file