Repository navigation
Conversation
…ons, one result per detection type A family check with one row per documented sign-in and user riskEventType (plus any undocumented type with open detections). A row fails when a detection of its type is still atRisk or confirmedCompromised and lists them high risk first, so SecOps can review and dismiss or remediate them. Part of #2730. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Entire-Checkpoint: 01M6X8CMR457WNSZ1TZGV4DGSM
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Up to standards ✅🟢 Issues
|
earbona23
left a comment
There was a problem hiding this comment.
Read MT.1273 and MT.1274 together. Three observations, one of which is a loose end I measured on another PR this morning and found two more instances of here.
The shape is the one I have been recommending elsewhere
One instance per detection type with the severity carried on the instance — MT.1273.<riskEventType>, each type's severity set in the instance source — is exactly right for this data, and worth pointing at: I spent this morning arguing for it on #2704, where MT.1262 and MT.1263 are 125 of 161 lines identical and differ only by a risk level and a severity. This PR is the maintainer's own precedent for the alternative, so I will cross-reference it there.
Three more things I checked rather than assumed:
- The gates skip, they do not pass.
$type.Premiumwithout P2 returns$nullwithNotLicensedEntraIDP2, and a 403 returns$nullwithNotAuthorizedwhile anything else rethrows. A premium detection type in a P1 tenant therefore cannot read as "no open detections". - The discovered instance ID is validated against the engine's own grammar before it becomes an instance:
$type -notmatch '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$'and it is dropped. That matters more than it looks —Invoke-MtNativePlan.ps1:330turns one invalid suffix into a singleErrorrow for the whole family, so validating at the source is what stops an unexpectedriskEventTypefrom Microsoft taking out all the other rows. I raised the same point on #2746 aboutTarget.Id; here it is already done. Get-MtSafeMarkdownon the detection name, and the relationship to MT.1260 stated in the guide ("MT.1260 reports the users that are high risk and unremediated; the two complement each other") — which answers the overlap question I came in with.
1. The one thing that degrades quietly is the part nobody would notice
The instance source enumerates documented types from the table, then asks the tenant for any type Microsoft has added since:
try {
$openTypes = @(Get-MtUserRiskDetection | ForEach-Object { [string]$_.riskEventType } | ... )
} catch {
Write-Verbose "MT.1273: could not read open risk detections for undocumented types. $($_.Exception.Message)"
$openTypes = @()
}If that read fails, the documented types still produce their rows, so the check looks healthy — and the only thing lost is the one thing the code exists to catch: an undocumented type with open detections. There is no row for it, nothing in the report says enumeration did not happen, and the evidence is a verbose line nobody runs with.
The failure is also not unlikely: that call is the same read the results use, so a transient throttle or a permission that covers one path and not another lands here first.
It is a thin fix given the shape you already have — the discovery outcome could ride along on Data and each result's detail could end with one line when it failed ("new detection types could not be enumerated this run"), or the family could carry a single extra instance for it. What I would avoid is letting the catch rethrow: a transient failure should not cost all 40-odd rows.
2. -Severity on Add-MtTestResultDetail is dead here, four times in MT.1273 and three in MT.1274
$severity = $Instance.Severity, then Add-MtTestResultDetail -Severity $severity. The engine's own chain at Invoke-MtNativePlan.ps1:467-472 reads:
# Severity: config row (instance, then parent), the instance's, the attribute's, then the helper's.
elseif ($isInstance -and (Get-MtInstanceValue -Instance $Instance -Name 'Severity')) { ... } # :470
elseif ($test.Severity) { ... } # :471
elseif ($detail -and $detail.Severity) { ... } # :472The instance's severity wins at :470, two lines before the helper's value is ever considered, so passing the same figure to the helper cannot change anything.
Harmless here because it is the same value by both routes. I raise it only because I measured the class this morning for #2757: 50 call sites pass -Severity to that helper and all 50 are dead, and in 7 of them the literal passed contradicts what the report shows — MT.1208 asks for High and reports Medium, and six others like it. These seven calls would make 57. I offered on #2757 to write a general test that fails when a native test passes -Severity to the helper, in the shape of TestParameterNames.Tests.ps1; if that lands, this is two files to touch, and better before the pattern is copied from a maintainer's PR.
|
Ran this at
|
Important
Opened during the Maester 3.0 code freeze as a draft, for review after the release.
📑 Description
Adds MT.1273, a family check that reports open Entra ID Protection user risk detections, with one result per detection type (
MT.1273.<riskEventType>). This is the user half of the design in #2730. Workload identities are in a separate PR (MT.1274).A row fails when at least one detection of its type is still
atRiskorconfirmedCompromised(the same open states MT.1260 uses). The row lists those detections with high risk first, then by date, and opens with a count by level. Rows for remediated, dismissed or confirmed-safe detections pass, so the report also shows which signals are clean. The recommendation, aimed at the security operations team: review each detection, then dismiss it if benign, or confirm compromised and remediate, including removing any authentication method the attacker added.Part of #2730.
How it works
riskEventTypevalues documented in What are risk detections?, plus a row for any undocumented type that has open detections, so new Microsoft detections are not droppedidentityProtection/riskDetections(v1.0), two cached reads (riskState eq 'atRisk',riskState eq 'confirmedCompromised') through the newpowershell/internal/services/entra/Get-MtUserRiskDetection.ps1Highfor strong compromise signals (leaked credentials, AitM, password spray, PRT access, verified threat actor IP, suspicious MFA approval, suspicious credential addition, token issuer anomaly, threat intelligence, admin-confirmed compromise);Lowfor anonymous IP and new country;Mediumfor the restLicense = 'AAD_PREMIUM'(the API needs P1 or P2). Premium detection types are skipped withNotLicensedEntraIDP2in tenants without P2, because those tenants only see them asgeneric. That is why MT.1273 joins MT.1024 on the licence-check allow-list inNativeTestLint.Tests.ps1IdentityRiskEvent.Read.All, already a default scope; no new consentDuplicate review
MT.1260 (and the planned MT.1261) report risky users by level from
riskyUsers. This check reports the detections behind that risk, split by signal. The endpoint, granularity and question are different, so it's not a shim. The guide links the two. #2705 (MT.1253) checks the Conditional Access response to risk, not the backlog.Attributes
entra/identity-protection, Arealogging-and-detectionand SeverityMedium(matching MT.1260), ResourceTypeUser(instance type), UserImpactLow, ImplementationCostLow. Mitre T1078.004, T1110.003, T1557, T1098.005, T1114.003, each named in the guide. Controlnist-800-53-r5:IR-4,nist-800-53-r5:AC-2(12). LifecyclePreview.✅ Checks
/powershell/tests/pester.ps1locally.ℹ️ Additional Information
Get-MtTest MT.1273is valid. 11 new unit tests inpowershell/tests/functions/Test-MtEntraUserRiskDetection.Tests.ps1../build/golden/Export-MtGoldenFixture.ps1(one more selected test).🤖 Generated with Claude Code