diff --git a/Packs/ApiModules/Scripts/MicrosoftApiModule/MicrosoftApiModule.py b/Packs/ApiModules/Scripts/MicrosoftApiModule/MicrosoftApiModule.py index 2ee554bd4834..7eddf51d02e5 100644 --- a/Packs/ApiModules/Scripts/MicrosoftApiModule/MicrosoftApiModule.py +++ b/Packs/ApiModules/Scripts/MicrosoftApiModule/MicrosoftApiModule.py @@ -145,6 +145,62 @@ class Resources: 'gcc-high': 'https://login.microsoftonline.us', } +MICROSOFT_365_DEFENDER_TYPE = { + "Worldwide": "com", + "US Geo Proximity": "geo-us", + "EU Geo Proximity": "geo-eu", + "UK Geo Proximity": "geo-uk", + "AU Geo Proximity": "geo-au", + "SWA Geo Proximity": "geo-swa", + "INA Geo Proximity": "geo-ina", + "US GCC": "gcc", + "US GCC-High": "gcc-high", + "DoD": "dod", +} + +# https://learn.microsoft.com/en-us/defender-endpoint/api/exposed-apis-list +# https://learn.microsoft.com/en-us/defender-xdr/usgov?view=o365-worldwide +MICROSOFT_365_DEFENDER_API_ENDPOINTS = { + "com": "https://api.security.microsoft.com", + "geo-us": "https://us.api.security.microsoft.com", + "geo-eu": "https://eu.api.security.microsoft.com", + "geo-uk": "https://uk.api.security.microsoft.com", + "geo-au": "https://au.api.security.microsoft.com", + "geo-swa": "https://swa.api.security.microsoft.com", + "geo-ina": "https://ina.api.security.microsoft.com", + "gcc": "https://api-gcc.security.microsoft.us", + "gcc-high": "https://api-gov.security.microsoft.us", + "dod": "https://api-gov.security.microsoft.us", +} + +# https://learn.microsoft.com/en-us/defender-xdr/usgov?view=o365-worldwide +MICROSOFT_365_DEFENDER_TOKEN_RETRIEVAL_ENDPOINTS = { + 'com': 'https://login.windows.net', + 'geo-us': 'https://login.windows.net', + 'geo-eu': 'https://login.windows.net', + 'geo-uk': 'https://login.windows.net', + "geo-au": 'https://login.windows.net', + "geo-swa": 'https://login.windows.net', + "geo-ina": 'https://login.windows.net', + "gcc": "https://login.microsoftonline.com", + "gcc-high": "https://login.microsoftonline.us", + "dod": "https://login.microsoftonline.us", +} + +MICROSOFT_365_DEFENDER_SCOPES = { + 'com': "https://security.microsoft.com/mtp", + 'geo-us': 'https://security.microsoft.com', + 'geo-eu': 'https://security.microsoft.com', + 'geo-uk': 'https://security.microsoft.com', + "geo-au": 'https://security.microsoft.com', + "geo-swa": 'https://security.microsoft.com', + "geo-ina": 'https://security.microsoft.com', + 'gcc': 'https://security.microsoft.com', + 'gcc-high': 'https://security.microsoft.us', + 'dod': 'https://security.apps.mil', +} + + # Azure Managed Identities MANAGED_IDENTITIES_TOKEN_URL = 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01' MANAGED_IDENTITIES_SYSTEM_ASSIGNED = 'SYSTEM_ASSIGNED' @@ -636,6 +692,17 @@ def get_azure_cloud(params, integration_name): return AZURE_CLOUDS.get(AZURE_CLOUD_NAME_MAPPING.get(azure_cloud_arg), AZURE_WORLDWIDE_CLOUD) # type: ignore[arg-type] +def microsoft_defender_get_base_url(base_url: str, endpoint_type: str) -> str: + if endpoint_type == 'Custom': + if not base_url: + raise DemistoException("Endpoint type is set to 'Custom' but no URL was provided.") + url = base_url + else: + endpoint = MICROSOFT_365_DEFENDER_TYPE.get(endpoint_type, 'com') + url = MICROSOFT_365_DEFENDER_API_ENDPOINTS.get(endpoint, 'https://api.security.microsoft.com') + return url + + class MicrosoftClient(BaseClient): def __init__(self, tenant_id: str = '', auth_id: str = '', @@ -1387,8 +1454,12 @@ def _add_info_headers() -> dict[str, str]: def device_auth_request(self) -> dict: response_json = {} try: + if self.tenant_id: + url = f'{self.azure_ad_endpoint}/{self.tenant_id}/oauth2/v2.0/devicecode' + else: + url = f'{self.azure_ad_endpoint}/organizations/oauth2/v2.0/devicecode' response = requests.post( - url=f'{self.azure_ad_endpoint}/organizations/oauth2/v2.0/devicecode', + url=url, data={ 'client_id': self.client_id, 'scope': self.scope @@ -1396,6 +1467,9 @@ def device_auth_request(self) -> dict: verify=self.verify ) if not response.ok: + if "National Cloud" in self.error_parser(response): + return_error(f'Error in Microsoft authorization. Status: {response.status_code},' + f' The tenant is not supported by GCC-High. body: {self.error_parser(response)}') return_error(f'Error in Microsoft authorization. Status: {response.status_code},' f' body: {self.error_parser(response)}') response_json = response.json() diff --git a/Packs/AzureActiveDirectory/ReleaseNotes/1_3_28.md b/Packs/AzureActiveDirectory/ReleaseNotes/1_3_28.md new file mode 100644 index 000000000000..c37ae8b42336 --- /dev/null +++ b/Packs/AzureActiveDirectory/ReleaseNotes/1_3_28.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Active Directory Identity Protection (Deprecated) + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureActiveDirectory/pack_metadata.json b/Packs/AzureActiveDirectory/pack_metadata.json index 90878d2f2965..c3459b1d4c97 100644 --- a/Packs/AzureActiveDirectory/pack_metadata.json +++ b/Packs/AzureActiveDirectory/pack_metadata.json @@ -3,7 +3,7 @@ "description": "Deprecated. Use Microsoft Graph Identity and Access instead.", "support": "xsoar", "hidden": true, - "currentVersion": "1.3.27", + "currentVersion": "1.3.28", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureCompute/ReleaseNotes/1_2_33.md b/Packs/AzureCompute/ReleaseNotes/1_2_33.md new file mode 100644 index 000000000000..e38a03d19f0e --- /dev/null +++ b/Packs/AzureCompute/ReleaseNotes/1_2_33.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Compute v2 + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureCompute/pack_metadata.json b/Packs/AzureCompute/pack_metadata.json index 7654d3ee38ae..a702ed778baf 100644 --- a/Packs/AzureCompute/pack_metadata.json +++ b/Packs/AzureCompute/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Compute", "description": "Create and Manage Azure Virtual Machines", "support": "xsoar", - "currentVersion": "1.2.32", + "currentVersion": "1.2.33", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureDataExplorer/ReleaseNotes/1_3_7.md b/Packs/AzureDataExplorer/ReleaseNotes/1_3_7.md new file mode 100644 index 000000000000..96c758c9177e --- /dev/null +++ b/Packs/AzureDataExplorer/ReleaseNotes/1_3_7.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Data Explorer + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureDataExplorer/pack_metadata.json b/Packs/AzureDataExplorer/pack_metadata.json index f1e0ed77a32f..d2ff00165aeb 100644 --- a/Packs/AzureDataExplorer/pack_metadata.json +++ b/Packs/AzureDataExplorer/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Data Explorer", "description": "Use Azure Data Explorer integration to collect and analyze data inside clusters of Azure Data Explorer and manage search queries.", "support": "xsoar", - "currentVersion": "1.3.6", + "currentVersion": "1.3.7", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureDevOps/ReleaseNotes/1_4_7.md b/Packs/AzureDevOps/ReleaseNotes/1_4_7.md new file mode 100644 index 000000000000..89ead3fefefb --- /dev/null +++ b/Packs/AzureDevOps/ReleaseNotes/1_4_7.md @@ -0,0 +1,5 @@ +#### Integrations + +##### AzureDevOps + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureDevOps/pack_metadata.json b/Packs/AzureDevOps/pack_metadata.json index f6fab062dc99..b99ea8c7e7c6 100644 --- a/Packs/AzureDevOps/pack_metadata.json +++ b/Packs/AzureDevOps/pack_metadata.json @@ -2,7 +2,7 @@ "name": "AzureDevOps", "description": "Create and manage Git repositories in Azure DevOps Services.", "support": "xsoar", - "currentVersion": "1.4.6", + "currentVersion": "1.4.7", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureFirewall/ReleaseNotes/1_2_0.md b/Packs/AzureFirewall/ReleaseNotes/1_2_0.md new file mode 100644 index 000000000000..668baa6c5db7 --- /dev/null +++ b/Packs/AzureFirewall/ReleaseNotes/1_2_0.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Firewall + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureFirewall/pack_metadata.json b/Packs/AzureFirewall/pack_metadata.json index cf9392e53766..c774601d646a 100644 --- a/Packs/AzureFirewall/pack_metadata.json +++ b/Packs/AzureFirewall/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Firewall", "description": "Azure Firewall is a cloud-native and intelligent network firewall security service that provides breed threat protection for cloud workloads running in Azure. It's a fully stateful firewall as a service, with built-in high availability and unrestricted cloud scalability. This pack contains an integration with a main goal to manage Azure Firewall security service, and normalization rules for ingesting and modeling Azure Firewall Resource logs.", "support": "xsoar", - "currentVersion": "1.1.46", + "currentVersion": "1.2.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureKeyVault/ReleaseNotes/1_1_50.md b/Packs/AzureKeyVault/ReleaseNotes/1_1_50.md new file mode 100644 index 000000000000..f5433b59780b --- /dev/null +++ b/Packs/AzureKeyVault/ReleaseNotes/1_1_50.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Key Vault + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureKeyVault/pack_metadata.json b/Packs/AzureKeyVault/pack_metadata.json index f7e890024f5c..635537e3e341 100644 --- a/Packs/AzureKeyVault/pack_metadata.json +++ b/Packs/AzureKeyVault/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Key Vault", "description": "Use Key Vault to safeguard and manage cryptographic keys and secrets used by cloud applications and services.", "support": "xsoar", - "currentVersion": "1.1.49", + "currentVersion": "1.1.50", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureKubernetesServices/ReleaseNotes/1_2_5.md b/Packs/AzureKubernetesServices/ReleaseNotes/1_2_5.md new file mode 100644 index 000000000000..9a05a4cc1683 --- /dev/null +++ b/Packs/AzureKubernetesServices/ReleaseNotes/1_2_5.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Kubernetes Services + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureKubernetesServices/pack_metadata.json b/Packs/AzureKubernetesServices/pack_metadata.json index 05e13be2f011..826d05b6a37a 100644 --- a/Packs/AzureKubernetesServices/pack_metadata.json +++ b/Packs/AzureKubernetesServices/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Kubernetes Services", "description": "Deploy and manage containerized applications with a fully managed Kubernetes service.", "support": "xsoar", - "currentVersion": "1.2.4", + "currentVersion": "1.2.5", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureLogAnalytics/ReleaseNotes/1_2_0.md b/Packs/AzureLogAnalytics/ReleaseNotes/1_2_0.md new file mode 100644 index 000000000000..79aa51dcb399 --- /dev/null +++ b/Packs/AzureLogAnalytics/ReleaseNotes/1_2_0.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Log Analytics + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureLogAnalytics/pack_metadata.json b/Packs/AzureLogAnalytics/pack_metadata.json index 26bcd7e1793f..c9fb3630fd33 100644 --- a/Packs/AzureLogAnalytics/pack_metadata.json +++ b/Packs/AzureLogAnalytics/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Log Analytics", "description": "Log Analytics is a service that helps you collect and analyze data generated by resources in your cloud and on-premises environments.", "support": "xsoar", - "currentVersion": "1.1.43", + "currentVersion": "1.2.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureNetworkSecurityGroups/ReleaseNotes/1_2_37.md b/Packs/AzureNetworkSecurityGroups/ReleaseNotes/1_2_37.md new file mode 100644 index 000000000000..3007302ed954 --- /dev/null +++ b/Packs/AzureNetworkSecurityGroups/ReleaseNotes/1_2_37.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Network Security Groups + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureNetworkSecurityGroups/pack_metadata.json b/Packs/AzureNetworkSecurityGroups/pack_metadata.json index 0f0e741c4a47..ebafab70afce 100644 --- a/Packs/AzureNetworkSecurityGroups/pack_metadata.json +++ b/Packs/AzureNetworkSecurityGroups/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Network Security Groups", "description": "Azure Network Security Groups are used to filter network traffic to and from Azure resources in an Azure virtual network", "support": "xsoar", - "currentVersion": "1.2.36", + "currentVersion": "1.2.37", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureResourceGraph/ReleaseNotes/1_0_6.md b/Packs/AzureResourceGraph/ReleaseNotes/1_0_6.md new file mode 100644 index 000000000000..dec0808fbad5 --- /dev/null +++ b/Packs/AzureResourceGraph/ReleaseNotes/1_0_6.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Resource Graph + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureResourceGraph/pack_metadata.json b/Packs/AzureResourceGraph/pack_metadata.json index 534e88e18d8f..e4796f02cfdb 100644 --- a/Packs/AzureResourceGraph/pack_metadata.json +++ b/Packs/AzureResourceGraph/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Resource Graph", "description": "Azure Resource Graph is an Azure service designed to extend Azure Resource Management by providing efficient and performant resource exploration with the ability to query at scale across a given set of resources. This pack is primarily used to allow for executing Azure Resource Graph queries.", "support": "xsoar", - "currentVersion": "1.0.5", + "currentVersion": "1.0.6", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureRiskyUsers/ReleaseNotes/1_2_0.md b/Packs/AzureRiskyUsers/ReleaseNotes/1_2_0.md new file mode 100644 index 000000000000..f19c22d4995a --- /dev/null +++ b/Packs/AzureRiskyUsers/ReleaseNotes/1_2_0.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Risky Users + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureRiskyUsers/pack_metadata.json b/Packs/AzureRiskyUsers/pack_metadata.json index 11f4ff565cd2..97593089de0e 100644 --- a/Packs/AzureRiskyUsers/pack_metadata.json +++ b/Packs/AzureRiskyUsers/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Risky Users", "description": "Azure Risky Users provides access to all at-risk users and risk detections in Azure AD environment.", "support": "xsoar", - "currentVersion": "1.1.42", + "currentVersion": "1.2.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureSQLManagement/ReleaseNotes/1_2_5.md b/Packs/AzureSQLManagement/ReleaseNotes/1_2_5.md new file mode 100644 index 000000000000..8810fe30c52d --- /dev/null +++ b/Packs/AzureSQLManagement/ReleaseNotes/1_2_5.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure SQL Management + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureSQLManagement/pack_metadata.json b/Packs/AzureSQLManagement/pack_metadata.json index 8d17ed9d6e6a..5d1a123db2ab 100644 --- a/Packs/AzureSQLManagement/pack_metadata.json +++ b/Packs/AzureSQLManagement/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure SQL Management", "description": "Microsoft Azure SQL Database is a managed cloud database provided as part of Microsoft Azure", "support": "xsoar", - "currentVersion": "1.2.4", + "currentVersion": "1.2.5", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureSecurityCenter/ReleaseNotes/2_1_0.md b/Packs/AzureSecurityCenter/ReleaseNotes/2_1_0.md new file mode 100644 index 000000000000..2b5aebbb4a10 --- /dev/null +++ b/Packs/AzureSecurityCenter/ReleaseNotes/2_1_0.md @@ -0,0 +1,9 @@ +#### Integrations + +##### Microsoft Defender for Cloud Event Collector + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. + +##### Microsoft Defender for Cloud + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureSecurityCenter/pack_metadata.json b/Packs/AzureSecurityCenter/pack_metadata.json index dbe9509cdc0a..d4a7f94524f4 100644 --- a/Packs/AzureSecurityCenter/pack_metadata.json +++ b/Packs/AzureSecurityCenter/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Microsoft Defender for Cloud", "description": "Unified security management and advanced threat protection across hybrid cloud workloads.", "support": "xsoar", - "currentVersion": "2.0.35", + "currentVersion": "2.1.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureSentinel/ReleaseNotes/1_6_0.md b/Packs/AzureSentinel/ReleaseNotes/1_6_0.md new file mode 100644 index 000000000000..ee1eec46af3a --- /dev/null +++ b/Packs/AzureSentinel/ReleaseNotes/1_6_0.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Microsoft Sentinel + +Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureSentinel/pack_metadata.json b/Packs/AzureSentinel/pack_metadata.json index 5bc1dfe62d3e..3f4e0b0d2276 100644 --- a/Packs/AzureSentinel/pack_metadata.json +++ b/Packs/AzureSentinel/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Microsoft Sentinel", "description": "Microsoft Sentinel is a cloud-native security information and event manager (SIEM) platform that uses built-in AI to help analyze large volumes of data across an enterprise.", "support": "xsoar", - "currentVersion": "1.5.57", + "currentVersion": "1.6.0", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/AzureStorage/ReleaseNotes/1_2_32.md b/Packs/AzureStorage/ReleaseNotes/1_2_32.md new file mode 100644 index 000000000000..03fb13c5e8b9 --- /dev/null +++ b/Packs/AzureStorage/ReleaseNotes/1_2_32.md @@ -0,0 +1,5 @@ +#### Integrations + +##### Azure Storage Management + +- Added support for National Cloud in Microsoft 365 Defender, implemented in the Microsoft API Module. diff --git a/Packs/AzureStorage/pack_metadata.json b/Packs/AzureStorage/pack_metadata.json index 422abe802b5b..73575279aaaa 100644 --- a/Packs/AzureStorage/pack_metadata.json +++ b/Packs/AzureStorage/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Azure Storage Management", "description": "Deploy and manage storage accounts and blob service properties.", "support": "xsoar", - "currentVersion": "1.2.31", + "currentVersion": "1.2.32", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "", diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.py b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.py index 9178ff29d676..0b317d4aebd2 100644 --- a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.py +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.py @@ -22,7 +22,9 @@ class Client: def __init__(self, app_id: str, verify: bool, proxy: bool, base_url: str = BASE_URL, tenant_id: str = None, enc_key: str = None, client_credentials: bool = False, certificate_thumbprint: Optional[str] = None, private_key: Optional[str] = None, - managed_identities_client_id: Optional[str] = None): + managed_identities_client_id: Optional[str] = None, + endpoint: str = 'com', + azure_cloud: AzureCloud = AZURE_WORLDWIDE_CLOUD): if app_id and '@' in app_id: app_id, refresh_token = app_id.split('@') integration_context = get_integration_context() @@ -35,7 +37,7 @@ def __init__(self, app_id: str, verify: bool, proxy: bool, base_url: str = BASE_ verify=verify, proxy=proxy, ok_codes=(200, 201, 202, 204), - scope='offline_access https://security.microsoft.com/mtp/.default', + scope=f'offline_access {MICROSOFT_365_DEFENDER_SCOPES.get(endpoint)}/.default', self_deployed=True, # We always set the self_deployed key as True because when not using a self # deployed machine, the DEVICE_CODE flow should behave somewhat like a self deployed # flow and most of the same arguments should be set, as we're !not! using OProxy. @@ -44,8 +46,9 @@ def __init__(self, app_id: str, verify: bool, proxy: bool, base_url: str = BASE_ grant_type=CLIENT_CREDENTIALS if client_credentials else DEVICE_CODE, # used for device code flow - resource='https://api.security.microsoft.com' if not client_credentials else None, - token_retrieval_url='https://login.windows.net/organizations/oauth2/v2.0/token' if not client_credentials else None, + resource=MICROSOFT_365_DEFENDER_API_ENDPOINTS.get(endpoint) if not client_credentials else None, + token_retrieval_url=f'{MICROSOFT_365_DEFENDER_TOKEN_RETRIEVAL_ENDPOINTS.get(endpoint)}' + f'/organizations/oauth2/v2.0/token' if not client_credentials else None, # used for client credentials flow tenant_id=tenant_id, enc_key=enc_key, @@ -53,6 +56,8 @@ def __init__(self, app_id: str, verify: bool, proxy: bool, base_url: str = BASE_ private_key=private_key, managed_identities_client_id=managed_identities_client_id, managed_identities_resource_uri=Resources.security, + endpoint=endpoint, + azure_cloud=azure_cloud, command_prefix="microsoft-365-defender", ) self.ms_client = MicrosoftClient(**client_args) # type: ignore @@ -600,6 +605,9 @@ def main() -> None: proxy = params.get('proxy', False) app_id = params.get('creds_client_id', {}).get('password', '') or params.get('app_id') or params.get('_app_id') base_url = params.get('base_url') + endpoint_type = params.get('endpoint_type', 'Worldwide') + endpoint = MICROSOFT_365_DEFENDER_TYPE.get(endpoint_type, 'com') + base_url = microsoft_defender_get_base_url(base_url, endpoint_type) tenant_id = params.get('creds_tenant_id', {}).get('password', '') or params.get('tenant_id') or params.get('_tenant_id') client_credentials = params.get('client_credentials', False) @@ -623,6 +631,7 @@ def main() -> None: if not managed_identities_client_id and not app_id: raise Exception('Application ID must be provided.') + azure_cloud = AZURE_CLOUDS.get(endpoint) client = Client( app_id=app_id, verify=verify_certificate, @@ -633,7 +642,9 @@ def main() -> None: client_credentials=client_credentials, certificate_thumbprint=certificate_thumbprint, private_key=private_key, - managed_identities_client_id=managed_identities_client_id + managed_identities_client_id=managed_identities_client_id, + endpoint=endpoint, + azure_cloud=azure_cloud, ) if demisto.command() == 'test-module': # This is the call made when pressing the integration Test button. diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.yml b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.yml index 52aaddfefe49..bcc42136f935 100644 --- a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.yml +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender.yml @@ -7,13 +7,31 @@ commonfields: version: -1 configuration: - additionalinfo: |- - The United States: api-us.security.microsoft.com - Europe: api-eu.security.microsoft.com - The United Kingdom: api-uk.security.microsoft.co - defaultvalue: https://api.security.microsoft.com - display: Endpoint URI + The endpoint type. When selecting the Custom option, the Server URL parameter must be filled. + defaultvalue: Worldwide + display: Endpoint Type + name: endpoint_type + required: false + type: 15 + section: Connect + options: + - Worldwide + - US Geo Proximity + - EU Geo Proximity + - UK Geo Proximity + - AU Geo Proximity + - SWA Geo Proximity + - INA Geo Proximity + - US GCC + - US GCC-High + - DoD + - Custom + advanced: true +- additionalinfo: |- + Custom Server URL. Required when Endpoint Type is Custom. + display: Server URL name: base_url - required: true + required: false type: 0 section: Connect - name: creds_client_id diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_description.md b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_description.md index cb3765cf4dee..7c4603998ab7 100644 --- a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_description.md +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_description.md @@ -79,3 +79,11 @@ Follow one of these steps for authentication based on Azure Managed Identities: 3. Select the **Use Azure Managed Identities** checkbox. For more information, see [Managed identities for Azure resources](https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview). + + +### Using National Cloud +Using a national cloud endpoint is supported by setting the *Endpoint Type* parameter to one of the following options: +* US Government GCC Endpoint: `https://api-gcc.security.microsoft.us` +* US Government GCC-High Endpoint: `https://api-gov.security.microsoft.us` +* US Government Department of Defence (DoD) Endpoint: `https://api-gov.security.microsoft.us` +When using **US Government GCC-High Endpoint** with **Device Code** Flow, tenant ID is a required parameter in the instance configuration. diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_test.py b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_test.py index f66ac3083f2f..4c48b2063e38 100644 --- a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_test.py +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/Microsoft365Defender_test.py @@ -185,3 +185,87 @@ def test_test_module_command_with_managed_identities(mocker, requests_mock, clie qs = get_mock.last_request.qs assert qs['resource'] == [Resources.security] assert client_id and qs['client_id'] == [client_id] or 'client_id' not in qs + + +@pytest.mark.parametrize( + 'server_url, expected_endpoint', [ + ('com', 'https://api.security.microsoft.com'), + ('geo-us', 'https://us.api.security.microsoft.com'), + ('geo-eu', 'https://eu.api.security.microsoft.com'), + ('geo-uk', 'https://uk.api.security.microsoft.com'), + ('geo-au', 'https://au.api.security.microsoft.com'), + ('geo-swa', 'https://swa.api.security.microsoft.com'), + ('geo-ina', 'https://ina.api.security.microsoft.com'), + ('gcc', 'https://api-gcc.security.microsoft.us'), + ('gcc-high', 'https://api-gov.security.microsoft.us'), + ('dod', 'https://api-gov.security.microsoft.us'), + ] +) +def test_endpoint_to_api(server_url, expected_endpoint): + """ + Given: + - A dictionary mapping server URLs to Microsoft 365 Defender API endpoints. + When: + - Testing the endpoint lookup for various server URLs. + Then: + - Ensure the returned endpoint matches the expected value for each server URL. + """ + from MicrosoftApiModule import MICROSOFT_365_DEFENDER_API_ENDPOINTS + + assert MICROSOFT_365_DEFENDER_API_ENDPOINTS[server_url] == expected_endpoint + + +@pytest.mark.parametrize( + 'server_url, expected_endpoint', [ + ('com', 'https://login.windows.net'), + ('geo-us', 'https://login.windows.net'), + ('geo-eu', 'https://login.windows.net'), + ('geo-uk', 'https://login.windows.net'), + ('geo-au', 'https://login.windows.net'), + ('geo-swa', 'https://login.windows.net'), + ('geo-ina', 'https://login.windows.net'), + ('gcc', 'https://login.microsoftonline.com'), + ('gcc-high', 'https://login.microsoftonline.us'), + ('dod', 'https://login.microsoftonline.us'), + ] +) +def test_token_retrieval_endpoint(server_url, expected_endpoint): + """ + Given: + - A dictionary mapping server URLs to Microsoft 365 Defender token retrieval endpoints. + When: + - Testing the token retrieval endpoint lookup for various server URLs. + Then: + - Ensure the returned endpoint matches the expected value for each server URL. + """ + from MicrosoftApiModule import MICROSOFT_365_DEFENDER_TOKEN_RETRIEVAL_ENDPOINTS + + assert MICROSOFT_365_DEFENDER_TOKEN_RETRIEVAL_ENDPOINTS[server_url] == expected_endpoint + + +@pytest.mark.parametrize( + 'server_url, expected_scope', [ + ('com', 'https://security.microsoft.com'), + ('geo-us', 'https://security.microsoft.com'), + ('geo-eu', 'https://security.microsoft.com'), + ('geo-uk', 'https://security.microsoft.com'), + ('geo-au', 'https://security.microsoft.com'), + ('geo-swa', 'https://security.microsoft.com'), + ('geo-ina', 'https://security.microsoft.com'), + ('gcc', 'https://security.microsoft.com'), + ('gcc-high', 'https://security.microsoft.us'), + ('dod', 'https://security.apps.mil'), + ] +) +def test_scope_to_api(server_url, expected_scope): + """ + Given: + - A dictionary mapping server URLs to Microsoft 365 Defender scopes. + When: + - Testing the scope lookup for various server URLs. + Then: + - Ensure the returned scope matches the expected value for each server URL. + """ + from MicrosoftApiModule import MICROSOFT_365_DEFENDER_SCOPES + + assert MICROSOFT_365_DEFENDER_SCOPES[server_url] == expected_scope diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/README.md b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/README.md index 88adb6777995..c9180198bc56 100644 --- a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/README.md +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/README.md @@ -24,6 +24,14 @@ In order to use the Cortex XSOAR application, use the default application ID. To use a self-configured Azure application, you need to add a new Azure App Registration in the Azure Portal. For more details, follow [Self Deployed Application - Device Code Flow](https://xsoar.pan.dev/docs/reference/articles/microsoft-integrations---authentication#device-code-flow). +### Using National Cloud +Using a national cloud endpoint is supported by setting the *Endpoint Type* parameter to one of the following options: +* US Government GCC Endpoint: `https://api-gcc.security.microsoft.us` +* US Government GCC-High Endpoint: `https://api-gov.security.microsoft.us` +* US Government Department of Defence (DoD) Endpoint: `https://api-gov.security.microsoft.us` +When using **US Government GCC-High Endpoint** with **Device Code** Flow, tenant ID is a required parameter in the instance configuration. + + #### Required Permissions The required API permissions are for the ***Microsoft Threat Protection*** app. * offline_access - Delegate @@ -51,24 +59,45 @@ Follow these steps for a self-deployed configuration: 2. Search for Microsoft Defender XDR. 3. Click **Add instance** to create and configure a new integration instance. - | **Parameter** | **Description** | **Required** | - | --- | --- | --- | - | Application ID or Client ID | The API key to use to connect. | False | - | Endpoint URI | The United States: api-us.security.microsoft.com
Europe: api-eu.security.microsoft.com
The United Kingdom: api-uk.security.microsoft.co | True | - | Use Client Credentials Authorization Flow | Use a self-deployed Azure application and authenticate using the Client Credentials flow. | False | - | Token or Tenant ID (for Client Credentials mode) | | False | - | Password | | False | - | Certificate Thumbprint | Used for certificate authentication. As appears in the "Certificates & secrets" page of the app. | False | - | Private Key | Used for certificate authentication. The private key of the registered certificate. | False | - | Use Azure Managed Identities | Relevant only if the integration is running on Azure VM. If selected, authenticates based on the value provided for the Azure Managed Identities Client ID field. If no value is provided for the Azure Managed Identities Client ID field, authenticates based on the System Assigned Managed Identity. For additional information, see the Help tab. | False | - | Azure Managed Identities Client ID | The Managed Identities client ID for authentication - relevant only if the integration is running on Azure VM. | False | - | First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days) | | False | - | Fetch incidents timeout | The time limit in seconds for fetch incidents to run. Leave this empty to cancel the timeout limit. | False | - | Number of incidents for each fetch. | Due to API limitations, the maximum is 100. | False | - | Incident type | | False | - | Fetch incidents | | False | - | Trust any certificate (not secure) | | False | - | Use system proxy settings | | False | + +| **Parameter** | **Description** | **Required** | +| --- | --- | --- | +| Application ID or Client ID | The API key to use to connect. | False | +| Endpoint Type | The endpoint type. When selecting the Custom option, the Server URL parameter must be filled. | False | +| Server URL | Custom Server URL. Required when Endpoint Type is Custom. | False | +| Use Client Credentials Authorization Flow | Use a self-deployed Azure application and authenticate using the Client Credentials flow. | False | +| Token or Tenant ID (for Client Credentials mode) | | False | +| Password | | False | +| Certificate Thumbprint | Used for certificate authentication. As appears in the "Certificates & secrets" page of the app. | False | +| Private Key | Used for certificate authentication. The private key of the registered certificate. | False | +| Use Azure Managed Identities | Relevant only if the integration is running on Azure VM. If selected, authenticates based on the value provided for the Azure Managed Identities Client ID field. If no value is provided for the Azure Managed Identities Client ID field, authenticates based on the System Assigned Managed Identity. For additional information, see the Help tab. | False | +| Azure Managed Identities Client ID | The Managed Identities client ID for authentication - relevant only if the integration is running on Azure VM. | False | +| First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days) | | False | +| Fetch incidents timeout | The time limit in seconds for fetch incidents to run. Leave this empty to cancel the timeout limit. | False | +| Number of incidents for each fetch. | Due to API limitations, the maximum is 100. | False | +| Incident type | | False | +| Fetch incidents | | False | +| Trust any certificate (not secure) | | False | +| Use system proxy settings | | False | + + +Endpoint Type Options: + +| Endpoint Type | Description | +|--------|-----------------------------------------------------------------------------------------| +| Worldwide | The publicly accessible Microsoft 365 Defender. | +| US Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the US customers. | +| EU Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the EU customers. | +| UK Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the UK customers. | +| AU Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the AU customers. | +| SWA Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the SWA customers. | +| INA Geo Proximity | Microsoft 365 Defender Geo proximity endpoint for the INA customers. | +| US GCC | Microsoft 365 Defender endpoint for the USA Government Cloud Community (GCC). | +| US GCC-High | Microsoft 365 Defender endpoint for the USA Government Cloud Community High (GCC-High). | +| DoD | Microsoft 365 Defender endpoint for the USA Department of Defense (DoD). | +| Custom | Custom endpoint configuration for Microsoft 365 Defender. | + + 4. Run the !microsoft-365-defender-auth-test command to validate the authentication process. @@ -350,4 +379,4 @@ Details on how to write queries you can find [here](https://docs.microsoft.com/e >### Result of query: AlertInfo: >|Timestamp|AlertId|Title|Category|Severity|ServiceSource|DetectionSource|AttackTechniques| >|---|---|---|---|---|---|---|---| ->| 2021-04-25T10:11:00Z | alertId | eDiscovery search started or exported | InitialAccess | Medium | Microsoft Defender for Office 365 | Microsoft Defender for Office 365 | | +>| 2021-04-25T10:11:00Z | alertId | eDiscovery search started or exported | InitialAccess | Medium | Microsoft Defender for Office 365 | Microsoft Defender for Office 365 | | \ No newline at end of file diff --git a/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/integration-Microsoft365Defender-SecondFix.yml b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/integration-Microsoft365Defender-SecondFix.yml new file mode 100644 index 000000000000..bd6985cd33a0 --- /dev/null +++ b/Packs/Microsoft365Defender/Integrations/Microsoft365Defender/integration-Microsoft365Defender-SecondFix.yml @@ -0,0 +1,2851 @@ +category: Network Security +sectionOrder: +- Connect +- Collect +commonfields: + id: Microsoft 365 Defender - Second Fix + version: -1 +configuration: +- additionalinfo: The endpoint type. When selecting the Custom option, the Server URL parameter must be filled. + defaultvalue: Worldwide + display: Endpoint Type + name: endpoint_type + required: false + type: 15 + section: Connect + options: + - Worldwide + - US Geo Proximity + - EU Geo Proximity + - UK Geo Proximity + - AU Geo Proximity + - SWA Geo Proximity + - INA Geo Proximity + - US GCC + - US GCC-High + - DoD + - Custom + advanced: true +- additionalinfo: Custom Server URL. Required when Endpoint Type is Custom. + display: Server URL + name: base_url + required: false + type: 0 + section: Connect +- name: creds_client_id + type: 9 + displaypassword: ID or Client ID + hiddenusername: true + section: Connect + required: false +- name: creds_tenant_id + type: 9 + displaypassword: Token or Tenant ID + hiddenusername: true + section: Connect + required: false +- additionalinfo: The API key to use to connect. + defaultvalue: 9093c354-630a-47f1-b087-6768eb9427e6 + display: Application ID + name: _app_id + type: 0 + section: Connect + hidden: true + required: false +- additionalinfo: Use a self-deployed Azure application and authenticate using the Client Credentials flow. + display: Use Client Credentials Authorization Flow + name: client_credentials + type: 8 + section: Connect + required: false +- display: Tenant ID (for Client Credentials mode) + name: _tenant_id + type: 0 + section: Connect + hidden: true + required: false +- display: Client Secret (for Client Credentials mode) + hiddenusername: true + name: credentials + type: 9 + section: Connect + displaypassword: Client Secret + required: false +- additionalinfo: Used for certificate authentication. As appears in the "Certificates & secrets" page of the app. + display: Certificate Thumbprint + name: creds_certificate + type: 9 + displaypassword: Private Key + section: Connect + advanced: true + required: false +- additionalinfo: Used for certificate authentication. As appears in the "Certificates & secrets" page of the app. + display: Certificate Thumbprint + name: certificate_thumbprint + type: 4 + section: Connect + advanced: true + hidden: true + required: false +- additionalinfo: Used for certificate authentication. The private key of the registered certificate. + display: Private Key + name: private_key + type: 14 + section: Connect + advanced: true + hidden: true + required: false +- additionalinfo: Relevant only if the integration is running on Azure VM. If selected, authenticates based on the value provided for the Azure Managed Identities Client ID field. If no value is provided for the Azure Managed Identities Client ID field, authenticates based on the System Assigned Managed Identity. For additional information, see the Help tab. + display: Use Azure Managed Identities + name: use_managed_identities + type: 8 + section: Connect + advanced: true + required: false +- additionalinfo: The Managed Identities client ID for authentication - relevant only if the integration is running on Azure VM. + displaypassword: Azure Managed Identities Client ID + name: managed_identities_client_id + hiddenusername: true + type: 9 + section: Connect + advanced: true + required: false +- defaultvalue: 12 hours + display: First fetch timestamp (