From 6e184dae937b26323218d24e77149cbaa4aaf12c Mon Sep 17 00:00:00 2001 From: Hugo Pereira Brito <101209179+HugoPBrito@users.noreply.github.com> Date: Wed, 21 May 2025 12:46:35 +0200 Subject: [PATCH] fix(admincenter): `admincenter_users_admins_reduced_license_footprint` logic (#7779) Co-authored-by: Andoni A. <14891798+andoniaf@users.noreply.github.com> --- prowler/CHANGELOG.md | 1 + .../admincenter_users_admins_reduced_license_footprint.py | 4 ++-- ...admincenter_users_admins_reduced_license_footprint_test.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/prowler/CHANGELOG.md b/prowler/CHANGELOG.md index 75a7f1ec42..965cf81cf5 100644 --- a/prowler/CHANGELOG.md +++ b/prowler/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to the **Prowler SDK** are documented in this file. ### Fixed - Fix `m365_powershell test_credentials` to use sanitized credentials. [(#7761)](https://github.com/prowler-cloud/prowler/pull/7761) +- Fix `admincenter_users_admins_reduced_license_footprint` check logic to pass when admin user has no license. [(#7779)](https://github.com/prowler-cloud/prowler/pull/7779) --- diff --git a/prowler/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint.py b/prowler/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint.py index 7497feb305..e97f42cd80 100644 --- a/prowler/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint.py +++ b/prowler/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint.py @@ -21,7 +21,7 @@ class admincenter_users_admins_reduced_license_footprint(Check): """Execute the check for users with administrative roles and their licenses. This method iterates over all users and checks if those with administrative roles - have an allowed license. If a user has a valid license (AAD_PREMIUM or AAD_PREMIUM_P2), + have an allowed license. If a user has a valid license (AAD_PREMIUM or AAD_PREMIUM_P2) or no license, the check passes; otherwise, it fails. Returns: @@ -45,7 +45,7 @@ class admincenter_users_admins_reduced_license_footprint(Check): resource_name=user.name, resource_id=user.id, ) - report.status = "FAIL" + report.status = "PASS" report.status_extended = f"User {user.name} has administrative roles {admin_roles} and does not have a license." if user.license: diff --git a/tests/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint_test.py b/tests/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint_test.py index 6b93429b3d..a3667af57a 100644 --- a/tests/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint_test.py +++ b/tests/providers/m365/services/admincenter/admincenter_users_admins_reduced_license_footprint/admincenter_users_admins_reduced_license_footprint_test.py @@ -210,7 +210,7 @@ class Test_admincenter_users_admins_reduced_license_footprint: check = admincenter_users_admins_reduced_license_footprint() result = check.execute() assert len(result) == 1 - assert result[0].status == "FAIL" + assert result[0].status == "PASS" assert ( result[0].status_extended == "User User1 has administrative roles Global Administrator and does not have a license."