From 2675d7f61641a7ff260f1cb90e2a1833caee6d0c Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Tue, 10 Nov 2026 15:36:41 +1300 Subject: [PATCH 1/8] feat(cisa): move DLP checks to Purview Security Suite 3.1-3.5 (Part 5) Move EXO 8.4 to Purview SECURITYSUITE 3.1, remove the superseded EXO 8.1 and 8.2 tests, and add 3.2-3.5 with a sensitive-information DLP rule helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../purview/Get-MtCisaSensitiveDlpRule.ps1 | 82 ++++++++++++++ .../Test-MtCisaSecuritySuitePurview.Tests.ps1 | 107 ++++++++++++++++++ .../functions/engine/Frameworks.Tests.ps1 | 15 +-- .../engine/NativeLicenseGates.Tests.ps1 | 2 +- .../tests/general/NativeTestLint.Tests.ps1 | 1 + tests/cisa/exchange/Test.CISA.MS.EXO.8.1.md | 44 ------- tests/cisa/exchange/Test.CISA.MS.EXO.8.1.ps1 | 77 ------------- tests/cisa/exchange/Test.CISA.MS.EXO.8.2.md | 46 -------- tests/cisa/exchange/Test.CISA.MS.EXO.8.2.ps1 | 91 --------------- tests/cisa/frameworks/cisa-scuba.json | 24 ++++ .../Test.CISA.MS.SECURITYSUITE.3.1.md} | 6 +- .../Test.CISA.MS.SECURITYSUITE.3.1.ps1} | 10 +- .../purview/Test.CISA.MS.SECURITYSUITE.3.2.md | 18 +++ .../Test.CISA.MS.SECURITYSUITE.3.2.ps1 | 91 +++++++++++++++ .../purview/Test.CISA.MS.SECURITYSUITE.3.3.md | 18 +++ .../Test.CISA.MS.SECURITYSUITE.3.3.ps1 | 63 +++++++++++ .../purview/Test.CISA.MS.SECURITYSUITE.3.4.md | 18 +++ .../Test.CISA.MS.SECURITYSUITE.3.4.ps1 | 61 ++++++++++ .../purview/Test.CISA.MS.SECURITYSUITE.3.5.md | 18 +++ .../Test.CISA.MS.SECURITYSUITE.3.5.ps1 | 43 +++++++ 20 files changed, 561 insertions(+), 274 deletions(-) create mode 100644 powershell/internal/checks/cisa/purview/Get-MtCisaSensitiveDlpRule.ps1 create mode 100644 powershell/tests/functions/Test-MtCisaSecuritySuitePurview.Tests.ps1 delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.8.1.md delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.8.1.ps1 delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.8.2.md delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.8.2.ps1 rename tests/cisa/{exchange/Test.CISA.MS.EXO.8.4.md => purview/Test.CISA.MS.SECURITYSUITE.3.1.md} (79%) rename tests/cisa/{exchange/Test.CISA.MS.EXO.8.4.ps1 => purview/Test.CISA.MS.SECURITYSUITE.3.1.ps1} (90%) create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.2.md create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.2.ps1 create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.3.md create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.3.ps1 create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.4.md create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.4.ps1 create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.5.md create mode 100644 tests/cisa/purview/Test.CISA.MS.SECURITYSUITE.3.5.ps1 diff --git a/powershell/internal/checks/cisa/purview/Get-MtCisaSensitiveDlpRule.ps1 b/powershell/internal/checks/cisa/purview/Get-MtCisaSensitiveDlpRule.ps1 new file mode 100644 index 0000000000..55a038de69 --- /dev/null +++ b/powershell/internal/checks/cisa/purview/Get-MtCisaSensitiveDlpRule.ps1 @@ -0,0 +1,82 @@ +function Get-MtCisaSensitiveDlpRule { + [CmdletBinding()] + [OutputType([object[]])] + param() + + $policies = @(Get-MtExo -Request DlpCompliancePolicy) + $rules = @(Get-MtExo -Request DlpComplianceRule) + $sensitiveTypeIds = @( + '50842eb7-edc8-4019-85dd-5a5c1f2bb085', + 'a44669fe-0d48-453d-a9b1-2cc83f2cba77', + 'e55e2a32-f92d-4985-a35d-a0b269eb687b' + ) + $sensitiveTypes = @( + [pscustomobject]@{ Name = 'Credit Card Number'; Id = $sensitiveTypeIds[0] } + [pscustomobject]@{ Name = 'U.S. Social Security Number (SSN)'; Id = $sensitiveTypeIds[1] } + [pscustomobject]@{ Name = 'U.S. Individual Taxpayer Identification Number (ITIN)'; Id = $sensitiveTypeIds[2] } + ) + + $enabledPolicies = @( + $policies | Where-Object { $_.Enabled -eq $true -and $_.Mode -eq 'Enable' } | + ForEach-Object { + [pscustomobject]@{ + Name = $_.Name + Policy = $_ + } + } + ) + + $fullProtectionRules = foreach ($rule in $rules) { + if ($rule.Disabled -ne $false) { + continue + } + + $parentPolicy = $enabledPolicies | + Where-Object { $_.Name -eq $rule.ParentPolicyName -or $_.Policy.Identity -eq $rule.ParentPolicyName } | + Select-Object -First 1 + if (-not $parentPolicy) { + continue + } + + $matchedTypes = [System.Collections.Generic.List[string]]::new() + if ($rule.IsAdvancedRule -ne $true) { + foreach ($contentType in @($rule.ContentContainsSensitiveInformation)) { + $contentName = if ($contentType -is [string]) { + $contentType + } elseif ($contentType.Name) { + [string]$contentType.Name + } else { + [string]$contentType.DisplayName + } + + foreach ($sensitiveType in $sensitiveTypes) { + if ($contentName -ieq $sensitiveType.Name -and $sensitiveType.Name -notin $matchedTypes) { + $matchedTypes.Add($sensitiveType.Name) + } + } + } + } + + if ($rule.IsAdvancedRule -ne $false) { + $advancedRule = [string]$rule.AdvancedRule + foreach ($sensitiveType in $sensitiveTypes) { + if ( + ($advancedRule -match [regex]::Escape($sensitiveType.Name) -or + $advancedRule -match [regex]::Escape($sensitiveType.Id)) -and + $sensitiveType.Name -notin $matchedTypes + ) { + $matchedTypes.Add($sensitiveType.Name) + } + } + } + + if ($matchedTypes.Count -eq $sensitiveTypes.Count) { + [pscustomobject]@{ + Policy = $parentPolicy.Policy + Rule = $rule + } + } + } + + return @($fullProtectionRules) +} diff --git a/powershell/tests/functions/Test-MtCisaSecuritySuitePurview.Tests.ps1 b/powershell/tests/functions/Test-MtCisaSecuritySuitePurview.Tests.ps1 new file mode 100644 index 0000000000..71cdc20689 --- /dev/null +++ b/powershell/tests/functions/Test-MtCisaSecuritySuitePurview.Tests.ps1 @@ -0,0 +1,107 @@ +BeforeAll { + $testRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\..') + function New-TestSensitiveDlpResponses { + $advancedRule = @( + '50842eb7-edc8-4019-85dd-5a5c1f2bb085', + 'a44669fe-0d48-453d-a9b1-2cc83f2cba77', + 'e55e2a32-f92d-4985-a35d-a0b269eb687b' + ) -join ' ' + + @{ + DlpCompliancePolicy = @( + [pscustomobject]@{ + Name = 'Sensitive information'; Identity = 'Sensitive information'; Enabled = $true + Mode = 'Enable' + Workload = @('Exchange', 'OneDriveForBusiness', 'SharePoint', 'Teams', 'EndpointDevices') + ExchangeLocation = @([pscustomobject]@{ DisplayName = 'All' }) + OneDriveLocation = @([pscustomobject]@{ DisplayName = 'All' }) + SharePointLocation = @([pscustomobject]@{ DisplayName = 'All' }) + TeamsLocation = @([pscustomobject]@{ DisplayName = 'All' }) + EndpointDlpLocation = @([pscustomobject]@{ DisplayName = 'All' }) + } + ) + DlpComplianceRule = @( + [pscustomobject]@{ + Name = 'Protect sensitive information'; ParentPolicyName = 'Sensitive information' + Disabled = $false; IsAdvancedRule = $true; Mode = 'Enforce'; AdvancedRule = $advancedRule + ContentContainsSensitiveInformation = @() + BlockAccess = $true; BlockAccessScope = 'All'; NotifyUser = @('user@contoso.com') + } + ) + } + } + + . (Join-Path $testRoot 'powershell\internal\checks\cisa\purview\Get-MtCisaSensitiveDlpRule.ps1') + . (Join-Path $testRoot 'tests\cisa\purview\Test.CISA.MS.SECURITYSUITE.3.2.ps1') + . (Join-Path $testRoot 'tests\cisa\purview\Test.CISA.MS.SECURITYSUITE.3.3.ps1') + . (Join-Path $testRoot 'tests\cisa\purview\Test.CISA.MS.SECURITYSUITE.3.4.ps1') + . (Join-Path $testRoot 'tests\cisa\purview\Test.CISA.MS.SECURITYSUITE.3.5.ps1') +} + +Describe 'CISA Security Suite Purview checks' { + BeforeEach { + Mock Add-MtTestResultDetail {} + } + It 'checks that sensitive-information DLP policies cover all five workloads' { + $script:exoResponses = New-TestSensitiveDlpResponses + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaDlpAllLocations | Should -BeTrue + + $script:exoResponses.DlpCompliancePolicy[0].TeamsLocation = @() + Test-MtCisaDlpAllLocations | Should -BeFalse + } + + It 'recognizes basic DLP sensitive-information types and requires an enabled parent policy' { + $script:exoResponses = New-TestSensitiveDlpResponses + $script:exoResponses.DlpComplianceRule[0].IsAdvancedRule = $false + $script:exoResponses.DlpComplianceRule[0].ContentContainsSensitiveInformation = @( + [pscustomobject]@{ Name = 'Credit Card Number' } + [pscustomobject]@{ Name = 'U.S. Social Security Number (SSN)' } + [pscustomobject]@{ Name = 'U.S. Individual Taxpayer Identification Number (ITIN)' } + ) + $script:exoResponses.DlpComplianceRule[0].AdvancedRule = $null + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaDlpAllLocations | Should -BeTrue + Test-MtCisaDlpBlocksSensitiveInformation | Should -BeTrue + Test-MtCisaDlpNotifiesUsers | Should -BeTrue + + $script:exoResponses.DlpComplianceRule[0].ContentContainsSensitiveInformation = @( + $script:exoResponses.DlpComplianceRule[0].ContentContainsSensitiveInformation | Select-Object -First 2 + ) + Test-MtCisaDlpAllLocations | Should -BeFalse + Test-MtCisaDlpBlocksSensitiveInformation | Should -BeFalse + Test-MtCisaDlpNotifiesUsers | Should -BeFalse + + $script:exoResponses = New-TestSensitiveDlpResponses + $script:exoResponses.DlpCompliancePolicy[0].Mode = 'Audit' + Test-MtCisaDlpAllLocations | Should -BeFalse + } + + It 'requires full-protection DLP rules to block access for everyone' { + $script:exoResponses = New-TestSensitiveDlpResponses + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaDlpBlocksSensitiveInformation | Should -BeTrue + + $script:exoResponses.DlpComplianceRule[0].BlockAccessScope = 'NotInvolved' + Test-MtCisaDlpBlocksSensitiveInformation | Should -BeFalse + } + + It 'requires full-protection DLP rules to notify at least one user' { + $script:exoResponses = New-TestSensitiveDlpResponses + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaDlpNotifiesUsers | Should -BeTrue + + $script:exoResponses.DlpComplianceRule[0].NotifyUser = @() + Test-MtCisaDlpNotifiesUsers | Should -BeFalse + } + + It 'returns an investigation result for the manual endpoint DLP requirement' { + Test-MtCisaDlpEndpointRestrictions | Should -BeTrue + + Should -Invoke Add-MtTestResultDetail -Times 1 -Exactly -ParameterFilter { $Investigate } + } +} diff --git a/powershell/tests/functions/engine/Frameworks.Tests.ps1 b/powershell/tests/functions/engine/Frameworks.Tests.ps1 index 06a6372fd8..95dfcc5023 100644 --- a/powershell/tests/functions/engine/Frameworks.Tests.ps1 +++ b/powershell/tests/functions/engine/Frameworks.Tests.ps1 @@ -336,7 +336,7 @@ Describe 'Benchmark of the tests shipped with Maester' { It 'Gives every test a Benchmark of