From 69557522596c95d19c953fd2fd5a75d9694bfc87 Mon Sep 17 00:00:00 2001 From: Merill Fernando Date: Sun, 8 Nov 2026 08:24:23 +1100 Subject: [PATCH] refactor(tests): make CIS.M365.4.1 a shim of MT.1054 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 Entire-Checkpoint: 01M6VYBXV5GBJX6ZY6Y3HQ9VVF --- tests/cis/Test.CIS.M365.4.1.md | 2 ++ tests/cis/Test.CIS.M365.4.1.ps1 | 36 +++++---------------------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/tests/cis/Test.CIS.M365.4.1.md b/tests/cis/Test.CIS.M365.4.1.md index dee11ae9ac..83f8c207a8 100644 --- a/tests/cis/Test.CIS.M365.4.1.md +++ b/tests/cis/Test.CIS.M365.4.1.md @@ -4,6 +4,8 @@ Compliance policies are sets of rules and conditions that are used to evaluate t The recommended state is **Mark devices with no compliance policy assigned as** **Not compliant** +This test runs the same check as [MT.1054](https://maester.dev/docs/tests/MT.1054). The benchmark's audit reads the Intune device management settings and verifies that `secureByDefault` is `true`, which is what MT.1054 checks. The default, **Compliant** (`secureByDefault` is `false`), fails. + #### Rationale Implementing this setting is a first step in adopting compliance policies for devices. When used in together with Conditional Access policies the attack surface can be reduced by forcing an action to be taken for non-compliant devices. diff --git a/tests/cis/Test.CIS.M365.4.1.ps1 b/tests/cis/Test.CIS.M365.4.1.ps1 index e68b12cc50..5e40faab3b 100644 --- a/tests/cis/Test.CIS.M365.4.1.ps1 +++ b/tests/cis/Test.CIS.M365.4.1.ps1 @@ -7,13 +7,16 @@ Devices without a compliance policy assigned should be marked "not compliant". CIS Microsoft 365 Foundations Benchmark v7.0.0 (4.1, L1) + The benchmark's audit reads deviceManagement/settings and verifies that secureByDefault is True. + MT.1054 checks the same setting, so this test runs that check (Test-MtDeviceComplianceSettings). + .EXAMPLE Test-MtCisDevicesWithoutCompliancePolicyMarked Returns true if devices without a compliance policy assigned are marked "not compliant". .LINK - https://maester.dev/docs/commands/Test-MtCisDevicesWithoutCompliancePolicyMarked + https://maester.dev/docs/tests/CIS.M365.4.1 #> [MaesterTest( Id = 'CIS.M365.4.1', @@ -36,34 +39,5 @@ [OutputType([bool])] param() - Write-Verbose 'Getting settings...' - $settings = Invoke-MtGraphRequest -RelativeUri "deviceManagement/settings" - - Write-Verbose 'Executing checks' - $checkSecureByDefault = $settings | Where-Object { $_.secureByDefault -eq $true } - - $testResult = (($checkSecureByDefault | Measure-Object).Count -ge 1) - - if ($testResult) { - $testResultMarkdown = "Well done. Your tenant settings comply with CIS recommendations.`n`n%TestResult%" - } - else { - $testResultMarkdown = "Your tenant settings do not comply with CIS recommendations.`n`n%TestResult%" - } - - $resultMd = "| Setting | Result |`n" - $resultMd += "| --- | --- |`n" - - if ($checkSecureByDefault) { - $checkSecureByDefaultResult = '✅ Pass' - } - else { - $checkSecureByDefaultResult = '❌ Fail' - } - - $resultMd += "| Mark devices with no compliance policy assigned as 'Not compliant' | $checkSecureByDefaultResult |`n" - $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $resultMd - - Add-MtTestResultDetail -Result $testResultMarkdown - return $testResult + return Test-MtDeviceComplianceSettings }