From a6dd97b6bca614b5f1f93569ba29c2aa08d3236f Mon Sep 17 00:00:00 2001 From: HugoPBrito Date: Mon, 21 Apr 2025 17:54:12 +0200 Subject: [PATCH] feat: pwsh setup and print credentials comprobation --- prowler/providers/m365/m365_provider.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/prowler/providers/m365/m365_provider.py b/prowler/providers/m365/m365_provider.py index f6ca473af4..c9b269e9d7 100644 --- a/prowler/providers/m365/m365_provider.py +++ b/prowler/providers/m365/m365_provider.py @@ -447,8 +447,11 @@ class M365Provider(Provider): f"M365 Region: {Fore.YELLOW}{self.region_config.name}{Style.RESET_ALL}", f"M365 Tenant Domain: {Fore.YELLOW}{self._identity.tenant_domain}{Style.RESET_ALL} M365 Tenant ID: {Fore.YELLOW}{self._identity.tenant_id}{Style.RESET_ALL}", f"M365 Identity Type: {Fore.YELLOW}{self._identity.identity_type}{Style.RESET_ALL} M365 Identity ID: {Fore.YELLOW}{self._identity.identity_id}{Style.RESET_ALL}", - f"M365 User: {Fore.YELLOW}{self.credentials.user}{Style.RESET_ALL}", ] + if self.credentials and self.credentials.user: + report_lines.append( + f"M365 User: {Fore.YELLOW}{self.credentials.user}{Style.RESET_ALL}" + ) report_title = ( f"{Style.BRIGHT}Using the M365 credentials below:{Style.RESET_ALL}" ) @@ -700,11 +703,14 @@ class M365Provider(Provider): logger.info("M365 provider: Connection to MSGraph successful") # Set up PowerShell credentials - M365Provider.setup_powershell( - env_auth, - m365_credentials, - provider_id, - ) + if user and encrypted_password: + M365Provider.setup_powershell( + env_auth, + m365_credentials, + provider_id, + ) + else: + logger.info("M365 provider: PowerShell authentication not required") logger.info("M365 provider: Connection to PowerShell successful")