diff --git a/.github/skills/maester-test-expert/SKILL.md b/.github/skills/maester-test-expert/SKILL.md index a58c985e11..947291dc4c 100644 --- a/.github/skills/maester-test-expert/SKILL.md +++ b/.github/skills/maester-test-expert/SKILL.md @@ -222,6 +222,7 @@ Reserved names (rejected today): `OptionalService`, `TimeoutSeconds`. Licence tokens: `AAD_PREMIUM` (Entra ID P1 or better), `AAD_PREMIUM_P2`, `Entra_Identity_Governance`, `AAD_WRKLDID_P1`, `AAD_WRKLDID_P2`, `ATP_ENTERPRISE` (MDO P1 or P2), `THREAT_INTELLIGENCE` (MDO P2), +`SAFEDOCS` (Safe Documents, which neither MDO plan includes), `EOP_ENTERPRISE`, `EXCHANGE_S_STANDARD`, `EXCHANGE_DLP`, `M365_ADVANCED_AUDITING`, `DEFENDER_XDR`, `LOCKBOX_ENTERPRISE`, `INTUNE_A`. Built-in checks use only these; add a token to the table if you need a new one. diff --git a/build/orca/Update-OrcaTests.ps1 b/build/orca/Update-OrcaTests.ps1 index 8e31de92d8..0cebba3b99 100644 --- a/build/orca/Update-OrcaTests.ps1 +++ b/build/orca/Update-OrcaTests.ps1 @@ -18,7 +18,8 @@ tests/orca/Test.ORCA..ps1 with one [MaesterTest] function, and tests/orca/Test.ORCA..md. Maester metadata that ORCA does not carry (severity, author, contributors and the classification attributes RelatedProduct, Feature, Area, ResourceType, UserImpact, ImplementationCost and Mitre) is - read from build/orca/orca-test-metadata.json. Edit that file, never the generated tests. + read from build/orca/orca-test-metadata.json, as is License for a check whose feature Defender for + Office 365 does not include. Edit that file, never the generated tests. .PARAMETER Offline Regenerates only the native tests from the committed check files. Nothing is downloaded. @@ -356,7 +357,9 @@ foreach ($check in $checks) { if ($meta.Control) { $attribute.Add("Control = $(Format-OrcaList @($meta.Control))") } $attribute.Add("Service = $(Format-OrcaList $services)") # Defender for Office 365 Plan 1 or 2. ORCA detects MDO itself and reports 'not completed' without it. - if ($check.Services -eq 'MDO') { $attribute.Add("License = 'ATP_ENTERPRISE'") } + # A check of a feature that neither plan includes, such as Safe Documents, names its licence in the metadata. + if ($meta.License) { $attribute.Add("License = $(Format-OrcaList @($meta.License))") } + elseif ($check.Services -eq 'MDO') { $attribute.Add("License = 'ATP_ENTERPRISE'") } $attribute.Add("Author = $(Format-OrcaList @($meta.Author))") if ($meta.Contributor) { $attribute.Add("Contributor = $(Format-OrcaList @($meta.Contributor))") } $attributeText = ($attribute | ForEach-Object { " $_" }) -join ",`n" diff --git a/build/orca/orca-test-metadata.json b/build/orca/orca-test-metadata.json index c8d0d5080f..232188c8c7 100644 --- a/build/orca/orca-test-metadata.json +++ b/build/orca/orca-test-metadata.json @@ -935,6 +935,7 @@ }, "ORCA.225": { "Severity": "Medium", + "License": "SAFEDOCS", "Author": [ "soulemike" ], @@ -1130,6 +1131,7 @@ }, "ORCA.234": { "Severity": "Medium", + "License": "SAFEDOCS", "Author": [ "soulemike" ], diff --git a/powershell/assets/MaesterLicenseTable.psd1 b/powershell/assets/MaesterLicenseTable.psd1 index 0554dec322..2f262e706e 100644 --- a/powershell/assets/MaesterLicenseTable.psd1 +++ b/powershell/assets/MaesterLicenseTable.psd1 @@ -33,6 +33,9 @@ THREAT_INTELLIGENCE = @{ ServicePlanIds = @('8e0c0a52-6a6c-4d40-8370-dd62790dcd70', '900018f1-0cdb-4ecb-94d4-90281760fdc6'); SkuIds = @('8e0c0a52-6a6c-4d40-8370-dd62790dcd70', '900018f1-0cdb-4ecb-94d4-90281760fdc6'); LegacySkipCode = 'NotLicensedMdo' } # Defender for Office 365 Plan 1 or Plan 2 (incl. GOV). ATP_ENTERPRISE = @{ DisplayName = 'Microsoft Defender for Office 365 Plan 1 or Plan 2'; ServicePlanIds = @('f20fedf3-f3c3-43c3-8267-2bfdd51c0939', '493ff600-6a2b-4db6-ad37-a7d4eb214516', '8e0c0a52-6a6c-4d40-8370-dd62790dcd70', '900018f1-0cdb-4ecb-94d4-90281760fdc6'); LegacySkipCode = 'NotLicensedMdoP1' } + # Safe Documents: Microsoft 365 A5, E5 and G5, and Microsoft Defender Suite. Neither Defender for Office 365 plan + # includes it, so ATP_ENTERPRISE does not cover it. 2.x had no code for it. + SAFEDOCS = @{ ServicePlanIds = @('bf6f5520-59e3-4f82-974b-7dbbc4fd27c7'); LegacySkipCode = 'Custom' } M365_ADVANCED_AUDITING = @{ ServicePlanIds = @('2f442157-a11c-46b9-ae5b-6e39ff4e5849'); SkuIds = @('2f442157-a11c-46b9-ae5b-6e39ff4e5849'); LegacySkipCode = 'NotLicensedAdvAudit' } # Any Exchange Online mailbox licence. EXCHANGE_S_STANDARD = @{ diff --git a/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 b/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 index 586d84a1c2..512a13f1a1 100644 --- a/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 +++ b/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 @@ -8,6 +8,8 @@ $p2OrGovernance = @{ License = @('AAD_PREMIUM_P2', 'Entra_Identity_Governance'); Legacy = 'NotLicensedEntraIDP2' } $p2AndAgent365 = @{ License = @('AAD_PREMIUM_P2&AGENT_365'); Legacy = 'NotLicensedEntraIDP2' } $mdoP1 = @{ License = @('ATP_ENTERPRISE'); Legacy = 'NotLicensedMdoP1' } + # CIS.M365.2.1.5 also requires Safe Documents, which neither Defender for Office 365 plan includes (2.x gated it on Plan 1). + $safeDocs = @{ License = @('SAFEDOCS'); Legacy = 'Custom' } $exoDlp = @{ License = @('EXCHANGE_DLP'); Legacy = 'NotLicensedExoDlp' } $intune = @{ License = @('INTUNE_A'); Legacy = 'NotLicensedIntune' } $converted = [ordered]@{ @@ -20,7 +22,7 @@ 'CISA.MS.EXO.17.3' = @{ License = @('M365_ADVANCED_AUDITING'); Legacy = 'NotLicensedAdvAudit' } 'CISA.MS.EXO.8.1' = $exoDlp; 'CISA.MS.EXO.8.2' = $exoDlp; 'CISA.MS.EXO.8.4' = $exoDlp 'CIS.M365.1.3.6' = @{ License = @('LOCKBOX_ENTERPRISE'); Legacy = 'NotLicensedCustomerLockbox' } - 'CIS.M365.2.1.1' = $mdoP1; 'CIS.M365.2.1.4' = $mdoP1; 'CIS.M365.2.1.5' = $mdoP1; 'CIS.M365.2.1.7' = $mdoP1 + 'CIS.M365.2.1.1' = $mdoP1; 'CIS.M365.2.1.4' = $mdoP1; 'CIS.M365.2.1.5' = $safeDocs; 'CIS.M365.2.1.7' = $mdoP1 'MT.1053' = $intune; 'MT.1096' = $intune; 'MT.1102' = $intune; 'MT.1105' = $intune 'MT.1106' = $p2OrGovernance; 'MT.1107' = $p2OrGovernance; 'MT.1108' = $p2OrGovernance; 'MT.1109' = $p2OrGovernance; 'MT.1110' = $p2OrGovernance 'MT.1175' = $exoDlp @@ -93,6 +95,15 @@ Describe 'Licence gates of converted tests' { } } + It 'Skip the Safe Documents checks on a tenant with Defender for Office 365 alone' { + # Defender for Office 365 Plan 1, part of Microsoft 365 E3 since July 2026, does not include Safe Documents. + foreach ($id in 'ORCA.225', 'ORCA.234', 'CIS.M365.2.1.5') { + (@((Get-MtTest -Id $id).License) -join ',') | Should -Be 'SAFEDOCS' -Because "$id checks a Safe Documents setting" + $row = Invoke-MtTest -Id $id -Config (New-Config -Licenses 'ATP_ENTERPRISE') + $row.ReasonCode | Should -Be 'LicenseNotFound' -Because "$id needs the SAFEDOCS service plan, not only Defender for Office 365" + } + } + It 'Run MT.1181 on a tenant with both Entra ID P2 and Agent 365' { # The mocks return no Conditional Access policy, so the body runs and finds no blocking policy. $row = Invoke-MtTest -Id 'MT.1181' -Config (New-Config -Licenses 'AAD_PREMIUM_P2', 'AGENT_365') @@ -159,6 +170,18 @@ Describe 'Licence skip message' { $met | Should -BeTrue } + It 'Counts the SAFEDOCS service plan as Safe Documents, and the Defender for Office 365 plans as not' { + $met = InModuleScope Maester { + Test-MtLicenseRequirement -Requirement 'SAFEDOCS' -Licenses ([pscustomobject]@{ ServicePlanIds = @('bf6f5520-59e3-4f82-974b-7dbbc4fd27c7'); SkuIds = @(); ServicePlanNames = @() }) + } + $met | Should -BeTrue + # ATP_ENTERPRISE (Plan 1) and THREAT_INTELLIGENCE (Plan 2) do not include Safe Documents. + $notMet = InModuleScope Maester { + Test-MtLicenseRequirement -Requirement 'SAFEDOCS' -Licenses ([pscustomobject]@{ ServicePlanIds = @('f20fedf3-f3c3-43c3-8267-2bfdd51c0939', '8e0c0a52-6a6c-4d40-8370-dd62790dcd70'); SkuIds = @(); ServicePlanNames = @() }) + } + $notMet | Should -BeFalse + } + It 'Gives every licence token a friendly name, from Microsoft or the table' { $unnamed = InModuleScope Maester { $table = Get-MtLicenseTable diff --git a/tests/cis/Test.CIS.M365.2.1.5.ps1 b/tests/cis/Test.CIS.M365.2.1.5.ps1 index f62fea9d95..ec9d50f3ca 100644 --- a/tests/cis/Test.CIS.M365.2.1.5.ps1 +++ b/tests/cis/Test.CIS.M365.2.1.5.ps1 @@ -7,6 +7,11 @@ Safe Attachments for SharePoint, OneDrive, and Microsoft Teams should be enabled CIS Microsoft 365 Foundations Benchmark v7.0.0 (2.1.5, L2) + The control also requires Safe Documents, which needs the SAFEDOCS service plan (Microsoft 365 A5, E5 or G5, + or Microsoft Defender Suite) and is not part of Defender for Office 365 Plan 1 or Plan 2. When Maester can read + the tenant's licences, it skips the check on a tenant without that plan; when it cannot, the check runs. + ORCA.158 checks the SharePoint, OneDrive and Teams setting on any Defender for Office 365 tenant. + .EXAMPLE Test-MtCisSafeAttachmentsAtpPolicy @@ -29,7 +34,7 @@ Mitre = ('T1080', 'T1204.002'), Control = ('cis-m365:2.1.5', 'nist-800-53-r5:SI-3'), Service = ('ExchangeOnline', 'Graph'), - License = 'ATP_ENTERPRISE', + License = 'SAFEDOCS', Author = 'NZLostboy' )] [CmdletBinding()] diff --git a/tests/orca/Test.ORCA.225.ps1 b/tests/orca/Test.ORCA.225.ps1 index c5f2176ca0..9dd2b39d4d 100644 --- a/tests/orca/Test.ORCA.225.ps1 +++ b/tests/orca/Test.ORCA.225.ps1 @@ -24,7 +24,7 @@ function Test-ORCA225 { Mitre = 'T1204.002', Control = 'nist-800-53-r5:SI-3', Service = 'ExchangeOnline', - License = 'ATP_ENTERPRISE', + License = 'SAFEDOCS', Author = 'soulemike' )] [CmdletBinding()] diff --git a/tests/orca/Test.ORCA.234.ps1 b/tests/orca/Test.ORCA.234.ps1 index 60d56249b2..2116d780cf 100644 --- a/tests/orca/Test.ORCA.234.ps1 +++ b/tests/orca/Test.ORCA.234.ps1 @@ -24,7 +24,7 @@ function Test-ORCA234 { Mitre = 'T1204.002', Control = 'nist-800-53-r5:SI-3', Service = 'ExchangeOnline', - License = 'ATP_ENTERPRISE', + License = 'SAFEDOCS', Author = 'soulemike' )] [CmdletBinding()] diff --git a/website/docs/writing-tests/index.mdx b/website/docs/writing-tests/index.mdx index 2bdc73705e..aedec3111a 100644 --- a/website/docs/writing-tests/index.mdx +++ b/website/docs/writing-tests/index.mdx @@ -420,6 +420,7 @@ government, education and suite variants match too: | `AAD_WRKLDID_P1`, `AAD_WRKLDID_P2` | Workload ID P1 or better, Workload ID P2 | | `ATP_ENTERPRISE` | Defender for Office 365 Plan 1 or Plan 2 | | `THREAT_INTELLIGENCE` | Defender for Office 365 Plan 2 | +| `SAFEDOCS` | Safe Documents (Microsoft 365 A5, E5 or G5, or Microsoft Defender Suite); not part of Defender for Office 365 | | `EOP_ENTERPRISE` | Exchange Online Protection | | `EXCHANGE_S_STANDARD` | Any Exchange Online mailbox licence | | `EXCHANGE_DLP` | Exchange Online DLP (Exchange Online Plan 2, the DLP plan, or Microsoft 365 Business Premium) | diff --git a/website/src/data/test-builder.json b/website/src/data/test-builder.json index 2b025d35ea..f03f8a568c 100644 --- a/website/src/data/test-builder.json +++ b/website/src/data/test-builder.json @@ -1201,6 +1201,7 @@ "INTUNE_A", "LOCKBOX_ENTERPRISE", "M365_ADVANCED_AUDITING", + "SAFEDOCS", "THREAT_INTELLIGENCE" ], "suites": [