Skip to content

fix(MT.1191): skip when break-glass exclusion cannot be verified - #2165

Open
earbona23 wants to merge 1 commit into
maester365:mainfrom
earbona23:fix/mt1191-unverifiable-breakglass-reports-passed
Open

fix(MT.1191): skip when break-glass exclusion cannot be verified#2165
earbona23 wants to merge 1 commit into
maester365:mainfrom
earbona23:fix/mt1191-unverifiable-breakglass-reports-passed

Conversation

@earbona23

@earbona23 earbona23 commented Sep 1, 2026

Copy link
Copy Markdown

Fixes #2114.

The problem

MT.1191 is counted as Passed in exactly the situation where it has just reported that it could not check anything.

When no emergency access accounts are configured in maester-config.json, Test-MtGsaCompliantNetworkBreakGlassExcluded records "break-glass exclusion cannot be verified" and returns $null. The bundled wrapper only asserts when the result is non-null:

$result = Test-MtGsaCompliantNetworkBreakGlassExcluded

if ($null -ne $result) {
    $result | Should -Be $true -Because "..."
}

So the It block completes without executing a single assertion, and Pester reports Passed. A control that states its own requirement is unverifiable lands in the passed count — which is the reading most likely to stop someone from looking.

The fix

Add-MtTestResultDetail calls Set-ItResult -Skipped only when -SkippedBecause is supplied. Passing -SkippedBecause Custom with the same message keeps the wording identical and moves the result from Passed to Skipped:

-Add-MtTestResultDetail -Result No emergency access accounts are configured...
+Add-MtTestResultDetail -SkippedBecause Custom -SkippedCustomReason No emergency access accounts are configured...

That pattern is already used in 153 places in this repository, so this introduces nothing new.

Tests

Adds powershell/tests/functions/Test-MtGsaCompliantNetworkBreakGlassExcluded.Tests.ps1 covering three branches: the unverifiable case now skips, an unexcluded break-glass account still returns $false, and an excluded one still returns $true.

The first test was checked by reverting the one-line fix and confirming it fails (Expected Add-MtTestResultDetail to be called 1 time exactly, but was called 0 times). Without that check it would pass with or without the bug and prove nothing.

Full unit suite after the change: 4103 passed, 0 failed (Pester 6.1.0, pwsh 7.6.2, Linux).

Deliberately not changed

The sibling "No enabled Compliant Network enforcement policy was found" branch, and the equivalent branches in the other GSA checks, are left alone. Those are genuinely not applicable rather than unverifiable — with no such policy there is no lock-out risk — and they follow the convention established across the GSA family. Happy to revisit separately if you see it differently.

Summary by CodeRabbit

  • Bug Fixes

    • Updated compliance results to clearly show when verification is skipped because no emergency access accounts are configured.
    • Prevented unverifiable controls from being incorrectly counted as passed.
    • Preserved accurate pass/fail results for network policies that do or do not exclude break-glass accounts.
  • Tests

    • Added coverage for skipped, compliant, and non-compliant scenarios.

@earbona23
earbona23 requested a review from a team as a code owner September 1, 2026 21:19
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: be6afc9b-db83-48ff-a898-8b5a88cf9842

📥 Commits

Reviewing files that changed from the base of the PR and between ccd720c and fb1e5f1.

📒 Files selected for processing (2)
  • powershell/public/maester/globalsecureaccess/Test-MtGsaCompliantNetworkBreakGlassExcluded.ps1
  • powershell/tests/functions/Test-MtGsaCompliantNetworkBreakGlassExcluded.Tests.ps1

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


📝 Walkthrough

Walkthrough

The break-glass exclusion test now records missing emergency access accounts as skipped with a custom reason. New Pester tests cover skipped, failed, and passed evaluation outcomes.

Changes

Break-glass verification status

Layer / File(s) Summary
Record unverifiable checks as skipped
powershell/public/maester/globalsecureaccess/Test-MtGsaCompliantNetworkBreakGlassExcluded.ps1
The function uses SkippedBecause Custom and a custom reason when emergency access accounts are not configured.
Validate break-glass evaluation outcomes
powershell/tests/functions/Test-MtGsaCompliantNetworkBreakGlassExcluded.Tests.ps1
Pester tests verify the skipped result for missing accounts, $false for non-excluded accounts, and $true for excluded accounts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to fb1e5

The unverifiable break-glass condition is now reported as skipped instead of passed, preventing a misleading compliance result. The change is localized and no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: cloud-architekt

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: skipping MT.1191 when break-glass exclusion cannot be verified.
Description check ✅ Passed The description is detailed and covers the problem, fix, linked issue, tests, results, and intentionally unchanged scope. It does not reproduce the template checklist, but it provides the required inf…
Linked Issues check ✅ Passed The implementation directly addresses issue #2114 by changing the unverifiable branch to a skipped result while preserving the message. Regression tests cover the skipped, failing, and passing branche…
Out of Scope Changes check ✅ Passed The one-line behavior change and focused regression tests are directly related to issue #2114. The PR explicitly leaves unrelated GSA branches unchanged.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Full details: Description check

Explanation

The description is detailed and covers the problem, fix, linked issue, tests, results, and intentionally unchanged scope. It does not reproduce the template checklist, but it provides the required information in substance.

Full details: Linked Issues check

Explanation

The implementation directly addresses issue #2114 by changing the unverifiable branch to a skipped result while preserving the message. Regression tests cover the skipped, failing, and passing branches.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@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

Copy link
Copy Markdown
Author

Thanks — automated checks are green (CodeRabbit + Codacy). Happy to rebase onto the latest main whenever it helps the review; it still merges cleanly today. Just flagging I'm around to adjust anything.

For context: the change is a one-liner that follows the -SkippedBecause Custom pattern already used in 153 places here, and the new test was verified by reverting the fix and confirming it fails (so it can't pass without the fix). Full unit suite after the change: 4103 passed, 0 failed. If a maintainer sees the "not applicable vs unverifiable" split on the sibling GSA branches differently, glad to revisit.

MT.1191 was counted as Passed in situations where it had explicitly reported that it
could not check anything.

When no emergency access accounts are configured in maester-config.json,
Test-MtGsaCompliantNetworkBreakGlassExcluded records "break-glass exclusion cannot be
verified" and returns $null. The bundled wrapper only asserts when the result is
non-null, so the It block completes without executing a single assertion and Pester
reports Passed. A control that states its own requirement is unverifiable therefore
lands in the passed count, which is the reading most likely to stop someone looking.

Add-MtTestResultDetail calls Set-ItResult -Skipped only when -SkippedBecause is
supplied. Passing -SkippedBecause Custom with the same message keeps the wording
identical and moves the result from Passed to Skipped. That pattern is already used in
153 places in this repository, so nothing new is introduced here.

Adds unit tests for the three branches: the unverifiable case now skips, an unexcluded
break-glass account still returns false, and an excluded one still returns true. The
first test was checked by reverting the one-line fix and confirming it fails -- without
that, it would pass either way and prove nothing.

Deliberately not changed: the sibling "no enabled Compliant Network policy was found"
branch, and the equivalent branches in the other GSA checks. Those are genuinely not
applicable rather than unverifiable -- with no such policy there is no lock-out risk --
and they follow the convention established across the GSA family. Happy to revisit
separately if maintainers see it differently.

Fixes maester365#2114
@earbona23
earbona23 force-pushed the fix/mt1191-unverifiable-breakglass-reports-passed branch from fb1e5f1 to 5a1950f Compare September 3, 2026 11:17
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.

MT.1191 reports Passed when the break-glass exclusion cannot be verified

1 participant