feat(m365): add Entra Conditional Access group management restriction#11342
feat(m365): add Entra Conditional Access group management restriction#11342SAMurai-16 wants to merge 2 commits into
Conversation
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new M365 Entra check to ensure groups referenced by enabled/report-only Conditional Access policies are protected (management-restricted or role-assignable), and extends group collection to fetch the required Graph properties.
Changes:
- Introduces
entra_conditional_access_policy_groups_management_restrictedcheck implementation + metadata. - Updates Entra group retrieval to
$selectrole-assignable and management-restricted properties and handle pagination. - Adds unit tests covering pass/fail scenarios for protected, unprotected, and unresolved group references.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
prowler/providers/m365/services/entra/entra_service.py |
Fetches additional group fields (isAssignableToRole, isManagementRestricted) and paginates groups results. |
prowler/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/entra_conditional_access_policy_groups_management_restricted.py |
New check logic to evaluate Conditional Access group references. |
prowler/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/entra_conditional_access_policy_groups_management_restricted.metadata.json |
Metadata for the new check (description, risk, remediation, URLs). |
tests/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/entra_conditional_access_policy_groups_management_restricted_test.py |
New tests for the check behavior. |
tests/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/__init__.py |
Adds package marker for tests directory. |
prowler/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/__init__.py |
Adds package marker for check directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| query_parameters = ( | ||
| GroupsRequestBuilder.GroupsRequestBuilderGetQueryParameters( | ||
| select=[ | ||
| "id", | ||
| "displayName", | ||
| "groupTypes", | ||
| "membershipRule", | ||
| "isAssignableToRole", | ||
| "isManagementRestricted", | ||
| ], | ||
| ) | ||
| ) |
There was a problem hiding this comment.
I verified against the installed msgraph-sdk==1.55.0:
module has GroupsRequestBuilderGetQueryParameters: False class has GroupsRequestBuilderGetQueryParameters: True
| def test_no_enabled_or_report_only_policy_references_groups(self): | ||
| entra_client = mock.MagicMock | ||
| entra_client.audited_tenant = "audited_tenant" | ||
| entra_client.audited_domain = DOMAIN | ||
| entra_client.groups = [] | ||
| entra_client.conditional_access_policies = { | ||
| "policy-1": _make_policy(state=ConditionalAccessPolicyState.DISABLED) | ||
| } |
| entra_client = mock.MagicMock | ||
| entra_client.audited_tenant = "audited_tenant" | ||
| entra_client.audited_domain = DOMAIN | ||
| entra_client.groups = [] | ||
| entra_client.conditional_access_policies = { | ||
| "policy-1": _make_policy(state=ConditionalAccessPolicyState.DISABLED) | ||
| } |
| @@ -0,0 +1 @@ | |||
|
|
|||
| name: str | ||
| groupTypes: List[str] | ||
| membershipRule: Optional[str] | ||
| is_assignable_to_role: bool = False | ||
| is_management_restricted: bool = False |
| ) | ||
| or False, | ||
| is_management_restricted=getattr( | ||
| group, "is_management_restricted", False | ||
| ) | ||
| or False, |
|
@HugoPBrito Please review and suggest changes if needed |
Context
Adds a Microsoft 365 Entra check for Conditional Access policies that reference security groups in
includeGroupsorexcludeGroups.Groups used by Conditional Access policies are security-sensitive because changing group membership can affect who is included in, or excluded from, access controls. This check helps detect groups that are not protected by Restricted Management Administrative Units or role-assignable group controls.
Fix #11060
Description
This PR adds
entra_conditional_access_policy_groups_management_restricted.The check evaluates enabled and report-only Conditional Access policies, collects referenced group IDs from
conditions.users.includeGroupsandconditions.users.excludeGroups, and verifies each resolved group has at least one of:isManagementRestricted = trueisAssignableToRole = trueThe check fails when a referenced group has both values set to false, and reports unresolved group IDs separately as stale Conditional Access references.
Changes included:
isAssignableToRoleandisManagementRestricted.No new provider permissions are required.
Steps to review
prowler/providers/m365/services/entra/entra_service.py.prowler/providers/m365/services/entra/entra_conditional_access_policy_groups_management_restricted/.SDK/CLI
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.