Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Up to standards ✅🟢 Issues
|
earbona23
left a comment
There was a problem hiding this comment.
Read this against main (2d659e8). The route you took is the one that works, and it closes the concern I raised in #2803 rather than working around it.
One file is enough, and that is because of return $null. In #2803 I noted that the four tests encode isActive -eq $false as a pass themselves, so a change to the shared function could not move a verdict — unless the function returns $null. That is the exception, and it is the one you used. All four tests guard it first, before the line that would re-encode the pass:
# Test.MT.1029.ps1:31-33, identical in 1030, 1031 and 1032
if ($null -eq $check) { return $null }
# Passed when the PIM alert is not active or has no affected items after filtering.
return ($check.isActive -eq $false -or $check.numberOfAffectedItems -eq '0')So the four .ps1 files genuinely do not need to change. Nobody should re-raise that.
The fixture risk is closed. New-PimAlert now takes LastScannedDateTime with a scanned default, which is what keeps the existing cases from all turning into "never scanned" the moment the function starts reading that field.
The new pass message breaks nothing else. Your checklist leaves "unit tests pass locally" unticked, so here is that part measured on main. The old string All privileged role assignments are managed by PIM. Well done! occurs in 6 files:
| file | occurrences | what it is |
|---|---|---|
powershell/internal/checks/maester/entra/Test-MtPimAlertsExists.ps1 |
1 | the source line this PR changes |
powershell/tests/functions/Test-MtPimAlertsExists.Tests.ps1 |
1 | the only assertion — already updated here |
report/src/lib/testResults.ts |
2 | committed sample report data |
report/src/lib/testResultsLegacy.ts |
2 | committed sample report data |
build/aitools/test-metadata/test-results.json |
1 | committed sample report data |
website/public/demo/report.html |
1 | demo report |
The two golden fixtures that a grep for managed by PIM turns up — powershell/tests/fixtures/golden/shipped-2x/maester-config.json and powershell/tests/fixtures/golden/tags-and-blocks.json — contain 0 occurrences of the pass message; their match is MT.1031's own title ("Privileged role on Control Plane are managed by PIM only"). And Compare-MtTestResult.Tests.ps1, the only suite that reads testResultsLegacy.ts, diffs two committed files that this PR does not touch. So no assertion outside the one you edited depends on that string.
Two observations, neither a request to widen this PR.
A stale scan still passes. The guard is $lastScanUtc.Year -le 1, so a tenant whose last PIM scan was eight months ago keeps reading as a pass. What changes is that the date is now printed in the result, which turns a silent state into a visible one — that is what would make a follow-up measurable, and it is a better place to stop than guessing at a staleness threshold here.
The skip returns before Add-MtTestResultDetail -Description $testDescription, so a skipped result carries the custom reason without the Security Impact / Mitigation steps block. That is the same shape as the existing catch two dozen lines down, so it is consistent with the function as it stands.
On the red check: of the 15 checks here the only failure is build-validation (ubuntu-latest), which is the one leg that runs with PESTER_COVERAGE and therefore the only one running the OS-independent tests. It is failing the same way on all eight of my open PRs; #2795 and #2797 are what clear it. Not yours.
|
Thanks for the review. Ran the four tests with this PR on a lab tenant (head
The three passes now read, for example, "Well done. No role assignment in scope is affected by the PIM alert Roles are being assigned outside of Privileged Identity Management (last scan: 2026-11-13 01:20 UTC)." instead of the shared "All privileged role assignments are managed by PIM. Well done!". The never-scanned path can no longer be reproduced on this tenant, since its alerts have been scanned; the new unit tests cover it with the date as a string and as a Agreed on both observations. A staleness threshold would be a separate decision, and the printed date now gives a basis for it. |
|
Thank you for running it. The blast radius in your table is exactly the expected one: MT.1029 unchanged in verdict and text, and the change confined to the three pass messages. One thing worth stating for whoever reviews after me: your tenant has scanned its alerts, so the branch this PR adds — inactive and never scanned — cannot be exercised there, and you say so plainly. That leaves the four new unit cases as the only evidence for the path being introduced, which is where review attention should go rather than at the tenant run. They cover the string form, the |
earbona23
left a comment
There was a problem hiding this comment.
Approving. I reviewed this on 13 November and closed with "two observations, neither a request to widen this PR"; a comment was all I could leave then. Re-verified against today's main first, since it has moved since.
- Merges cleanly with
main—merge-treereports no conflict. - 12/12 on
Test-MtPimAlertsExists.Tests.ps1, Pester 5.7.1 (CI's pinned version; I print it now after a Pester 6 default caught me out on another PR today). - The control discriminates. Reverting only
Test-MtPimAlertsExists.ps1tomainand keeping your tests: 8 passed, 4 failed:
[-] returns zero affected items for an inactive alert
[-] skips an inactive alert that PIM has never scanned
[-] skips an inactive alert whose scan date is the minimum DateTime value
[-] evaluates an inactive alert without a scan date as before
The fourth is the one I want to point at: it pins that an inactive alert without a scan date still behaves as it did before. A new guard like this usually comes with cases for the new path only, and then nothing notices when the old path moves too. Asserting the unchanged half is what makes this safe to merge rather than merely plausible.
I had to run that control twice — my first reading reported four fewer tests executed rather than four failing, which was an artefact of how I was collecting the counts, not of your suite. The numbers above are from a clean run reproduced twice, counting per test.
My two earlier observations stand as observations:
- A stale scan still passes, because the guard is
$lastScanUtc.Year -le 1. What this PR changes is that the date is now in the result, so the state is visible instead of silent — which is the right place to stop rather than inventing a staleness threshold here. - The skip returns before
Add-MtTestResultDetail -Description $testDescription, so a skipped row carries the reason without the Security Impact block. Same shape as the existingcatchfurther down, so it is consistent with the function as it stands.
On the red check: build-validation (ubuntu-latest) is failing on main itself and every open PR inherits it — #2795 and #2797 are what clear it. Not caused by this change.
📑 Description
Test-MtPimAlertsExiststreats an inactive alert as a pass. PIM also reports an alert it has never scanned as inactive, withlastScannedDateTimeset to0001-01-01, so MT.1029–MT.1032 passed on a tenant where PIM had not scanned anything yet (details in #2803).$null(not evaluated) when the function does, so they are unchanged. An active alert is evaluated as before, and so is an alert withoutlastScannedDateTime.New-PimAlerttakes aLastScannedDateTimeparameter, set to a scanned date by default. New unit tests cover a never-scanned alert given as a string and as aDateTime, an active alert whatever its scan date, and an alert without a scan date.Dismissed alerts are not changed by this PR: the skip only applies to an alert that has never been scanned.
Closes #2803
✅ Checks
/powershell/tests/pester.ps1locally.ℹ️ Additional Information
On a tenant where PIM has not scanned the alerts yet, MT.1029–MT.1032 now report Skipped instead of Passed. The pass message changes for all four tests.
Local run of
./powershell/tests/pester.ps1on Windows: 8,759 of 8,760 tests pass. The only failure is the missing byte order mark inpowershell/tests/functions/Invoke-MtPackGitHubRequest.Tests.ps1, already onmainand fixed by #2795.Summary by CodeRabbit
Bug Fixes
Documentation