Skip to content

refactor(tests): make CIS.M365.4.1 a shim of MT.1054 - #2720

Merged
merill merged 1 commit into
mainfrom
refactor/cis-m365-4-1-shim
Nov 8, 2026
Merged

merill merged 1 commit into
mainfrom
refactor/cis-m365-4-1-shim

Conversation

@merill

@merill merill commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

📑 Description

CIS.M365.4.1 now runs MT.1054's check instead of a copy of it: its body is return Test-MtDeviceComplianceSettings. It follows "Reviewing a test for duplicates" in AGENTS.md.

Why it's a duplicate. The CIS Microsoft 365 Foundations Benchmark v7.0.0, 4.1 (p.185), audits with GET https://graph.microsoft.com/v1.0/deviceManagement/settings and verifies that secureByDefault is True. MT.1054 reads the same property and passes only when it is true, so both tests checked the same setting in two different ways. MT.1054 reads the beta endpoint, which returns the same property. When the setting isn't returned, the test still fails.

What changes

  • tests/cis/Test.CIS.M365.4.1.ps1: the body is now the one return. The test keeps its own Id, Title, Control (cis-m365:4.1 first) and guide. Its other attributes already matched MT.1054's. The help now says which test it runs, and .LINK points to the test page, as CIS 4.2 does.
  • tests/cis/Test.CIS.M365.4.1.md: one paragraph that names MT.1054 and explains what the audit checks.
  • The result text now comes from MT.1054, which doesn't name a benchmark, as the writing-tests guide asks. The old "comply with CIS recommendations" wording and its one-row table are gone.

✅ Checks

  • My pull request adheres to the code style of this project.
  • My code requires changes to the documentation.
  • I have updated the documentation as required.
  • The build and unit tests pass after running /powershell/tests/pester.ps1 locally.

ℹ️ Additional Information

  • This isn't a bug fix, so under the 3.0 code freeze it can wait until after the release.
  • It overlaps the draft PR feat: the defender's path (M1–M7) #2683 (the defender's path), which adds Step = 'intune.mark-unassigned-noncompliant' to both CIS.M365.4.1 and MT.1054 and adds Step to the attributes a shim must match in TestShims.Tests.ps1. Whichever PR merges second must keep the shim's Step the same as MT.1054's, or TestShims fails.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • The audit now consistently checks that Intune’s secure-by-default setting is enabled; the default value of false fails the check.
  • Documentation
    • Clarified which setting the audit verifies and updated the link to the relevant test documentation.

CIS M365 v7.0.0 4.1 audits GET deviceManagement/settings and verifies that
secureByDefault is True, which is what MT.1054 checks. The CIS test now
returns Test-MtDeviceComplianceSettings instead of re-reading the setting,
so the two suites cannot give different answers for one setting. It keeps
its own Id, Title, Control and guide; the guide names MT.1054.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M6VYBXV5GBJX6ZY6Y3HQ9VVF
@merill
merill requested a review from a team as a code owner November 8, 2026 00:04
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CIS test documentation now describes the Intune secureByDefault check. The PowerShell test delegates that check to Test-MtDeviceComplianceSettings instead of performing its own Graph query and result construction.

Changes: Intune secureByDefault test

Layer / File(s) Summary
Document and delegate the setting check
tests/cis/Test.CIS.M365.4.1.md, tests/cis/Test.CIS.M365.4.1.ps1
The documentation identifies the secureByDefault requirement and notes that the default value of false fails. The PowerShell test description and documentation link are updated, and the test calls Test-MtDeviceComplianceSettings.

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

Change: Refactor

Suggested reviewers: samerde

Merge Risk: Minimal · up to 69557

The CIS test delegates its setting check while retaining its identity. No actionable merge risk remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: CIS.M365.4.1 becomes a shim that delegates to MT.1054. It matches the raw summary, which says the test now delegates to Test-MtDeviceComplianceSettings instead of runn…
Description check Passed The description follows the repository template. It has a Description section that explains the change and why it is a duplicate, a file-by-file list of what changes, a completed Checks section, and A…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 names the main change: CIS.M365.4.1 becomes a shim that delegates to MT.1054. It matches the raw summary, which says the test now delegates to Test-MtDeviceComplianceSettings instead of running its own Graph query. The title is short, specific, and follows the conventional-commit style.

Full details: Description check

Explanation

The description follows the repository template. It has a Description section that explains the change and why it is a duplicate, a file-by-file list of what changes, a completed Checks section, and Additional Information with the code-freeze note and overlap with draft PR #2683. The 'Closes #' issue line is left as a template placeholder, and the 'Checks' item on documentation is unchecked while the docs were in fact updated. These are minor gaps, so the description is mostly complete.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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 bb7a0e8 and 6955752.

Files selected for processing: 2

  • tests/cis/Test.CIS.M365.4.1.md
  • tests/cis/Test.CIS.M365.4.1.ps1

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 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.

@merill
merill merged commit 50ef692 into main Nov 8, 2026
15 checks passed
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.

1 participant