Skip to content

Commit

Permalink
Merge pull request #462 from SEKOIA-IO/Refactor/Azure_ad
Browse files Browse the repository at this point in the history
fix async class and secret field
  • Loading branch information
squioc authored Nov 3, 2023
2 parents 2b919cc + 02b36e7 commit c4737f2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
21 changes: 19 additions & 2 deletions AzureActiveDirectory/azure_ad/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion AzureActiveDirectory/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 0 additions & 1 deletion AzureActiveDirectory/tests/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4737f2

Please sign in to comment.