Skip to content

fix(entra): drop MT.1208's dead severity override - #2757

Open
agnivesh wants to merge 3 commits into
maester365:mainfrom
agnivesh:fix/mt-severity-attribute-mismatch
Open

agnivesh wants to merge 3 commits into
maester365:mainfrom
agnivesh:fix/mt-severity-attribute-mismatch

Conversation

@agnivesh

@agnivesh agnivesh commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • MT.1208's failure path passed -Severity 'High' to Add-MtTestResultDetail, but native tests resolve severity from the [MaesterTest] attribute before that call ever runs, so the override had no effect, every failed run already reported Medium. Removed it so the code doesn't claim a severity the check never reports.

Test plan

  • Parsed and linted the changed file (PSScriptAnalyzer: no findings)
  • Ran ./powershell/tests/pester.ps1 (8323 tests) - one unrelated, pre-existing MtConsoleRenderer.Tests.ps1 timing flake; everything else passes

Refs #2692.

Summary by CodeRabbit

  • Bug Fixes
    • Credential findings now use the test’s configured default severity instead of being explicitly marked High. The finding is therefore reported with Medium severity, aligning the displayed severity with the test configuration. This change affects how severity is shown in the finding report; it does not change the finding itself or its detection.

Add-MtTestResultDetail's -Severity 'High' on the failure path never
took effect: Invoke-MtNativePlan.ps1 resolves a native test's severity
from its [MaesterTest] attribute (Medium) before it ever looks at the
helper call, so every failed run already reported Medium. Remove the
override so the code no longer implies a severity the check never
actually reports (maester365#2692).
@agnivesh
agnivesh requested a review from a team as a code owner November 9, 2026 22:46
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

MT.1208 now adds its finding report without explicitly setting severity to High.

Changes: MT.1208 Finding Severity

Layer / File(s) Summary
Finding report severity
tests/maester/entra/Test.MT.1208.ps1
The finding report no longer sets severity to High explicitly.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Refactor

Possibly related issues

Possibly related PRs

Suggested reviewers: merill

Merge Risk: Minimal · up to 7ee7a

This removes a severity override that had no effect on results. Failed MT.1208 runs already reported Medium, so reported behavior should not change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(entra): drop MT.1208's dead severity override" matches the changeset. The diff removes the -Severity 'High' argument from MT.1208's failure path in tests/maester/entra/Test.MT.1208.ps1,…
Description check Passed The description covers the change and the reason for it. It explains that the severity override had no effect, so it was removed. It also gives a test plan with PSScriptAnalyzer linting and a Pester r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(entra): drop MT.1208's dead severity override" matches the changeset. The diff removes the -Severity 'High' argument from MT.1208's failure path in tests/maester/entra/Test.MT.1208.ps1, because native tests take severity from the [MaesterTest] attribute. The title is specific, short, and names the test and the change.

Full details: Description check

Explanation

The description covers the change and the reason for it. It explains that the severity override had no effect, so it was removed. It also gives a test plan with PSScriptAnalyzer linting and a Pester run, and it references issue #2692. The template sections for the issue closure link, the checklist, and additional information are not filled in. The 'Closes # <Issue #>' line is still a placeholder, and the checklist items are unchecked. The description does not mention the Maester 3.0 code freeze, which only bug fixes may merge during. This PR is a bug fix, so the freeze does not block it. The description is mostly complete, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 61c0d30 and 7ee7a36.

Files selected for processing: 1

  • tests/maester/entra/Test.MT.1208.ps1

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@earbona23 earbona23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The premise checks out, and the engine says so in its own words. powershell/internal/engine/Invoke-MtNativePlan.ps1:467-472:

# Severity: config row (instance, then parent), the instance's, the attribute's, then the helper's.
$severity = if ($setting -and ... ) { ... }
    elseif ($isInstance -and (Get-MtInstanceValue -Instance $Instance -Name 'Severity')) { ... }
    elseif ($test.Severity) { [string]$test.Severity }          # the attribute
    elseif ($detail -and $detail.Severity) { [string]$detail.Severity }   # the helper

The helper is the last fallback, so for any native test that declares Severity in [MaesterTest] the argument can never win. MT.1208 declares Medium, so High never reached a report. Removing it is right.

It is a class, not an instance

I swept every call to Add-MtTestResultDetail that passes -Severity in tests/ and powershell/internal/checks/. 50 call sites in 47 files, and all 50 are dead: every one of those files declares Severity in its attribute, so :471 always answers first. The 50 split into two groups that need opposite treatment.

Seven pass a literal that contradicts the attribute. These are the ones that actively mislead a reader of the code:

test the code asks for the report shows
MT.1208 High Medium
MT.1077 High Medium
MT.1118 High Medium
CISA.MS.SHAREPOINT.1.1 High Medium
CISA.MS.SHAREPOINT.1.2 High Medium
CISA.MS.SHAREPOINT.2.2 Low Medium
CISA.MS.SHAREPOINT.3.1 High Medium

So this PR fixes one of seven. Test.CISA.MS.SHAREPOINT.3.1.ps1 is the same shape line for line — Severity = 'Medium' at line 24, -Severity 'High' at line 56.

Fifteen pass a computed value, which is a different problem: deleting the argument there would throw away an intent rather than dead weight.

test passes attribute
MT.1024 $priority Medium
MT.1059 $Instance.Severity Medium
MT.1182 $maxSeverity Medium
MT.1078–MT.1081, MT.1085–MT.1089, MT.1111, MT.1112, MT.1213 $Severity Low / Medium / High

MT.1059 is the telling one: it passes $Instance.Severity, and the engine does support exactly that — one line above, at :470, through Get-MtInstanceValue. The intent is supported; it is the route that is wrong. Those fifteen want the instance severity or a config row, not a deletion.

One question on this PR

Removing the argument settles a disagreement silently. The code said High, the report said Medium, and after this the answer is Medium with nothing recording that anyone chose it. You are right that Medium is what shipped, but was Medium the intended severity for a dead-tenant-admin finding, or was High the author's later judgement that never took effect? #2692 is the right place for that if it is open; a line in the PR body either way would stop the next reader reopening it.

Worth a gate

The parameter is not useless in general: Add-MtTestResultDetail.ps1:206 still fills it from the Pester tag for non-native tests, so it cannot just be removed from the signature. But a general test in the shape of TestParameterNames.Tests.ps1 — fail when a native test passes -Severity to the helper — would close the class instead of these seven being found one at a time. I am happy to write that, and the other six literals, as a follow-up PR if you would rather keep this one at a single line.

@earbona23 earbona23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I re-verified the premise against today's main rather than relying on my earlier reading, because Invoke-MtNativePlan.ps1 changed in between.

The severity resolution order is unchanged (powershell/internal/engine/Invoke-MtNativePlan.ps1:469-473):

$severity = if ($setting -and ...) { ... }                 # config row
elseif ($isInstance -and (Get-MtInstanceValue ... 'Severity')) { ... }  # the instance
elseif ($test.Severity) { [string]$test.Severity }          # the attribute   <-- answers first
elseif ($detail -and $detail.Severity) { ... }              # the helper      <-- never reached

MT.1208 declares Severity = 'Medium' at line 27 and passed -Severity 'High' at line 173, so the argument could never reach a report. Removing it is correct, and the net diff is still exactly that one line.

The wider point from my earlier comment stands as a repo-wide observation rather than anything owed by this PR: six other checks pass a literal that contradicts their attribute, Test.CISA.MS.SHAREPOINT.3.1.ps1 being the same shape line for line. Those are separate changes, and fifteen more pass a computed value where deleting the argument would discard an intent instead of dead weight — so a blanket sweep would be wrong.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants