Skip to content

CISA PIM tests fail when the PIM API rejects the tenant license #2363

Open

Description

@nathanmcnulty

Follow-up to #2255 and #2260.

Six CISA controls read PIM endpoints directly once the tenant appears to have Entra ID P2 or Governance:

Control Function Endpoint
CISA.MS.AAD.7.4 Test-MtCisaPermanentRoleAssignment roleManagement/directory/roleAssignmentSchedules
CISA.MS.AAD.7.5 Test-MtCisaUnmanagedRoleAssignment roleManagement/directory/roleAssignmentSchedules
CISA.MS.AAD.7.6 Test-MtCisaRequireActivationApproval policies/roleManagementPolicyAssignments
CISA.MS.AAD.7.7 Test-MtCisaAssignmentNotification policies/roleManagementPolicyAssignments
CISA.MS.AAD.7.8, 7.9 Test-MtCisaActivationNotification policies/roleManagementPolicyAssignments

#2255 showed that subscribedSkus can list a P2 plan while the PIM API still rejects the tenant with 400 AadPremiumLicenseRequired. In a tenant without P2, both endpoints above return that error. #2260 handled it in Get-MtRoleMember, but these functions call the endpoints themselves.

What happens in 2.3.0, measured with the Graph SDK against a local server that returns this 400:

  • Run under Pester, as Invoke-Maester does, the five functions fail with the Graph error instead of being skipped.
  • Called directly from a script, the error is printed and the function still returns a verdict: $true for the two role-assignment checks (7.4, 7.5) and $false for the three policy checks.

The 3.0 rewrite in #2334 keeps the same calls with no handling for this error, and its License gate reads the same subscribedSkus service plans.

Suggested fix: on AadPremiumLicenseRequired, skip with NotLicensedEntraIDP2OrGovernance, the reason these tests already use when the license check finds no P2. Other errors would still be thrown.

I have this fix with tests for the current layout and am happy to open a PR if you'd like one. Because of the contribution pause, I plan to wait until 3.0 is on main and then target the native test files.

Activity

  1. added
    bug
    on Oct 14, 2026
  2. added
    status: accepted
    suite: cisa
    and removed on Oct 23, 2026
  3. JeremyFinney-lgtm commented on Nov 10, 2026

    @JeremyFinney-lgtm
    Contributor

    Implemented and pushed in #2756, commit 6e6d1b1d7.

    All six PIM checks, CISA.MS.AAD.7.4–7.9, now stop and skip with NotLicensedEntraIDP2OrGovernance when the PIM API specifically returns AadPremiumLicenseRequired, even if subscribed service plans report a qualifying licence. Other API errors are rethrown, not classified as licence skips.

    The fix does not fall back to incomplete non-PIM data or change the SCuBA compliance conditions. A licence rejection produces no compliance verdict, and session caching remains intact.

    Regression coverage includes all six checks: licence skips, terminating-error handling, permission/server errors, unchanged compliant/noncompliant verdicts, and native-engine Skipped versus Error outcomes. The targeted Pester selection passed 137 tests, with 92 additional analyzer/retired-check validations passing.

    Pending review and merge; no live-tenant validation performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugproduct: entrastatus: acceptedsuite: cisa

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions