From a9716d02489b680ff3fdc67584f9336aad5a690a Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Tue, 10 Nov 2026 15:36:41 +1300 Subject: [PATCH 1/7] feat(cisa): migrate Security Suite Safe Links and allow-list checks 7.1-7.3 and 8.1-8.2 (Part 4) Move EXO 15.2, 15.3, 12.1 and 12.2 to SECURITYSUITE 7.2, 7.3, 8.1 and 8.2, and replace EXO 15.1 with 7.1, which checks the effective Safe Links policy as ScubaGear does. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ...est-MtCisaSecuritySuiteSafeLinks.Tests.ps1 | 60 ++++++++ .../engine/NativeLicenseGates.Tests.ps1 | 4 +- tests/cisa/exchange/Test.CISA.MS.EXO.15.1.md | 25 ---- tests/cisa/exchange/Test.CISA.MS.EXO.15.1.ps1 | 93 ------------- .../Test.CISA.MS.SECURITYSUITE.7.1.md | 28 ++++ .../Test.CISA.MS.SECURITYSUITE.7.1.ps1 | 130 ++++++++++++++++++ ...2.md => Test.CISA.MS.SECURITYSUITE.7.2.md} | 4 +- ...ps1 => Test.CISA.MS.SECURITYSUITE.7.2.ps1} | 4 +- ...3.md => Test.CISA.MS.SECURITYSUITE.7.3.md} | 4 +- ...ps1 => Test.CISA.MS.SECURITYSUITE.7.3.ps1} | 4 +- ...1.md => Test.CISA.MS.SECURITYSUITE.8.1.md} | 4 +- ...ps1 => Test.CISA.MS.SECURITYSUITE.8.1.ps1} | 4 +- ...2.md => Test.CISA.MS.SECURITYSUITE.8.2.md} | 4 +- ...ps1 => Test.CISA.MS.SECURITYSUITE.8.2.ps1} | 4 +- tests/cisa/frameworks/cisa-scuba.json | 24 ++++ 15 files changed, 260 insertions(+), 136 deletions(-) create mode 100644 powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.15.1.md delete mode 100644 tests/cisa/exchange/Test.CISA.MS.EXO.15.1.ps1 create mode 100644 tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.md create mode 100644 tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 rename tests/cisa/exchange/{Test.CISA.MS.EXO.15.2.md => Test.CISA.MS.SECURITYSUITE.7.2.md} (75%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.15.2.ps1 => Test.CISA.MS.SECURITYSUITE.7.2.ps1} (96%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.15.3.md => Test.CISA.MS.SECURITYSUITE.7.3.md} (76%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.15.3.ps1 => Test.CISA.MS.SECURITYSUITE.7.3.ps1} (96%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.12.1.md => Test.CISA.MS.SECURITYSUITE.8.1.md} (73%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.12.1.ps1 => Test.CISA.MS.SECURITYSUITE.8.1.ps1} (94%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.12.2.md => Test.CISA.MS.SECURITYSUITE.8.2.md} (75%) rename tests/cisa/exchange/{Test.CISA.MS.EXO.12.2.ps1 => Test.CISA.MS.SECURITYSUITE.8.2.ps1} (94%) diff --git a/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 new file mode 100644 index 0000000000..02b1d26888 --- /dev/null +++ b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 @@ -0,0 +1,60 @@ +BeforeAll { + $testRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\..') + . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.1.ps1') +} +Describe 'CISA Security Suite Safe Links checks' { + BeforeEach { + Mock Add-MtTestResultDetail {} + } + + It 'requires the effective Safe Links policy to protect all channels and internal senders' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; RecommendedPolicyType = 'Strict' + EnableSafeLinksForEmail = $true; EnableSafeLinksForTeams = $true + EnableSafeLinksForOffice = $true; EnableForInternalSenders = $true + } + ) + EOPProtectionPolicyRule = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; State = 'Enabled' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + SafeLinksRule = @() + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaSafeLink | Should -BeTrue + + $script:exoResponses.SafeLinksPolicy[0].EnableForInternalSenders = $false + Test-MtCisaSafeLink | Should -BeFalse + } + + It 'selects the highest-priority enabled Safe Links rule that covers all recipients' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ + Identity = 'All recipients'; Name = 'All recipients' + EnableSafeLinksForEmail = $true; EnableSafeLinksForTeams = $true + EnableSafeLinksForOffice = $true; EnableForInternalSenders = $true + } + ) + EOPProtectionPolicyRule = @() + SafeLinksRule = @( + [pscustomobject]@{ + State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'Scoped' + SentTo = @('user@contoso.com'); SentToMemberOf = @(); RecipientDomainIs = @() + }, + [pscustomobject]@{ + State = 'Enabled'; Priority = 2; SafeLinksPolicy = 'All recipients' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaSafeLink | Should -BeTrue + } +} diff --git a/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 b/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 index 586d84a1c2..258159ecfc 100644 --- a/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 +++ b/powershell/tests/functions/engine/NativeLicenseGates.Tests.ps1 @@ -15,8 +15,8 @@ 'CISA.MS.AAD.3.5' = $p1; 'CISA.MS.AAD.3.6' = $p1; 'CISA.MS.AAD.3.7' = $p1; 'CISA.MS.AAD.3.8' = $p1; 'CISA.MS.AAD.4.1' = $p1 'CISA.MS.AAD.2.1' = $p2; 'CISA.MS.AAD.2.2' = $p2; 'CISA.MS.AAD.2.3' = $p2 'CISA.MS.AAD.7.4' = $p2OrGovernance; 'CISA.MS.AAD.7.5' = $p2OrGovernance; 'CISA.MS.AAD.7.6' = $p2OrGovernance; 'CISA.MS.AAD.7.7' = $p2OrGovernance - 'CISA.MS.EXO.11.1' = $mdoP1; 'CISA.MS.EXO.11.2' = $mdoP1; 'CISA.MS.EXO.11.3' = $mdoP1; 'CISA.MS.EXO.15.1' = $mdoP1 - 'CISA.MS.EXO.15.2' = $mdoP1; 'CISA.MS.EXO.15.3' = $mdoP1; 'CISA.MS.EXO.16.1' = $mdoP1; 'CISA.MS.EXO.16.2' = $mdoP1 + 'CISA.MS.EXO.11.1' = $mdoP1; 'CISA.MS.EXO.11.2' = $mdoP1; 'CISA.MS.EXO.11.3' = $mdoP1; 'CISA.MS.SECURITYSUITE.7.1' = $mdoP1 + 'CISA.MS.SECURITYSUITE.7.2' = $mdoP1; 'CISA.MS.SECURITYSUITE.7.3' = $mdoP1; 'CISA.MS.EXO.16.1' = $mdoP1; 'CISA.MS.EXO.16.2' = $mdoP1 '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' } diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.md b/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.md deleted file mode 100644 index 3061dd9552..0000000000 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.md +++ /dev/null @@ -1,25 +0,0 @@ -URL comparison with a block-list SHOULD be enabled. - -Rationale: Users may be directed to malicious websites via links in email. Blocking access to known, malicious URLs can prevent users from accessing known malicious websites. - -#### Remediation action: - -1. Sign in to **Microsoft 365 Defender**. -2. In the left-hand menu, go to **Email & Collaboration** > **Policies & Rules**. -3. Select **Threat Policies**. -4. From the **Templated policies** section, select **Preset Security Policies**. -5. Under either **Standard protection** or **Strict protection**, select **Manage protection settings**. -6. Select **Next** until you reach the **Apply Defender for Office 365 protection** page. -7. On the **Apply Defender for Office 365 protection** page, select **All recipients**. -8. (Optional) Under **Exclude these recipients**, add **Users** and **Groups** to be exempted from the preset policies. -9. Select **Next** on each page until the **Review and confirm your changes** page. -10. On the **Review and confirm your changes** page, select **Confirm**. - -#### Related links - -* [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) -* [CISA 15 Link Protection - MS.EXO.15.1](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/exo.md#msexo151v1) -* [CISA ScubaGear Rego Reference](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/EXOConfig.rego#L813) - - -%TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.ps1 deleted file mode 100644 index 6d41f39919..0000000000 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.1.ps1 +++ /dev/null @@ -1,93 +0,0 @@ -function Test-MtCisaSafeLink { - <# - .SYNOPSIS - Checks state of URL block list - - .DESCRIPTION - URL comparison with a block-list SHOULD be enabled. - - .EXAMPLE - Test-MtCisaSafeLink - - Returns true if URL block list enabled - - .LINK - https://maester.dev/docs/commands/Test-MtCisaSafeLink - #> - [MaesterTest( - Id = 'CISA.MS.EXO.15.1', - Title = 'URL comparison with a block-list SHOULD be enabled.', - Product = 'exchange', - RelatedProduct = 'defender', - Feature = 'safe-links', - Area = 'email-protection', - ResourceType = 'Tenant', - Severity = 'Medium', - UserImpact = 'Low', - ImplementationCost = 'Low', - Mitre = ('T1566.002', 'T1204.001'), - Control = 'cisa-scuba:MS.EXO.15.1', - Service = ('ExchangeOnline', 'Graph'), - License = 'ATP_ENTERPRISE', - Author = 'soulemike', - Contributor = 'thomas-s-schmidt' - )] - [CmdletBinding()] - [OutputType([bool])] - param() - - $policies = Get-MtExo -Request SafeLinksPolicy - - $resultPolicies = $policies | Where-Object { ` - $_.EnableSafeLinksForEmail - } - - $standard = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq 'Standard' - } - - $strict = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq 'Strict' - } - - $testResult = $standard -and $strict -and (($resultPolicies | Measure-Object).Count -ge 1) - - $portalLink = 'https://security.microsoft.com/presetSecurityPolicies' - $passResult = '✅ Pass' - $failResult = '❌ Fail' - - if ($testResult) { - $testResultMarkdown = "Well done. Your tenant has [standard and strict preset security policies]($portalLink).`n`n%TestResult%" - } else { - $testResultMarkdown = "Your tenant does not have [standard and strict preset security policies]($portalLink).`n`n%TestResult%" - } - - $result = "| Policy | Status |`n" - $result += "| --- | --- |`n" - if ($standard) { - $result += "| Standard | $passResult |`n" - } else { - $result += "| Standard | $failResult |`n" - } - if ($strict) { - $result += "| Strict | $passResult |`n`n" - } else { - $result += "| Strict | $failResult |`n`n" - } - - $result += "| Policy Name | Policy Result |`n" - $result += "| --- | --- |`n" - foreach ($item in $policies | Sort-Object -Property Identity) { - if ($item.Guid -in $resultPolicies.Guid) { - $result += "| $($item.Identity) | $passResult |`n" - } else { - $result += "| $($item.Identity) | $failResult |`n" - } - } - - $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $result - - Add-MtTestResultDetail -Result $testResultMarkdown - - return $testResult -} diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.md new file mode 100644 index 0000000000..c073f9c907 --- /dev/null +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.md @@ -0,0 +1,28 @@ +URL comparison with a block-list SHOULD be enabled for URLs in emails, Teams messages, and Office documents. + +Rationale: Users may be directed to malicious websites via links in email. Blocking access to known, malicious URLs can prevent users from accessing known malicious websites. + +#### Remediation action: + +1. Sign in to **Microsoft 365 Defender**. +2. In the left-hand menu, go to **Email & Collaboration** > **Policies & Rules**. +3. Select **Threat Policies**. +4. From the **Templated policies** section, select **Preset Security Policies**. +5. Under either **Standard protection** or **Strict protection**, select **Manage protection settings**. +6. Select **Next** until you reach the **Apply Defender for Office 365 protection** page. +7. Ensure Safe Links protection is enabled for email, Teams messages, and Office documents. +8. On the **Apply Defender for Office 365 protection** page, select **All recipients**. +9. (Optional) Under **Exclude these recipients**, add **Users** and **Groups** to be exempted from the preset policies. +10. Select **Next** on each page until the **Review and confirm your changes** page. +11. On the **Review and confirm your changes** page, select **Confirm**. + +If neither preset policy has an enabled rule covering all recipients, configure the highest-priority enabled Safe Links rule that applies to all recipients. Ensure it also enables protection for internal senders. + +#### Related links + +* [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) +* [CISA Security Suite baseline - MS.SECURITYSUITE.7.1v1](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/baselines/securitysuite.md#mssecuritysuite71v1) +* [CISA ScubaGear Security Suite implementation](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/Rego/SecuritySuiteConfig.rego) + + +%TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 new file mode 100644 index 0000000000..5c5407dd84 --- /dev/null +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 @@ -0,0 +1,130 @@ +function Test-MtCisaSafeLink { + <# + .SYNOPSIS + Checks URL protection for the effective all-recipient Safe Links policy. + + .DESCRIPTION + URL comparison with a block-list SHOULD be enabled for URLs in emails, Teams messages, and Office documents. + + .EXAMPLE + Test-MtCisaSafeLink + + Returns true when the active preset or highest-priority all-recipient Safe Links policy enables protection for email, Teams, Office documents, and internal senders. + + .LINK + https://maester.dev/docs/commands/Test-MtCisaSafeLink + #> + [MaesterTest( + Id = 'CISA.MS.SECURITYSUITE.7.1', + Title = 'URL comparison with a block-list SHOULD be enabled for URLs in emails, Teams messages, and Office documents.', + Product = 'exchange', + RelatedProduct = 'defender', + Feature = 'safe-links', + Area = 'email-protection', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Low', + Mitre = ('T1566.002', 'T1204.001'), + Control = 'cisa-scuba:MS.SECURITYSUITE.7.1', + Service = ('ExchangeOnline', 'Graph'), + License = 'ATP_ENTERPRISE', + Author = 'soulemike', + Contributor = 'thomas-s-schmidt' + )] + [CmdletBinding()] + [OutputType([bool])] + param() + + $policies = @(Get-MtExo -Request SafeLinksPolicy) + $presetRules = @(Get-MtExo -Request EOPProtectionPolicyRule) + $safeLinksRules = @(Get-MtExo -Request SafeLinksRule) + + $isEmpty = { + param($Value) + $null -eq $Value -or + ($Value -is [string] -and [string]::IsNullOrWhiteSpace($Value)) -or + @($Value).Count -eq 0 + } + + $activePresetRules = @( + $presetRules | Where-Object { + $_.State -eq 'Enabled' -and + $_.Identity -match '(?i)(Standard|Strict) Preset Security Policy' -and + (& $isEmpty $_.SentTo) -and + (& $isEmpty $_.SentToMemberOf) -and + (& $isEmpty $_.RecipientDomainIs) + } + ) + + $selectedPolicy = $null + $selectedPolicyName = 'Built-In Protection Policy' + $selectionReason = 'Built-in protection' + + if ($activePresetRules.Count -gt 0) { + $presetType = if (@($activePresetRules | Where-Object { $_.Identity -match '(?i)Strict Preset Security Policy' }).Count -gt 0) { + 'Strict' + } else { + 'Standard' + } + $selectedPolicy = $policies | + Where-Object { $_.RecommendedPolicyType -eq $presetType } | + Select-Object -First 1 + if ($selectedPolicy) { + $selectedPolicyName = $selectedPolicy.Identity + $selectionReason = "$presetType preset policy covers all recipients" + } else { + $selectedPolicyName = "$presetType preset policy data not returned" + $selectionReason = 'Enabled all-recipient preset rule' + } + } else { + $allRecipientRules = @( + $safeLinksRules | Where-Object { + $_.State -eq 'Enabled' -and + (& $isEmpty $_.SentTo) -and + (& $isEmpty $_.SentToMemberOf) -and + (& $isEmpty $_.RecipientDomainIs) + } + ) + if ($allRecipientRules.Count -gt 0) { + $highestPriority = ($allRecipientRules | Measure-Object -Property Priority -Minimum).Minimum + $selectedRule = $allRecipientRules | + Where-Object { $_.Priority -eq $highestPriority } | + Select-Object -First 1 + $policyReference = $selectedRule.SafeLinksPolicy + $selectedPolicy = $policies | + Where-Object { $_.Identity -eq $policyReference -or $_.Name -eq $policyReference } | + Select-Object -First 1 + $selectedPolicyName = if ($selectedPolicy) { $selectedPolicy.Identity } else { [string]$policyReference } + $selectionReason = "Highest-priority all-recipient rule (priority $highestPriority)" + } else { + $selectedPolicy = $policies | + Where-Object { $_.Identity -eq 'Built-In Protection Policy' -or $_.Name -eq 'Built-In Protection Policy' } | + Select-Object -First 1 + } + } + + $testResult = $null -ne $selectedPolicy -and + $selectedPolicy.EnableSafeLinksForEmail -eq $true -and + $selectedPolicy.EnableSafeLinksForTeams -eq $true -and + $selectedPolicy.EnableSafeLinksForOffice -eq $true -and + $selectedPolicy.EnableForInternalSenders -eq $true + + $status = if ($testResult) { '✅ Pass' } else { '❌ Fail' } + $email = if ($selectedPolicy.EnableSafeLinksForEmail -eq $true) { 'Enabled' } else { 'Disabled' } + $teams = if ($selectedPolicy.EnableSafeLinksForTeams -eq $true) { 'Enabled' } else { 'Disabled' } + $office = if ($selectedPolicy.EnableSafeLinksForOffice -eq $true) { 'Enabled' } else { 'Disabled' } + $internal = if ($selectedPolicy.EnableForInternalSenders -eq $true) { 'Enabled' } else { 'Disabled' } + $result = "| Effective policy | Selection | Email | Teams | Office documents | Internal senders | Result |`n" + $result += "| --- | --- | --- | --- | --- | --- | --- |`n" + $result += "| $selectedPolicyName | $selectionReason | $email | $teams | $office | $internal | $status |`n" + + if ($testResult) { + $message = "Well done. The effective all-recipient Safe Links policy enables URL protection for email, Teams, Office documents, and internal senders.`n`n%TestResult%" + } else { + $message = 'Enable Safe Links and internal-sender protection on the effective all-recipient policy. A preset policy applies only when its all-recipient preset rule is enabled; otherwise the highest-priority all-recipient custom rule applies.`n`n%TestResult%' + } + + Add-MtTestResultDetail -Result ($message -replace '%TestResult%', $result) + return [bool]$testResult +} diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.2.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md similarity index 75% rename from tests/cisa/exchange/Test.CISA.MS.EXO.15.2.md rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md index 110304dbb3..4f38f73b5b 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.2.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md @@ -18,8 +18,8 @@ Rationale: URLs in emails may direct users to download and run malware. Scanning #### Related links * [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) -* [CISA 15 Link Protection - MS.EXO.15.2](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/exo.md#msexo152v1) -* [CISA ScubaGear Rego Reference](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/EXOConfig.rego#L828) +* [CISA Security Suite baseline - MS.SECURITYSUITE.7.2v1](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/baselines/securitysuite.md#mssecuritysuite72v1) +* [CISA ScubaGear Security Suite implementation](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/Rego/SecuritySuiteConfig.rego) %TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 similarity index 96% rename from tests/cisa/exchange/Test.CISA.MS.EXO.15.2.ps1 rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 index 1b726dc75b..059c4f7218 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 @@ -15,7 +15,7 @@ https://maester.dev/docs/commands/Test-MtCisaSafeLinkDownloadScan #> [MaesterTest( - Id = 'CISA.MS.EXO.15.2', + Id = 'CISA.MS.SECURITYSUITE.7.2', Title = 'Direct download links SHOULD be scanned for malware.', Product = 'exchange', RelatedProduct = 'defender', @@ -26,7 +26,7 @@ UserImpact = 'Low', ImplementationCost = 'Low', Mitre = ('T1204.001', 'T1566.002'), - Control = 'cisa-scuba:MS.EXO.15.2', + Control = 'cisa-scuba:MS.SECURITYSUITE.7.2', Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.3.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md similarity index 76% rename from tests/cisa/exchange/Test.CISA.MS.EXO.15.3.md rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md index 51621aa79a..c4514dee59 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.3.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md @@ -18,8 +18,8 @@ Rationale: Users may click on malicious links in emails, leading to compromise o #### Related links * [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) -* [CISA 15 Link Protection - MS.EXO.15.3](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/exo.md#msexo153v1) -* [CISA ScubaGear Rego Reference](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/EXOConfig.rego#L843) +* [CISA Security Suite baseline - MS.SECURITYSUITE.7.3v1](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/baselines/securitysuite.md#mssecuritysuite73v1) +* [CISA ScubaGear Security Suite implementation](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/Rego/SecuritySuiteConfig.rego) %TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.15.3.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 similarity index 96% rename from tests/cisa/exchange/Test.CISA.MS.EXO.15.3.ps1 rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 index 987cf3bd4a..13254efd85 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.15.3.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 @@ -15,7 +15,7 @@ https://maester.dev/docs/commands/Test-MtCisaSafeLinkClickTracking #> [MaesterTest( - Id = 'CISA.MS.EXO.15.3', + Id = 'CISA.MS.SECURITYSUITE.7.3', Title = 'User click tracking SHOULD be enabled.', Product = 'exchange', RelatedProduct = 'defender', @@ -26,7 +26,7 @@ UserImpact = 'Low', ImplementationCost = 'Low', Mitre = ('T1566.002', 'T1204.001'), - Control = 'cisa-scuba:MS.EXO.15.3', + Control = 'cisa-scuba:MS.SECURITYSUITE.7.3', Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.12.1.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.md similarity index 73% rename from tests/cisa/exchange/Test.CISA.MS.EXO.12.1.md rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.md index 7f0c02028f..ef94dd8c5c 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.12.1.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.md @@ -16,8 +16,8 @@ To modify the connection filters, follow the instructions found in Use the Micro #### Related links * [Defender admin center - Anti-spam policies](https://security.microsoft.com/antispam) -* [CISA 12 IP Allow Lists - MS.EXO.12.1v1](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/exo.md#msexo121v1) -* [CISA ScubaGear Rego Reference](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/EXOConfig.rego#L683) +* [CISA Security Suite baseline - MS.SECURITYSUITE.8.1v1](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/baselines/securitysuite.md#mssecuritysuite81v1) +* [CISA ScubaGear Security Suite implementation](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/Rego/SecuritySuiteConfig.rego) %TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.12.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 similarity index 94% rename from tests/cisa/exchange/Test.CISA.MS.EXO.12.1.ps1 rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 index 5360cd4d18..90802289d5 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.12.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 @@ -15,7 +15,7 @@ https://maester.dev/docs/commands/Test-MtCisaAntiSpamAllowList #> [MaesterTest( - Id = 'CISA.MS.EXO.12.1', + Id = 'CISA.MS.SECURITYSUITE.8.1', Title = 'IP allow lists SHOULD NOT be created.', Product = 'exchange', RelatedProduct = 'defender', @@ -26,7 +26,7 @@ UserImpact = 'Low', ImplementationCost = 'Medium', Mitre = ('T1566', 'T1684.002'), - Control = 'cisa-scuba:MS.EXO.12.1', + Control = 'cisa-scuba:MS.SECURITYSUITE.8.1', Service = 'ExchangeOnline', Author = 'soulemike', Contributor = 'merill' diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.12.2.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.md similarity index 75% rename from tests/cisa/exchange/Test.CISA.MS.EXO.12.2.md rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.md index 4d1357ba69..611f80af33 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.12.2.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.md @@ -16,8 +16,8 @@ To modify the connection filters, follow the instructions found in Use the Micro #### Related links * [Defender admin center - Anti-spam policies](https://security.microsoft.com/antispam) -* [CISA 12 IP Allow Lists - MS.EXO.12.2v1](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/baselines/exo.md#msexo122v1) -* [CISA ScubaGear Rego Reference](https://github.com/cisagov/ScubaGear/blob/main/PowerShell/ScubaGear/Rego/EXOConfig.rego#L710) +* [CISA Security Suite baseline - MS.SECURITYSUITE.8.2v1](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/baselines/securitysuite.md#mssecuritysuite82v1) +* [CISA ScubaGear Security Suite implementation](https://github.com/cisagov/ScubaGear/blob/92e5f2e361e433554f72d38180d11210deb640dc/PowerShell/ScubaGear/Rego/SecuritySuiteConfig.rego) %TestResult% \ No newline at end of file diff --git a/tests/cisa/exchange/Test.CISA.MS.EXO.12.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 similarity index 94% rename from tests/cisa/exchange/Test.CISA.MS.EXO.12.2.ps1 rename to tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 index dac7e0fdeb..5c39247a03 100644 --- a/tests/cisa/exchange/Test.CISA.MS.EXO.12.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 @@ -15,7 +15,7 @@ https://maester.dev/docs/commands/Test-MtCisaAntiSpamSafeList #> [MaesterTest( - Id = 'CISA.MS.EXO.12.2', + Id = 'CISA.MS.SECURITYSUITE.8.2', Title = 'Safe lists SHOULD NOT be enabled.', Product = 'exchange', RelatedProduct = 'defender', @@ -26,7 +26,7 @@ UserImpact = 'Low', ImplementationCost = 'Low', Mitre = ('T1566', 'T1684.002'), - Control = 'cisa-scuba:MS.EXO.12.2', + Control = 'cisa-scuba:MS.SECURITYSUITE.8.2', Service = 'ExchangeOnline', Author = 'soulemike', Contributor = 'merill' diff --git a/tests/cisa/frameworks/cisa-scuba.json b/tests/cisa/frameworks/cisa-scuba.json index 75246535de..09bbac8af2 100644 --- a/tests/cisa/frameworks/cisa-scuba.json +++ b/tests/cisa/frameworks/cisa-scuba.json @@ -77,6 +77,30 @@ { "Id": "MS.EXO.17.1", "Criticality": "SHALL", "Upstream": { "Status": "Moved", "Id": "MS.SECURITYSUITE.5.1v1", "From": "MS.EXO.17.1v1" }, "Related": ["nist-800-53-r5:AU-12"] }, { "Id": "MS.EXO.17.2", "Criticality": "SHALL", "Upstream": { "Status": "NotFound" }, "Related": [] }, { "Id": "MS.EXO.17.3", "Criticality": "SHALL", "Upstream": { "Status": "Moved", "Id": "MS.SECURITYSUITE.5.2v1", "From": "MS.EXO.17.3v1" }, "Related": ["nist-800-53-r5:AU-11"] }, + { "Id": "MS.SECURITYSUITE.1.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.1.1v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.1.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.1.2v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.1.3", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.1.3v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.1.4", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.1.4v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.2.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.2.1v1" }, "Related": ["nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.2.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.2.2v1" }, "Related": ["nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.2.3", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.2.3v1" }, "Related": ["nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.2.4", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.2.4v1" }, "Related": ["nist-800-53-r5:AT-2b", "nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.3.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.3.1v1" }, "Related": ["nist-800-53-r5:SC-7(10)"] }, + { "Id": "MS.SECURITYSUITE.3.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.3.2v1" }, "Related": ["nist-800-53-r5:SC-7(10)"] }, + { "Id": "MS.SECURITYSUITE.3.3", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.3.3v1" }, "Related": ["nist-800-53-r5:AC-3", "nist-800-53-r5:SC-7(10)"] }, + { "Id": "MS.SECURITYSUITE.3.4", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.3.4v1" }, "Related": ["nist-800-53-r5:AT-2b"] }, + { "Id": "MS.SECURITYSUITE.3.5", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.3.5v1" }, "Related": ["nist-800-53-r5:AC-19a"] }, + { "Id": "MS.SECURITYSUITE.4.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.4.1v1" }, "Related": ["nist-800-53-r5:SI-4(5)"] }, + { "Id": "MS.SECURITYSUITE.4.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.4.2v1" }, "Related": ["nist-800-53-r5:SI-4(5)"] }, + { "Id": "MS.SECURITYSUITE.5.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.5.1v1" }, "Related": ["nist-800-53-r5:AU-12"] }, + { "Id": "MS.SECURITYSUITE.5.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.5.2v1" }, "Related": ["nist-800-53-r5:AU-11"] }, + { "Id": "MS.SECURITYSUITE.6.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.6.1v1" }, "Related": ["nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.6.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.6.2v1" }, "Related": ["nist-800-53-r5:SI-8"] }, + { "Id": "MS.SECURITYSUITE.7.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.7.1v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.7.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.7.2v1" }, "Related": ["nist-800-53-r5:SI-3"] }, + { "Id": "MS.SECURITYSUITE.7.3", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.7.3v1" }, "Related": ["nist-800-53-r5:SI-3", "nist-800-53-r5:AU-12c"] }, + { "Id": "MS.SECURITYSUITE.8.1", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.8.1v1" }, "Related": ["nist-800-53-r5:AC-4"] }, + { "Id": "MS.SECURITYSUITE.8.2", "Criticality": "SHOULD", "Upstream": { "Status": "Current", "Id": "MS.SECURITYSUITE.8.2v1" }, "Related": ["nist-800-53-r5:AC-4"] }, { "Id": "MS.SHAREPOINT.1.1", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.1.1v1" }, "Related": ["nist-800-53-r5:AC-2", "nist-800-53-r5:AC-3", "nist-800-53-r5:IA-8"] }, { "Id": "MS.SHAREPOINT.1.2", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.1.2v1" }, "Related": ["nist-800-53-r5:AC-2", "nist-800-53-r5:AC-3", "nist-800-53-r5:IA-8"] }, { "Id": "MS.SHAREPOINT.1.3", "Criticality": "SHALL", "Upstream": { "Status": "Current", "Id": "MS.SHAREPOINT.1.3v1" }, "Related": ["nist-800-53-r5:AC-3", "nist-800-53-r5:AC-6(10)"] }, From 99d3842e5fcdcd2f262bbfe4b23971790913a5cf Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Wed, 11 Nov 2026 08:29:53 +1300 Subject: [PATCH 2/7] fix(cisa): align Safe Links checks with SCuBA Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Get-MtCisaEffectiveSafeLinksPolicy.ps1 | 80 ++++++++++++++ ...est-MtCisaSecuritySuiteSafeLinks.Tests.ps1 | 100 ++++++++++++++++++ .../Test.CISA.MS.SECURITYSUITE.7.1.ps1 | 71 +------------ .../Test.CISA.MS.SECURITYSUITE.7.2.md | 2 + .../Test.CISA.MS.SECURITYSUITE.7.2.ps1 | 59 ++--------- .../Test.CISA.MS.SECURITYSUITE.7.3.md | 2 + .../Test.CISA.MS.SECURITYSUITE.7.3.ps1 | 58 ++-------- .../Test.CISA.MS.SECURITYSUITE.8.2.ps1 | 22 ++-- 8 files changed, 217 insertions(+), 177 deletions(-) create mode 100644 powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 diff --git a/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 new file mode 100644 index 0000000000..416f9a4b93 --- /dev/null +++ b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 @@ -0,0 +1,80 @@ +function Get-MtCisaEffectiveSafeLinksPolicy { + [CmdletBinding()] + [OutputType([object])] + param() + + $policies = @(Get-MtExo -Request SafeLinksPolicy) + $presetRules = @(Get-MtExo -Request EOPProtectionPolicyRule) + $safeLinksRules = @(Get-MtExo -Request SafeLinksRule) + + $isEmpty = { + param($Value) + $null -eq $Value -or + ($Value -is [string] -and [string]::IsNullOrWhiteSpace($Value)) -or + @($Value).Count -eq 0 + } + + $activePresetRules = @( + $presetRules | Where-Object { + $_.State -eq 'Enabled' -and + $_.Identity -match '(?i)(Standard|Strict) Preset Security Policy' -and + (& $isEmpty $_.SentTo) -and + (& $isEmpty $_.SentToMemberOf) -and + (& $isEmpty $_.RecipientDomainIs) + } + ) + + $selectedPolicy = $null + $selectedPolicyName = 'Built-In Protection Policy' + $selectionReason = 'Built-in protection' + + if ($activePresetRules.Count -gt 0) { + $presetType = if (@($activePresetRules | Where-Object { $_.Identity -match '(?i)Strict Preset Security Policy' }).Count -gt 0) { + 'Strict' + } else { + 'Standard' + } + $selectedPolicy = $policies | + Where-Object { $_.RecommendedPolicyType -eq $presetType } | + Select-Object -First 1 + if ($selectedPolicy) { + $selectedPolicyName = $selectedPolicy.Identity + $selectionReason = "$presetType preset policy covers all recipients" + } else { + $selectedPolicyName = "$presetType preset policy data not returned" + $selectionReason = 'Enabled all-recipient preset rule' + } + } else { + $allRecipientRules = @( + $safeLinksRules | Where-Object { + $_.State -eq 'Enabled' -and + (& $isEmpty $_.SentTo) -and + (& $isEmpty $_.SentToMemberOf) -and + (& $isEmpty $_.RecipientDomainIs) + } + ) + if ($allRecipientRules.Count -gt 0) { + $highestPriority = ($allRecipientRules | Measure-Object -Property Priority -Minimum).Minimum + $selectedRule = $allRecipientRules | + Where-Object { $_.Priority -eq $highestPriority } | + Select-Object -First 1 + $policyReference = $selectedRule.SafeLinksPolicy + $selectedPolicy = $policies | + Where-Object { $_.Identity -eq $policyReference -or $_.Name -eq $policyReference } | + Select-Object -First 1 + $selectedPolicyName = if ($selectedPolicy) { $selectedPolicy.Identity } else { [string]$policyReference } + $selectionReason = "Highest-priority all-recipient rule (priority $highestPriority)" + } else { + $selectedPolicy = $policies | + Where-Object { $_.Identity -eq 'Built-In Protection Policy' -or $_.Name -eq 'Built-In Protection Policy' } | + Select-Object -First 1 + } + } + + [pscustomobject]@{ + Policy = $selectedPolicy + PolicyName = $selectedPolicyName + SelectionReason = $selectionReason + IsPreset = $activePresetRules.Count -gt 0 + } +} diff --git a/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 index 02b1d26888..4ca99214b4 100644 --- a/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 +++ b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 @@ -1,6 +1,10 @@ BeforeAll { $testRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..\..') . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.1.ps1') + . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.2.ps1') + . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.3.ps1') + . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.8.2.ps1') + . (Join-Path $testRoot 'powershell\internal\checks\cisa\exchange\Get-MtCisaEffectiveSafeLinksPolicy.ps1') } Describe 'CISA Security Suite Safe Links checks' { BeforeEach { @@ -57,4 +61,100 @@ Describe 'CISA Security Suite Safe Links checks' { Test-MtCisaSafeLink | Should -BeTrue } + + It 'checks URL scanning and deliver-after-scan on the effective Safe Links policy' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ + Identity = 'Scoped'; ScanUrls = $true; DeliverMessageAfterScan = $true + }, + [pscustomobject]@{ + Identity = 'All recipients'; ScanUrls = $true; DeliverMessageAfterScan = $true + } + ) + EOPProtectionPolicyRule = @() + SafeLinksRule = @( + [pscustomobject]@{ + State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'Scoped' + SentTo = @('user@contoso.com'); SentToMemberOf = @(); RecipientDomainIs = @() + }, + [pscustomobject]@{ + State = 'Enabled'; Priority = 2; SafeLinksPolicy = 'All recipients' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaSafeLinkDownloadScan | Should -BeTrue + + $script:exoResponses.SafeLinksPolicy[1].DeliverMessageAfterScan = $false + Test-MtCisaSafeLinkDownloadScan | Should -BeFalse + } + + It 'checks click tracking only on the effective Safe Links policy' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ Identity = 'All recipients'; TrackClicks = $false }, + [pscustomobject]@{ Identity = 'Unrelated'; TrackClicks = $true } + ) + EOPProtectionPolicyRule = @() + SafeLinksRule = @( + [pscustomobject]@{ + State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'All recipients' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaSafeLinkClickTracking | Should -BeFalse + + $script:exoResponses.SafeLinksPolicy[0].TrackClicks = $true + Test-MtCisaSafeLinkClickTracking | Should -BeTrue + } + + It 'accepts an all-recipient preset policy for scanning and click-tracking requirements' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; RecommendedPolicyType = 'Strict' + ScanUrls = $false; DeliverMessageAfterScan = $false; TrackClicks = $false + } + ) + EOPProtectionPolicyRule = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; State = 'Enabled' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + SafeLinksRule = @() + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaSafeLinkDownloadScan | Should -BeTrue + Test-MtCisaSafeLinkClickTracking | Should -BeTrue + } + + It 'fails Safe List compliance if any returned connection filter enables it' { + $script:exoResponses = @{ + HostedConnectionFilterPolicy = @( + [pscustomobject]@{ Name = 'Default'; EnableSafeList = $false }, + [pscustomobject]@{ Name = 'Additional'; EnableSafeList = $false } + ) + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaAntiSpamSafeList | Should -BeTrue + + $script:exoResponses.HostedConnectionFilterPolicy[1].EnableSafeList = $true + Test-MtCisaAntiSpamSafeList | Should -BeFalse + } + + It 'does not pass Safe List compliance when no connection filter policy is returned' { + $script:exoResponses = @{ HostedConnectionFilterPolicy = @() } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaAntiSpamSafeList | Should -BeFalse + } } diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 index 5c5407dd84..887fda2743 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 @@ -36,73 +36,8 @@ [OutputType([bool])] param() - $policies = @(Get-MtExo -Request SafeLinksPolicy) - $presetRules = @(Get-MtExo -Request EOPProtectionPolicyRule) - $safeLinksRules = @(Get-MtExo -Request SafeLinksRule) - - $isEmpty = { - param($Value) - $null -eq $Value -or - ($Value -is [string] -and [string]::IsNullOrWhiteSpace($Value)) -or - @($Value).Count -eq 0 - } - - $activePresetRules = @( - $presetRules | Where-Object { - $_.State -eq 'Enabled' -and - $_.Identity -match '(?i)(Standard|Strict) Preset Security Policy' -and - (& $isEmpty $_.SentTo) -and - (& $isEmpty $_.SentToMemberOf) -and - (& $isEmpty $_.RecipientDomainIs) - } - ) - - $selectedPolicy = $null - $selectedPolicyName = 'Built-In Protection Policy' - $selectionReason = 'Built-in protection' - - if ($activePresetRules.Count -gt 0) { - $presetType = if (@($activePresetRules | Where-Object { $_.Identity -match '(?i)Strict Preset Security Policy' }).Count -gt 0) { - 'Strict' - } else { - 'Standard' - } - $selectedPolicy = $policies | - Where-Object { $_.RecommendedPolicyType -eq $presetType } | - Select-Object -First 1 - if ($selectedPolicy) { - $selectedPolicyName = $selectedPolicy.Identity - $selectionReason = "$presetType preset policy covers all recipients" - } else { - $selectedPolicyName = "$presetType preset policy data not returned" - $selectionReason = 'Enabled all-recipient preset rule' - } - } else { - $allRecipientRules = @( - $safeLinksRules | Where-Object { - $_.State -eq 'Enabled' -and - (& $isEmpty $_.SentTo) -and - (& $isEmpty $_.SentToMemberOf) -and - (& $isEmpty $_.RecipientDomainIs) - } - ) - if ($allRecipientRules.Count -gt 0) { - $highestPriority = ($allRecipientRules | Measure-Object -Property Priority -Minimum).Minimum - $selectedRule = $allRecipientRules | - Where-Object { $_.Priority -eq $highestPriority } | - Select-Object -First 1 - $policyReference = $selectedRule.SafeLinksPolicy - $selectedPolicy = $policies | - Where-Object { $_.Identity -eq $policyReference -or $_.Name -eq $policyReference } | - Select-Object -First 1 - $selectedPolicyName = if ($selectedPolicy) { $selectedPolicy.Identity } else { [string]$policyReference } - $selectionReason = "Highest-priority all-recipient rule (priority $highestPriority)" - } else { - $selectedPolicy = $policies | - Where-Object { $_.Identity -eq 'Built-In Protection Policy' -or $_.Name -eq 'Built-In Protection Policy' } | - Select-Object -First 1 - } - } + $effectivePolicy = Get-MtCisaEffectiveSafeLinksPolicy + $selectedPolicy = $effectivePolicy.Policy $testResult = $null -ne $selectedPolicy -and $selectedPolicy.EnableSafeLinksForEmail -eq $true -and @@ -117,7 +52,7 @@ $internal = if ($selectedPolicy.EnableForInternalSenders -eq $true) { 'Enabled' } else { 'Disabled' } $result = "| Effective policy | Selection | Email | Teams | Office documents | Internal senders | Result |`n" $result += "| --- | --- | --- | --- | --- | --- | --- |`n" - $result += "| $selectedPolicyName | $selectionReason | $email | $teams | $office | $internal | $status |`n" + $result += "| $($effectivePolicy.PolicyName) | $($effectivePolicy.SelectionReason) | $email | $teams | $office | $internal | $status |`n" if ($testResult) { $message = "Well done. The effective all-recipient Safe Links policy enables URL protection for email, Teams, Office documents, and internal senders.`n`n%TestResult%" diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md index 4f38f73b5b..4648e87e7d 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.md @@ -15,6 +15,8 @@ Rationale: URLs in emails may direct users to download and run malware. Scanning 9. Select **Next** on each page until the **Review and confirm your changes** page. 10. On the **Review and confirm your changes** page, select **Confirm**. +If you do not use an all-recipient Standard or Strict preset policy, enable URL scanning and delivery after scanning on the effective all-recipient Safe Links policy. + #### Related links * [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 index 059c4f7218..f8a89fe9a5 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 @@ -36,58 +36,19 @@ [OutputType([bool])] param() - $policies = Get-MtExo -Request SafeLinksPolicy - - $resultPolicies = $policies | Where-Object { ` - $_.ScanUrls - } - - $standard = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq "Standard" - } - - $strict = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq "Strict" - } - - $testResult = $standard -and $strict -and (($resultPolicies|Measure-Object).Count -ge 1) - - $portalLink = "https://security.microsoft.com/presetSecurityPolicies" - $passResult = "✅ Pass" - $failResult = "❌ Fail" + $effectivePolicy = Get-MtCisaEffectiveSafeLinksPolicy + $policy = $effectivePolicy.Policy + $testResult = $null -ne $policy -and ( + $effectivePolicy.IsPreset -or + ($policy.ScanUrls -eq $true -and $policy.DeliverMessageAfterScan -eq $true) + ) if ($testResult) { - $testResultMarkdown = "Well done. Your tenant has [standard and strict preset security policies]($portalLink).`n`n%TestResult%" + $message = "Well done. Direct download links are scanned for malware by the effective all-recipient Safe Links policy ($($effectivePolicy.PolicyName))." } else { - $testResultMarkdown = "Your tenant does not have [standard and strict preset security policies]($portalLink).`n`n%TestResult%" + $message = "Enable URL scanning and delivery after scanning on the effective all-recipient Safe Links policy. The benchmark requires both settings for a custom policy; an enabled all-recipient Standard or Strict preset policy also satisfies the requirement." } - $result = "| Policy | Status |`n" - $result += "| --- | --- |`n" - if ($standard) { - $result += "| Standard | $passResult |`n" - } else { - $result += "| Standard | $failResult |`n" - } - if ($strict) { - $result += "| Strict | $passResult |`n`n" - } else { - $result += "| Strict | $failResult |`n`n" - } - - $result += "| Policy Name | Policy Result |`n" - $result += "| --- | --- |`n" - foreach($item in $policies | Sort-Object -Property Identity){ - if($item.Guid -in $resultPolicies.Guid){ - $result += "| $($item.Identity) | $passResult |`n" - }else{ - $result += "| $($item.Identity) | $failResult |`n" - } - } - - $testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $result - - Add-MtTestResultDetail -Result $testResultMarkdown - - return $testResult + Add-MtTestResultDetail -Result $message + return [bool]$testResult } diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md index c4514dee59..bdb9ea60c2 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.md @@ -15,6 +15,8 @@ Rationale: Users may click on malicious links in emails, leading to compromise o 9. Select **Next** on each page until the **Review and confirm your changes** page. 10. On the **Review and confirm your changes** page, select **Confirm**. +If you do not use an all-recipient Standard or Strict preset policy, enable user click tracking on the effective all-recipient Safe Links policy. + #### Related links * [Defender admin center - Preset security policies](https://security.microsoft.com/presetSecurityPolicies) diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 index 13254efd85..edd6646932 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 @@ -36,58 +36,18 @@ [OutputType([bool])] param() - $policies = Get-MtExo -Request SafeLinksPolicy - - $resultPolicies = $policies | Where-Object { ` - $_.TrackClicks - } - - $standard = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq 'Standard' - } - - $strict = $policies | Where-Object { ` - $_.RecommendedPolicyType -eq 'Strict' - } - - $testResult = $standard -and $strict -and (($resultPolicies | Measure-Object).Count -ge 1) - - $portalLink = 'https://security.microsoft.com/presetSecurityPolicies' - $passResult = '✅ Pass' - $failResult = '❌ Fail' + $effectivePolicy = Get-MtCisaEffectiveSafeLinksPolicy + $policy = $effectivePolicy.Policy + $testResult = $null -ne $policy -and ( + $effectivePolicy.IsPreset -or $policy.TrackClicks -eq $true + ) if ($testResult) { - $testResultMarkdown = "Well done. Your tenant has [standard and strict preset security policies]($portalLink).`n`n%TestResult%" + $message = "Well done. User click tracking is enabled by the effective all-recipient Safe Links policy ($($effectivePolicy.PolicyName))." } else { - $testResultMarkdown = "Your tenant does not have [standard and strict preset security policies]($portalLink).`n`n%TestResult%" + $message = "Enable user click tracking on the effective all-recipient Safe Links policy. An enabled all-recipient Standard or Strict preset policy also satisfies the requirement." } - $result = "| Policy | Status |`n" - $result += "| --- | --- |`n" - if ($standard) { - $result += "| Standard | $passResult |`n" - } else { - $result += "| Standard | $failResult |`n" - } - if ($strict) { - $result += "| Strict | $passResult |`n`n" - } else { - $result += "| Strict | $failResult |`n`n" - } - - $result += "| Policy Name | Policy Result |`n" - $result += "| --- | --- |`n" - foreach ($item in $policies | Sort-Object -Property Identity) { - if ($item.Guid -in $resultPolicies.Guid) { - $result += "| $($item.Identity) | $passResult |`n" - } else { - $result += "| $($item.Identity) | $failResult |`n" - } - } - - $testResultMarkdown = $testResultMarkdown -replace '%TestResult%', $result - - Add-MtTestResultDetail -Result $testResultMarkdown - - return $testResult + Add-MtTestResultDetail -Result $message + return [bool]$testResult } diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 index 5c39247a03..757ee4cab7 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 @@ -35,25 +35,25 @@ [OutputType([bool])] param() - $policy = Get-MtExo -Request HostedConnectionFilterPolicy - - $resultPolicy = $policy | Where-Object {` - -not $_.EnableSafeList - } - - $testResult = ($resultPolicy|Measure-Object).Count -eq 1 + $policies = @(Get-MtExo -Request HostedConnectionFilterPolicy) + $policiesWithSafeList = @($policies | Where-Object { $_.EnableSafeList -eq $true }) + $testResult = $policies.Count -gt 0 -and $policiesWithSafeList.Count -eq 0 $portalLink = "https://security.microsoft.com/antispam" if ($testResult) { $testResultMarkdown = "Well done. [Safe List]($portalLink) is disabled in your tenant." } else { - $testResultMarkdown = "[Safe List]($portalLink) is enabled in your tenant." + $testResultMarkdown = "Disable Safe List on every connection filter policy returned by [the anti-spam policies page]($portalLink)." + if ($policies.Count -eq 0) { + $testResultMarkdown = "No connection filter policy was returned. Verify the connection to Exchange Online and confirm that the policy data is available." + } elseif ($policiesWithSafeList.Count -gt 0) { + $policyNames = @($policiesWithSafeList | ForEach-Object { $_.Name }) + $testResultMarkdown += "`n`nSafe List is enabled on: $($policyNames -join ', ')." + } } - $testResultMarkdown = $testResultMarkdown -replace "%TestResult%", $result - Add-MtTestResultDetail -Result $testResultMarkdown - return $testResult + return [bool]$testResult } From 5de5b94c99cf14b134d39de0e6cbafb02cc9df4f Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Wed, 11 Nov 2026 09:42:01 +1300 Subject: [PATCH 3/7] fix(cisa): address Security Suite review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build/golden/Export-MtLegacyIdTable.ps1 | 63 +++++++++++++++++-- powershell/assets/Maester.LegacyIds.json | 62 ++++++++++++++---- .../Get-MtCisaEffectiveSafeLinksPolicy.ps1 | 2 +- ...est-MtCisaSecuritySuiteSafeLinks.Tests.ps1 | 56 +++++++++++++++-- .../Test.CISA.MS.SECURITYSUITE.7.1.ps1 | 2 +- .../Test.CISA.MS.SECURITYSUITE.7.3.ps1 | 4 +- .../Test.CISA.MS.SECURITYSUITE.8.1.ps1 | 10 +-- 7 files changed, 171 insertions(+), 28 deletions(-) diff --git a/build/golden/Export-MtLegacyIdTable.ps1 b/build/golden/Export-MtLegacyIdTable.ps1 index e5a8d8ea9e..e4dc1f5395 100644 --- a/build/golden/Export-MtLegacyIdTable.ps1 +++ b/build/golden/Export-MtLegacyIdTable.ps1 @@ -19,9 +19,11 @@ function - the single check function called in the It body is called by exactly one current test retired - nothing matched - The output is deterministic: GeneratedFrom is the last commit that touched the scanned test files, - and current IDs are read from that commit's tree, so rerunning on a later commit that does not touch - tests/ produces identical output. + Existing mappings are retained when their target still exists, so moving a check from a Pester wrapper + to a native test does not discard its legacy IDs. + + The output is deterministic for the current tests tree and checked-in table: GeneratedFrom is the last + commit that touched the scanned legacy test files, and current IDs include native Test..ps1 files. .EXAMPLE ./build/golden/Export-MtLegacyIdTable.ps1 @@ -55,6 +57,11 @@ $ManualOverrides = [ordered]@{ # Pre-colon names of the split checks; the current titles say 'Global Administrator' and both call one function. 'MT.1050 Apps with high-risk permissions having a direct path to Global Admin' = 'MT.1050' 'MT.1051 Apps with high-risk permissions having an indirect path to Global Admin' = 'MT.1051' + 'MS.EXO.12.1' = 'CISA.MS.SECURITYSUITE.8.1' + 'MS.EXO.12.2' = 'CISA.MS.SECURITYSUITE.8.2' + 'MS.EXO.15.1' = 'CISA.MS.SECURITYSUITE.7.1' + 'MS.EXO.15.2' = 'CISA.MS.SECURITYSUITE.7.2' + 'MS.EXO.15.3' = 'CISA.MS.SECURITYSUITE.7.3' # Mock-based unit tests that briefly lived under tests/; they were never security checks. 'MFA for All users should pass even if not targeting guests' = 'retired' 'MFA for All users that excludes any guest type should fail' = 'retired' @@ -244,7 +251,7 @@ foreach ($commit in $commits) { } #endregion Scan history -#region Current IDs (from the tree of $generatedFrom) +#region Current IDs $currentIds = [System.Collections.Generic.Dictionary[string, object]]::new([System.StringComparer]::OrdinalIgnoreCase) $familyPrefixes = [System.Collections.Generic.SortedSet[string]]::new([System.StringComparer]::Ordinal) $treeLines = Invoke-Git ls-tree -r $generatedFrom -- tests @@ -261,6 +268,40 @@ foreach ($line in $treeLines) { $currentIds[$split.Id] = [pscustomobject]@{ Id = $split.Id; Title = (Get-NormalizedTitle $split.Title); Functions = $it.Functions; Path = $path } } } +# Native test IDs and their metadata are not present in the legacy Pester wrappers scanned above. +foreach ($nativeFile in (Get-ChildItem -Path (Join-Path $RepoRoot 'tests') -Recurse -File -Filter 'Test.*.ps1' | + Where-Object { $_.FullName -notmatch '[\\/]Custom[\\/]' })) { + $id = $nativeFile.Name -replace '^Test\.', '' -replace '\.ps1$', '' + $tokens = $null + $parseErrors = $null + $nativeAst = [System.Management.Automation.Language.Parser]::ParseFile($nativeFile.FullName, [ref] $tokens, [ref] $parseErrors) + if ($parseErrors.Count -gt 0) { + throw "Could not parse native test '$($nativeFile.FullName)': $($parseErrors[0].Message)" + } + $testFunction = $nativeAst.Find({ + param($node) + $node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and + @($node.Attributes | Where-Object { $_.TypeName.FullName -eq 'MaesterTest' }).Count -gt 0 + }, $true) | Select-Object -First 1 + $title = '' + $functions = @() + if ($testFunction) { + $testAttribute = $testFunction.Attributes | Where-Object { $_.TypeName.FullName -eq 'MaesterTest' } | Select-Object -First 1 + $titleArgument = $testAttribute.NamedArguments | Where-Object { $_.ArgumentName -eq 'Title' } | Select-Object -First 1 + if (-not $titleArgument -or $titleArgument.Argument -isnot [System.Management.Automation.Language.StringConstantExpressionAst]) { + throw "Native test '$($nativeFile.FullName)' has no constant Title in its MaesterTest attribute." + } + $title = Get-NormalizedTitle $titleArgument.Argument.Value + $functions = @($testFunction.Name) + } + $relativePath = [System.IO.Path]::GetRelativePath($RepoRoot, $nativeFile.FullName).Replace('\', '/') + $currentIds[$id] = [pscustomobject]@{ + Id = $id + Title = $title + Functions = $functions + Path = $relativePath + } +} Write-Verbose "Current static IDs: $($currentIds.Count); family prefixes: $($familyPrefixes -join ', ')" $titleIndex = @{} @@ -276,6 +317,18 @@ foreach ($c in $currentIds.Values) { } #endregion Current IDs +#region Existing mappings +$priorMappings = @{} +if (Test-Path -LiteralPath $OutputPath) { + $priorTable = Get-Content -LiteralPath $OutputPath -Raw | ConvertFrom-Json + foreach ($entry in $priorTable.Entries) { + if ($entry.CurrentId -and $entry.CurrentId -ne 'retired') { + $priorMappings[$entry.LegacyId] = $entry + } + } +} +#endregion Existing mappings + #region Map $entries = [System.Collections.Generic.List[object]]::new() $review = [System.Collections.Generic.List[string]]::new() @@ -303,6 +356,8 @@ foreach ($record in $history.Values) { $currentId = $ManualOverrides[$record.Id]; $rule = 'manual' } elseif ($prefixTarget) { $currentId = $prefixTarget; $rule = 'prefix' + } elseif ($priorMappings.ContainsKey($record.Id) -and $currentIds.ContainsKey($priorMappings[$record.Id].CurrentId)) { + $currentId = $priorMappings[$record.Id].CurrentId; $rule = $priorMappings[$record.Id].Rule } elseif ($titleCandidates.Count -eq 1) { $currentId = @($titleCandidates)[0]; $rule = 'title' if ($functionCandidates.Count -gt 0 -and -not $functionCandidates.Contains($currentId)) { diff --git a/powershell/assets/Maester.LegacyIds.json b/powershell/assets/Maester.LegacyIds.json index d0681e44a6..479def63f9 100644 --- a/powershell/assets/Maester.LegacyIds.json +++ b/powershell/assets/Maester.LegacyIds.json @@ -1,6 +1,6 @@ { "SchemaVersion": "1.0", - "GeneratedFrom": "fc6a9078bcdd59b5b2f788682fdcd2be27e15b9c", + "GeneratedFrom": "eb13e7a116e4063bec204e901e4847ae67c1f6f6", "Entries": [ { "LegacyId": "1.1.1 (L1) Ensure Administrative accounts are cloud-only", @@ -1130,6 +1130,46 @@ "LastSeenCommit": "5810a0dc37538fe0c4884f55938f23f5c7d1d6cc", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockExecutable.Tests.ps1" }, + { + "LegacyId": "CISA.MS.EXO.12.1", + "CurrentId": "retired", + "Rule": "retired", + "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", + "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", + "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamAllowList.Tests.ps1" + }, + { + "LegacyId": "CISA.MS.EXO.12.2", + "CurrentId": "retired", + "Rule": "retired", + "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", + "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", + "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamSafeList.Tests.ps1" + }, + { + "LegacyId": "CISA.MS.EXO.15.1", + "CurrentId": "retired", + "Rule": "retired", + "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", + "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", + "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLink.Tests.ps1" + }, + { + "LegacyId": "CISA.MS.EXO.15.2", + "CurrentId": "retired", + "Rule": "retired", + "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", + "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", + "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkDownloadScan.Tests.ps1" + }, + { + "LegacyId": "CISA.MS.EXO.15.3", + "CurrentId": "retired", + "Rule": "retired", + "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", + "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", + "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkClickTracking.Tests.ps1" + }, { "LegacyId": "Configure which users are allowed to present in Teams meetings", "CurrentId": "retired", @@ -1892,16 +1932,16 @@ }, { "LegacyId": "MS.EXO.12.1", - "CurrentId": "CISA.MS.EXO.12.1", - "Rule": "prefix", + "CurrentId": "CISA.MS.SECURITYSUITE.8.1", + "Rule": "manual", "FirstSeenCommit": "d119939a0fca63d684941e7194531ec6e6e0a455", "LastSeenCommit": "726b9fd3bc414db3c41db8c6ec9a825c0713b34e", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamAllowList.Tests.ps1" }, { "LegacyId": "MS.EXO.12.2", - "CurrentId": "CISA.MS.EXO.12.2", - "Rule": "prefix", + "CurrentId": "CISA.MS.SECURITYSUITE.8.2", + "Rule": "manual", "FirstSeenCommit": "4b0afaad10741d4fff485316df5a6b843d3afcfa", "LastSeenCommit": "6d7e5099d9d830c07cab2a660a471f29f74d18f3", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamSafeList.Tests.ps1" @@ -1948,24 +1988,24 @@ }, { "LegacyId": "MS.EXO.15.1", - "CurrentId": "CISA.MS.EXO.15.1", - "Rule": "prefix", + "CurrentId": "CISA.MS.SECURITYSUITE.7.1", + "Rule": "manual", "FirstSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLink.Tests.ps1" }, { "LegacyId": "MS.EXO.15.2", - "CurrentId": "CISA.MS.EXO.15.2", - "Rule": "prefix", + "CurrentId": "CISA.MS.SECURITYSUITE.7.2", + "Rule": "manual", "FirstSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkDownloadScan.Tests.ps1" }, { "LegacyId": "MS.EXO.15.3", - "CurrentId": "CISA.MS.EXO.15.3", - "Rule": "prefix", + "CurrentId": "CISA.MS.SECURITYSUITE.7.3", + "Rule": "manual", "FirstSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenCommit": "e7c8045968db237b765bb43687d055ed9ad4ec6e", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkClickTracking.Tests.ps1" diff --git a/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 index 416f9a4b93..e520434206 100644 --- a/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 +++ b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 @@ -4,7 +4,7 @@ function Get-MtCisaEffectiveSafeLinksPolicy { param() $policies = @(Get-MtExo -Request SafeLinksPolicy) - $presetRules = @(Get-MtExo -Request EOPProtectionPolicyRule) + $presetRules = @(Get-MtExo -Request ATPProtectionPolicyRule) $safeLinksRules = @(Get-MtExo -Request SafeLinksRule) $isEmpty = { diff --git a/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 index 4ca99214b4..4a736b35e6 100644 --- a/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 +++ b/powershell/tests/functions/Test-MtCisaSecuritySuiteSafeLinks.Tests.ps1 @@ -3,6 +3,7 @@ . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.1.ps1') . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.2.ps1') . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.7.3.ps1') + . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.8.1.ps1') . (Join-Path $testRoot 'tests\cisa\exchange\Test.CISA.MS.SECURITYSUITE.8.2.ps1') . (Join-Path $testRoot 'powershell\internal\checks\cisa\exchange\Get-MtCisaEffectiveSafeLinksPolicy.ps1') } @@ -20,7 +21,7 @@ Describe 'CISA Security Suite Safe Links checks' { EnableSafeLinksForOffice = $true; EnableForInternalSenders = $true } ) - EOPProtectionPolicyRule = @( + ATPProtectionPolicyRule = @( [pscustomobject]@{ Identity = 'Strict Preset Security Policy'; State = 'Enabled' SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() @@ -45,7 +46,7 @@ Describe 'CISA Security Suite Safe Links checks' { EnableSafeLinksForOffice = $true; EnableForInternalSenders = $true } ) - EOPProtectionPolicyRule = @() + ATPProtectionPolicyRule = @() SafeLinksRule = @( [pscustomobject]@{ State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'Scoped' @@ -72,7 +73,7 @@ Describe 'CISA Security Suite Safe Links checks' { Identity = 'All recipients'; ScanUrls = $true; DeliverMessageAfterScan = $true } ) - EOPProtectionPolicyRule = @() + ATPProtectionPolicyRule = @() SafeLinksRule = @( [pscustomobject]@{ State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'Scoped' @@ -98,7 +99,7 @@ Describe 'CISA Security Suite Safe Links checks' { [pscustomobject]@{ Identity = 'All recipients'; TrackClicks = $false }, [pscustomobject]@{ Identity = 'Unrelated'; TrackClicks = $true } ) - EOPProtectionPolicyRule = @() + ATPProtectionPolicyRule = @() SafeLinksRule = @( [pscustomobject]@{ State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'All recipients' @@ -122,7 +123,7 @@ Describe 'CISA Security Suite Safe Links checks' { ScanUrls = $false; DeliverMessageAfterScan = $false; TrackClicks = $false } ) - EOPProtectionPolicyRule = @( + ATPProtectionPolicyRule = @( [pscustomobject]@{ Identity = 'Strict Preset Security Policy'; State = 'Enabled' SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() @@ -136,6 +137,44 @@ Describe 'CISA Security Suite Safe Links checks' { Test-MtCisaSafeLinkClickTracking | Should -BeTrue } + It 'uses the Defender preset rule scope rather than the EOP preset rule scope' { + $script:exoResponses = @{ + SafeLinksPolicy = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; RecommendedPolicyType = 'Strict' + ScanUrls = $true; DeliverMessageAfterScan = $true; TrackClicks = $true + }, + [pscustomobject]@{ + Identity = 'All recipients'; Name = 'All recipients' + ScanUrls = $false; DeliverMessageAfterScan = $false; TrackClicks = $false + } + ) + ATPProtectionPolicyRule = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; State = 'Enabled' + SentTo = @('user@contoso.com'); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + EOPProtectionPolicyRule = @( + [pscustomobject]@{ + Identity = 'Strict Preset Security Policy'; State = 'Enabled' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + SafeLinksRule = @( + [pscustomobject]@{ + State = 'Enabled'; Priority = 1; SafeLinksPolicy = 'All recipients' + SentTo = @(); SentToMemberOf = @(); RecipientDomainIs = @() + } + ) + } + Mock Get-MtExo { $script:exoResponses[$Request] } + + (Get-MtCisaEffectiveSafeLinksPolicy).Policy.Identity | Should -Be 'All recipients' + Test-MtCisaSafeLinkDownloadScan | Should -BeFalse + Test-MtCisaSafeLinkClickTracking | Should -BeFalse + } + It 'fails Safe List compliance if any returned connection filter enables it' { $script:exoResponses = @{ HostedConnectionFilterPolicy = @( @@ -157,4 +196,11 @@ Describe 'CISA Security Suite Safe Links checks' { Test-MtCisaAntiSpamSafeList | Should -BeFalse } + + It 'does not pass IP allow-list compliance when no connection filter policy is returned' { + $script:exoResponses = @{ HostedConnectionFilterPolicy = @() } + Mock Get-MtExo { $script:exoResponses[$Request] } + + Test-MtCisaAntiSpamAllowList | Should -BeFalse + } } diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 index 887fda2743..e35f9ba32f 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 @@ -57,7 +57,7 @@ if ($testResult) { $message = "Well done. The effective all-recipient Safe Links policy enables URL protection for email, Teams, Office documents, and internal senders.`n`n%TestResult%" } else { - $message = 'Enable Safe Links and internal-sender protection on the effective all-recipient policy. A preset policy applies only when its all-recipient preset rule is enabled; otherwise the highest-priority all-recipient custom rule applies.`n`n%TestResult%' + $message = "Enable Safe Links and internal-sender protection on the effective all-recipient policy. A preset policy applies only when its all-recipient preset rule is enabled; otherwise the highest-priority all-recipient custom rule applies.`n`n%TestResult%" } Add-MtTestResultDetail -Result ($message -replace '%TestResult%', $result) diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 index edd6646932..609585281b 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 @@ -1,7 +1,7 @@ function Test-MtCisaSafeLinkClickTracking { <# .SYNOPSIS - Checks state of URL direct download scans + Checks whether user click tracking is enabled on the effective all-recipient Safe Links policy. .DESCRIPTION User click tracking SHOULD be enabled. @@ -9,7 +9,7 @@ .EXAMPLE Test-MtCisaSafeLinkClickTracking - Returns true if URL direct download scan enabled + Returns true if user click tracking is enabled on the effective all-recipient Safe Links policy. .LINK https://maester.dev/docs/commands/Test-MtCisaSafeLinkClickTracking diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 index 90802289d5..ef4d1218ca 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 @@ -35,18 +35,20 @@ [OutputType([bool])] param() - $policy = Get-MtExo -Request HostedConnectionFilterPolicy + $policies = @(Get-MtExo -Request HostedConnectionFilterPolicy) - $resultPolicy = $policy | Where-Object {` + $resultPolicy = @($policies | Where-Object {` ($_.IPAllowList | Measure-Object).Count -gt 0 - } + }) - $testResult = ($resultPolicy | Measure-Object).Count -eq 0 + $testResult = $policies.Count -gt 0 -and $resultPolicy.Count -eq 0 $portalLink = "https://security.microsoft.com/antispam" if ($testResult) { $testResultMarkdown = "Well done. Your tenant does not have any [Anti-spam IP allow lists]($portalLink)." + } elseif ($policies.Count -eq 0) { + $testResultMarkdown = "No connection filter policy was returned. Verify the connection to Exchange Online and confirm that the policy data is available." } else { $testResultMarkdown = "Your tenant has [Anti-spam IP allow lists]($portalLink).`n`n%TestResult%" $resultPolicy | ForEach-Object { From b7875f6167ac02b75b5a6335298c0df91bd9f684 Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Wed, 11 Nov 2026 10:02:33 +1300 Subject: [PATCH 4/7] fix(build): read native test metadata from param block Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build/golden/Export-MtLegacyIdTable.ps1 | 6 ++++-- powershell/assets/Maester.LegacyIds.json | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/build/golden/Export-MtLegacyIdTable.ps1 b/build/golden/Export-MtLegacyIdTable.ps1 index e4dc1f5395..fd2ea48f3c 100644 --- a/build/golden/Export-MtLegacyIdTable.ps1 +++ b/build/golden/Export-MtLegacyIdTable.ps1 @@ -281,12 +281,14 @@ foreach ($nativeFile in (Get-ChildItem -Path (Join-Path $RepoRoot 'tests') -Recu $testFunction = $nativeAst.Find({ param($node) $node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and - @($node.Attributes | Where-Object { $_.TypeName.FullName -eq 'MaesterTest' }).Count -gt 0 + @($node.Body.ParamBlock.Attributes | Where-Object { $_.TypeName.FullName -eq 'MaesterTest' }).Count -gt 0 }, $true) | Select-Object -First 1 $title = '' $functions = @() if ($testFunction) { - $testAttribute = $testFunction.Attributes | Where-Object { $_.TypeName.FullName -eq 'MaesterTest' } | Select-Object -First 1 + $testAttribute = $testFunction.Body.ParamBlock.Attributes | + Where-Object { $_.TypeName.FullName -eq 'MaesterTest' } | + Select-Object -First 1 $titleArgument = $testAttribute.NamedArguments | Where-Object { $_.ArgumentName -eq 'Title' } | Select-Object -First 1 if (-not $titleArgument -or $titleArgument.Argument -isnot [System.Management.Automation.Language.StringConstantExpressionAst]) { throw "Native test '$($nativeFile.FullName)' has no constant Title in its MaesterTest attribute." diff --git a/powershell/assets/Maester.LegacyIds.json b/powershell/assets/Maester.LegacyIds.json index 479def63f9..18e36b8213 100644 --- a/powershell/assets/Maester.LegacyIds.json +++ b/powershell/assets/Maester.LegacyIds.json @@ -1132,40 +1132,40 @@ }, { "LegacyId": "CISA.MS.EXO.12.1", - "CurrentId": "retired", - "Rule": "retired", + "CurrentId": "CISA.MS.SECURITYSUITE.8.1", + "Rule": "title", "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamAllowList.Tests.ps1" }, { "LegacyId": "CISA.MS.EXO.12.2", - "CurrentId": "retired", - "Rule": "retired", + "CurrentId": "CISA.MS.SECURITYSUITE.8.2", + "Rule": "title", "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaAntiSpamSafeList.Tests.ps1" }, { "LegacyId": "CISA.MS.EXO.15.1", - "CurrentId": "retired", - "Rule": "retired", + "CurrentId": "CISA.MS.SECURITYSUITE.7.1", + "Rule": "function", "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLink.Tests.ps1" }, { "LegacyId": "CISA.MS.EXO.15.2", - "CurrentId": "retired", - "Rule": "retired", + "CurrentId": "CISA.MS.SECURITYSUITE.7.2", + "Rule": "title", "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkDownloadScan.Tests.ps1" }, { "LegacyId": "CISA.MS.EXO.15.3", - "CurrentId": "retired", - "Rule": "retired", + "CurrentId": "CISA.MS.SECURITYSUITE.7.3", + "Rule": "title", "FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9", "LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca", "LastSeenFile": "tests/cisa/exchange/Test-MtCisaSafeLinkClickTracking.Tests.ps1" From 8bc466796d63fef6dbc5c63c6faa7d55e76dbf08 Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Wed, 11 Nov 2026 12:52:42 +1300 Subject: [PATCH 5/7] Correct CISA Security Suite test authorship --- tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 | 2 +- tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 | 2 +- tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 | 2 +- tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 | 2 +- tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 index e35f9ba32f..460eadec28 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = 'thomas-s-schmidt' + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 index f8a89fe9a5..025fb013ad 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = 'thomas-s-schmidt' + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 index 609585281b..550bffac37 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = 'thomas-s-schmidt' + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 index ef4d1218ca..f43ddae109 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 @@ -29,7 +29,7 @@ Control = 'cisa-scuba:MS.SECURITYSUITE.8.1', Service = 'ExchangeOnline', Author = 'soulemike', - Contributor = 'merill' + Contributor = ('merill', 'JeremyFinney-lgtm') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 index 757ee4cab7..0a33dae351 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 @@ -29,7 +29,7 @@ Control = 'cisa-scuba:MS.SECURITYSUITE.8.2', Service = 'ExchangeOnline', Author = 'soulemike', - Contributor = 'merill' + Contributor = ('merill', 'JeremyFinney-lgtm') )] [CmdletBinding()] [OutputType([bool])] From 584789b46a59042c0748aed5559677fb9fd2e625 Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Fri, 13 Nov 2026 08:50:33 +1300 Subject: [PATCH 6/7] fix(cisa): preserve legacy selection after Security Suite migration Discover current Pester IDs from the working tree while retaining historical family suppression. Refresh legacy tag and golden selections for the five migrated controls, restore the Safe Links helper BOM, and credit earbona23 for identifying the CI regressions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- build/golden/Export-MtLegacyIdTable.ps1 | 14 ++-- build/golden/Export-MtLegacyTagTable.ps1 | 5 ++ build/golden/README.md | 11 ++- powershell/assets/Maester.LegacyTags.json | 62 +++++++++++----- .../Get-MtCisaEffectiveSafeLinksPolicy.ps1 | 2 +- .../tests/fixtures/golden/selection.json | 70 +++++++++---------- .../tests/functions/golden/Golden.Tests.ps1 | 9 ++- powershell/tests/general/LegacyIds.Tests.ps1 | 56 +++++++++++++++ .../Test.CISA.MS.SECURITYSUITE.7.1.ps1 | 2 +- .../Test.CISA.MS.SECURITYSUITE.7.2.ps1 | 2 +- .../Test.CISA.MS.SECURITYSUITE.7.3.ps1 | 2 +- .../Test.CISA.MS.SECURITYSUITE.8.1.ps1 | 2 +- .../Test.CISA.MS.SECURITYSUITE.8.2.ps1 | 2 +- 13 files changed, 172 insertions(+), 67 deletions(-) diff --git a/build/golden/Export-MtLegacyIdTable.ps1 b/build/golden/Export-MtLegacyIdTable.ps1 index fd2ea48f3c..46b6a77f6d 100644 --- a/build/golden/Export-MtLegacyIdTable.ps1 +++ b/build/golden/Export-MtLegacyIdTable.ps1 @@ -254,12 +254,11 @@ foreach ($commit in $commits) { #region Current IDs $currentIds = [System.Collections.Generic.Dictionary[string, object]]::new([System.StringComparer]::OrdinalIgnoreCase) $familyPrefixes = [System.Collections.Generic.SortedSet[string]]::new([System.StringComparer]::Ordinal) -$treeLines = Invoke-Git ls-tree -r $generatedFrom -- tests -foreach ($line in $treeLines) { - if ($line -notmatch '^\d+ blob ([0-9a-f]{40})\t(tests/.+\.tests\.ps1)$') { continue } - if ($Matches[2] -like 'tests/Custom/*') { continue } - $path = $Matches[2] - foreach ($it in (Get-BlobItInfo -Blob $Matches[1])) { +$pesterFiles = Get-ChildItem -Path (Join-Path $RepoRoot 'tests') -Recurse -File -Filter '*.Tests.ps1' +foreach ($pesterFile in $pesterFiles) { + $path = [System.IO.Path]::GetRelativePath($RepoRoot, $pesterFile.FullName).Replace('\', '/') + if ($path -like 'tests/Custom/*') { continue } + foreach ($it in (Get-ItInfo -Content (Get-Content -LiteralPath $pesterFile.FullName -Raw))) { $split = Get-StaticSplit -Name $it.Name if (-not $split) { if ($it.Name -match '^([A-Za-z]+\.?\d+)\.(<|\$\()') { $null = $familyPrefixes.Add("$($Matches[1]).") } @@ -408,6 +407,9 @@ if ($retiredFamilies) { Write-Warning "Historical family prefixes no longer at H foreach ($line in ($review | Sort-Object)) { Write-Verbose "REVIEW $line" } #endregion Report +# Stale family wrappers must still be suppressed after their Pester sources are removed. +$familyPrefixes.UnionWith($historicalFamilies) + $document = [ordered]@{ SchemaVersion = '1.0' GeneratedFrom = $generatedFrom diff --git a/build/golden/Export-MtLegacyTagTable.ps1 b/build/golden/Export-MtLegacyTagTable.ps1 index 33da8e4eff..a6c3a82e93 100644 --- a/build/golden/Export-MtLegacyTagTable.ps1 +++ b/build/golden/Export-MtLegacyTagTable.ps1 @@ -52,6 +52,11 @@ $fixtures = Join-Path $RepoRoot 'powershell/tests/fixtures/golden' # 2.x IDs that have another ID in 3.0. $RenamedIds = @{ 'MT1060' = 'MT.1060' # The drift family: four Its per folder in 2.x, one native family in 3.0. + 'CISA.MS.EXO.12.1' = 'CISA.MS.SECURITYSUITE.8.1' + 'CISA.MS.EXO.12.2' = 'CISA.MS.SECURITYSUITE.8.2' + 'CISA.MS.EXO.15.1' = 'CISA.MS.SECURITYSUITE.7.1' + 'CISA.MS.EXO.15.2' = 'CISA.MS.SECURITYSUITE.7.2' + 'CISA.MS.EXO.15.3' = 'CISA.MS.SECURITYSUITE.7.3' } # The typed selector that takes the place of a tag. Only tags with an obvious one are listed. diff --git a/build/golden/README.md b/build/golden/README.md index 2ec873cc51..4b1f1fee09 100644 --- a/build/golden/README.md +++ b/build/golden/README.md @@ -20,8 +20,11 @@ Regenerate it after a change to `tests/` that renames or removes a check: otherwise `retired`. - `-Verbose` prints counts by rule and a `REVIEW` line for each ambiguous, conflicting or title-only match. Resolve ambiguous ones by adding them to `$ManualOverrides`. -- `GeneratedFrom` is the last commit that touched the scanned test files, so the - output only changes when `tests/` changes. +- `GeneratedFrom` is the last commit that touched the scanned legacy test files. + Current IDs come from the working tree's Pester and native tests, so removed + wrappers cannot keep retired tests marked as current. +- Historical family prefixes are retained after their Pester wrappers are removed, + so stale copies of those wrappers remain suppressed. - `powershell/tests/general/LegacyIds.Tests.ps1` checks that no legacy ID is a current ID and that every target ID still exists. If it fails after you rename or remove a check, regenerate the table. @@ -35,7 +38,7 @@ uses this table to keep `-Tag CA`, `-ExcludeTag MS.AAD.3.5` and every other 2.x selecting the tests it selected. The tags are used for selection only and are never written to a result row. -The table is derived from two frozen files, so it does not change when `tests/` changes: +The table is derived from two frozen files and the generator's explicit ID renames: - `powershell/tests/fixtures/golden/tags-and-blocks.json`, the 2.x snapshot; - `powershell/tests/fixtures/golden/tags-3.0-preview.json`, the tags the 3.0 previews added. @@ -47,6 +50,8 @@ The table is derived from two frozen files, so it does not change when `tests/` - A tag that is the ID of the one test that carried it is left out: the engine always treats a built-in test's own ID as a selection tag. - A 2.x ID that 3.0 renamed is written as its 3.0 ID (`$RenamedIds` in the script). + Update those renames and the corresponding golden-test expectations when a + migrated check changes ID, then regenerate this table and `selection.json`. - `$Replacements` in the script lists the typed selector for the suite, product and topic tags that have one; `Severity:` tags get `-Severity `. - Tests added after 3.0 are not in the table. Do not add them, and do not edit the file diff --git a/powershell/assets/Maester.LegacyTags.json b/powershell/assets/Maester.LegacyTags.json index 2ba8db3c4b..a1d3a7edbe 100644 --- a/powershell/assets/Maester.LegacyTags.json +++ b/powershell/assets/Maester.LegacyTags.json @@ -1167,16 +1167,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -1201,6 +1196,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -1211,6 +1211,36 @@ "CISA.MS.SHAREPOINT.3.3" ] }, + { + "Tag": "CISA.MS.EXO.12.1", + "Tests": [ + "CISA.MS.SECURITYSUITE.8.1" + ] + }, + { + "Tag": "CISA.MS.EXO.12.2", + "Tests": [ + "CISA.MS.SECURITYSUITE.8.2" + ] + }, + { + "Tag": "CISA.MS.EXO.15.1", + "Tests": [ + "CISA.MS.SECURITYSUITE.7.1" + ] + }, + { + "Tag": "CISA.MS.EXO.15.2", + "Tests": [ + "CISA.MS.SECURITYSUITE.7.2" + ] + }, + { + "Tag": "CISA.MS.EXO.15.3", + "Tests": [ + "CISA.MS.SECURITYSUITE.7.3" + ] + }, { "Tag": "CopilotStudio", "Replacement": "-Product copilot-studio", @@ -2158,16 +2188,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -2191,7 +2216,12 @@ "CISA.MS.EXO.9.2", "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", - "CISA.MS.EXO.9.5" + "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2" ] }, { @@ -2239,13 +2269,13 @@ { "Tag": "MS.EXO.12.1", "Tests": [ - "CISA.MS.EXO.12.1" + "CISA.MS.SECURITYSUITE.8.1" ] }, { "Tag": "MS.EXO.12.2", "Tests": [ - "CISA.MS.EXO.12.2" + "CISA.MS.SECURITYSUITE.8.2" ] }, { @@ -2281,19 +2311,19 @@ { "Tag": "MS.EXO.15.1", "Tests": [ - "CISA.MS.EXO.15.1" + "CISA.MS.SECURITYSUITE.7.1" ] }, { "Tag": "MS.EXO.15.2", "Tests": [ - "CISA.MS.EXO.15.2" + "CISA.MS.SECURITYSUITE.7.2" ] }, { "Tag": "MS.EXO.15.3", "Tests": [ - "CISA.MS.EXO.15.3" + "CISA.MS.SECURITYSUITE.7.3" ] }, { diff --git a/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 index e520434206..a87a7841af 100644 --- a/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 +++ b/powershell/internal/checks/cisa/exchange/Get-MtCisaEffectiveSafeLinksPolicy.ps1 @@ -1,4 +1,4 @@ -function Get-MtCisaEffectiveSafeLinksPolicy { +function Get-MtCisaEffectiveSafeLinksPolicy { [CmdletBinding()] [OutputType([object])] param() diff --git a/powershell/tests/fixtures/golden/selection.json b/powershell/tests/fixtures/golden/selection.json index ae970e7cfd..2c3883b9f8 100644 --- a/powershell/tests/fixtures/golden/selection.json +++ b/powershell/tests/fixtures/golden/selection.json @@ -272,16 +272,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -306,6 +301,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -1022,16 +1022,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -1056,6 +1051,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -1584,16 +1584,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -1618,6 +1613,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -2203,16 +2203,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -2237,6 +2232,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -2836,16 +2836,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -2870,6 +2865,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -3692,16 +3692,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -3726,6 +3721,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", @@ -4261,16 +4261,11 @@ "CISA.MS.EXO.11.1", "CISA.MS.EXO.11.2", "CISA.MS.EXO.11.3", - "CISA.MS.EXO.12.1", - "CISA.MS.EXO.12.2", "CISA.MS.EXO.13.1", "CISA.MS.EXO.14.1", "CISA.MS.EXO.14.2", "CISA.MS.EXO.14.3", "CISA.MS.EXO.14.4", - "CISA.MS.EXO.15.1", - "CISA.MS.EXO.15.2", - "CISA.MS.EXO.15.3", "CISA.MS.EXO.16.1", "CISA.MS.EXO.16.2", "CISA.MS.EXO.17.1", @@ -4295,6 +4290,11 @@ "CISA.MS.EXO.9.3", "CISA.MS.EXO.9.4", "CISA.MS.EXO.9.5", + "CISA.MS.SECURITYSUITE.7.1", + "CISA.MS.SECURITYSUITE.7.2", + "CISA.MS.SECURITYSUITE.7.3", + "CISA.MS.SECURITYSUITE.8.1", + "CISA.MS.SECURITYSUITE.8.2", "CISA.MS.SHAREPOINT.1.1", "CISA.MS.SHAREPOINT.1.2", "CISA.MS.SHAREPOINT.1.3", diff --git a/powershell/tests/functions/golden/Golden.Tests.ps1 b/powershell/tests/functions/golden/Golden.Tests.ps1 index 744d5aebe5..2404a4d536 100644 --- a/powershell/tests/functions/golden/Golden.Tests.ps1 +++ b/powershell/tests/functions/golden/Golden.Tests.ps1 @@ -59,7 +59,14 @@ Describe 'Maester 2.x golden fixtures' -Tag 'Golden' { # more. What must hold is that every 2.x tag still selects exactly the tests it selected: not # fewer, and not more, so a new test must not take a 2.x tag as one of its own tags. # MT1060 (drift) became the native family MT.1060: its four 2.x Its are one test. - $script:renamedIds = @{ 'MT1060' = 'MT.1060' } + $script:renamedIds = @{ + 'MT1060' = 'MT.1060' + 'CISA.MS.EXO.12.1' = 'CISA.MS.SECURITYSUITE.8.1' + 'CISA.MS.EXO.12.2' = 'CISA.MS.SECURITYSUITE.8.2' + 'CISA.MS.EXO.15.1' = 'CISA.MS.SECURITYSUITE.7.1' + 'CISA.MS.EXO.15.2' = 'CISA.MS.SECURITYSUITE.7.2' + 'CISA.MS.EXO.15.3' = 'CISA.MS.SECURITYSUITE.7.3' + } $toSet = { param($entries) $byTag = [System.Collections.Generic.Dictionary[string, System.Collections.Generic.SortedSet[string]]]::new([System.StringComparer]::OrdinalIgnoreCase) diff --git a/powershell/tests/general/LegacyIds.Tests.ps1 b/powershell/tests/general/LegacyIds.Tests.ps1 index 5139755591..c9518d2804 100644 --- a/powershell/tests/general/LegacyIds.Tests.ps1 +++ b/powershell/tests/general/LegacyIds.Tests.ps1 @@ -28,6 +28,7 @@ } else { continue } + $name = ($name -replace '\s+', ' ').Trim() $colon = $name.IndexOf(':') $id = $null @@ -106,3 +107,58 @@ } } } + +Describe 'Export-MtLegacyIdTable current Pester IDs' { + BeforeAll { + $exporter = Join-Path (Resolve-Path "$PSScriptRoot/../../..").Path 'build/golden/Export-MtLegacyIdTable.ps1' + $fixtureRoot = Join-Path $TestDrive 'legacy-id-repo' + $testsRoot = Join-Path $fixtureRoot 'tests' + $null = New-Item -Path $testsRoot -ItemType Directory -Force + $fixtureRoot = (Resolve-Path $fixtureRoot).ProviderPath + $historicalFile = Join-Path $testsRoot 'Historical.Tests.ps1' + $outputPath = Join-Path $fixtureRoot 'LegacyIds.json' + @( + "Describe 'Historical checks' {" + " It 'ORCA.100: Retired check' { Test-FixtureRetired }" + " It 'ORCA100: Retired check' { Test-FixtureRetired }" + " It 'Fixture.Legacy: Renamed check' { Test-FixtureRenamed }" + " It 'Fixture100.: Historical family' { Test-FixtureFamily }" + '}' + ) | Set-Content -LiteralPath $historicalFile -Encoding utf8BOM + & git -C $fixtureRoot init --quiet + if ($LASTEXITCODE -ne 0) { throw 'Could not initialize the legacy-ID fixture repository.' } + & git -C $fixtureRoot add -- tests + if ($LASTEXITCODE -ne 0) { throw 'Could not stage the legacy-ID fixture tests.' } + & git -C $fixtureRoot -c user.name=Fixture -c user.email=fixture@example.com -c commit.gpgsign=false commit --quiet -m 'Add historical checks' -m 'Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>' + if ($LASTEXITCODE -ne 0) { throw 'Could not commit the legacy-ID fixture tests.' } + Remove-Item -LiteralPath $historicalFile + "Describe 'Current checks' { It 'Fixture.Current: Renamed check' { Test-FixtureRenamed } }" | + Set-Content -LiteralPath (Join-Path $testsRoot 'Current.Tests.ps1') -Encoding utf8BOM + '{"Entries":[{"LegacyId":"ORCA100","CurrentId":"ORCA.100","Rule":"function"}]}' | + Set-Content -LiteralPath $outputPath -Encoding utf8 + + & $exporter -RepoRoot $fixtureRoot -OutputPath $outputPath -WarningAction SilentlyContinue + $script:fixtureTable = Get-Content -LiteralPath $outputPath -Raw | ConvertFrom-Json + $script:fixtureEntries = $script:fixtureTable.Entries + } + + It 'retires removed Pester IDs instead of retaining a mapping to a removed check' { + @($script:fixtureEntries | Where-Object { $_.LegacyId -in 'ORCA.100', 'ORCA100' }).Count | Should -Be 2 + foreach ($id in 'ORCA.100', 'ORCA100') { + $entry = $script:fixtureEntries | Where-Object { $_.LegacyId -eq $id } + $entry.CurrentId | Should -Be 'retired' + $entry.Rule | Should -Be 'retired' + } + } + + It 'maps historical IDs to the current working-tree Pester check' { + $entry = $script:fixtureEntries | Where-Object { $_.LegacyId -eq 'Fixture.Legacy' } + $entry.CurrentId | Should -Be 'Fixture.Current' + $entry.Rule | Should -Be 'title' + @($script:fixtureEntries | Where-Object { $_.LegacyId -eq 'Fixture.Current' }) | Should -BeNullOrEmpty + } + + It 'preserves historical family prefixes after their Pester wrappers are removed' { + $script:fixtureTable.FamilyPrefixes | Should -Contain 'Fixture100.' + } +} diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 index 460eadec28..6676990ded 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.1.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm', 'earbona23') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 index 025fb013ad..d27cee5398 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.2.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm', 'earbona23') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 index 550bffac37..2279080df0 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.7.3.ps1 @@ -30,7 +30,7 @@ Service = ('ExchangeOnline', 'Graph'), License = 'ATP_ENTERPRISE', Author = 'soulemike', - Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm') + Contributor = ('thomas-s-schmidt', 'JeremyFinney-lgtm', 'earbona23') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 index f43ddae109..7860f972d1 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.1.ps1 @@ -29,7 +29,7 @@ Control = 'cisa-scuba:MS.SECURITYSUITE.8.1', Service = 'ExchangeOnline', Author = 'soulemike', - Contributor = ('merill', 'JeremyFinney-lgtm') + Contributor = ('merill', 'JeremyFinney-lgtm', 'earbona23') )] [CmdletBinding()] [OutputType([bool])] diff --git a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 index 0a33dae351..bce22795a4 100644 --- a/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 +++ b/tests/cisa/exchange/Test.CISA.MS.SECURITYSUITE.8.2.ps1 @@ -29,7 +29,7 @@ Control = 'cisa-scuba:MS.SECURITYSUITE.8.2', Service = 'ExchangeOnline', Author = 'soulemike', - Contributor = ('merill', 'JeremyFinney-lgtm') + Contributor = ('merill', 'JeremyFinney-lgtm', 'earbona23') )] [CmdletBinding()] [OutputType([bool])] From e56e19dc0dc09382ae34ce9d022a3a7f8ca766f5 Mon Sep 17 00:00:00 2001 From: Jeremy Finney Date: Sat, 14 Nov 2026 07:31:18 +1300 Subject: [PATCH 7/7] Regenerate CISA test-builder data Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- website/src/data/test-builder.json | 225 +++++++++++++++++++++++++++-- 1 file changed, 210 insertions(+), 15 deletions(-) diff --git a/website/src/data/test-builder.json b/website/src/data/test-builder.json index 2b025d35ea..b32d4c017f 100644 --- a/website/src/data/test-builder.json +++ b/website/src/data/test-builder.json @@ -8573,9 +8573,7 @@ }, { "id": "MS.EXO.12.1", - "tests": [ - "CISA.MS.EXO.12.1" - ], + "tests": [], "criticality": "SHOULD", "related": [ "nist-800-53-r5:AC-4" @@ -8583,9 +8581,7 @@ }, { "id": "MS.EXO.12.2", - "tests": [ - "CISA.MS.EXO.12.2" - ], + "tests": [], "criticality": "SHOULD", "related": [ "nist-800-53-r5:AC-4" @@ -8640,9 +8636,7 @@ }, { "id": "MS.EXO.15.1", - "tests": [ - "CISA.MS.EXO.15.1" - ], + "tests": [], "criticality": "SHOULD", "related": [ "nist-800-53-r5:SI-3" @@ -8650,9 +8644,7 @@ }, { "id": "MS.EXO.15.2", - "tests": [ - "CISA.MS.EXO.15.2" - ], + "tests": [], "criticality": "SHOULD", "related": [ "nist-800-53-r5:SI-3" @@ -8660,9 +8652,7 @@ }, { "id": "MS.EXO.15.3", - "tests": [ - "CISA.MS.EXO.15.3" - ], + "tests": [], "criticality": "SHOULD", "related": [ "nist-800-53-r5:SI-3", @@ -8716,6 +8706,211 @@ "nist-800-53-r5:AU-11" ] }, + { + "id": "MS.SECURITYSUITE.1.1", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.1.2", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.1.3", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.1.4", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.2.1", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.2.2", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.2.3", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.2.4", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AT-2b", + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.3.1", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SC-7(10)" + ] + }, + { + "id": "MS.SECURITYSUITE.3.2", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SC-7(10)" + ] + }, + { + "id": "MS.SECURITYSUITE.3.3", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AC-3", + "nist-800-53-r5:SC-7(10)" + ] + }, + { + "id": "MS.SECURITYSUITE.3.4", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AT-2b" + ] + }, + { + "id": "MS.SECURITYSUITE.3.5", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AC-19a" + ] + }, + { + "id": "MS.SECURITYSUITE.4.1", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-4(5)" + ] + }, + { + "id": "MS.SECURITYSUITE.4.2", + "tests": [], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-4(5)" + ] + }, + { + "id": "MS.SECURITYSUITE.5.1", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:AU-12" + ] + }, + { + "id": "MS.SECURITYSUITE.5.2", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:AU-11" + ] + }, + { + "id": "MS.SECURITYSUITE.6.1", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.6.2", + "tests": [], + "criticality": "SHALL", + "related": [ + "nist-800-53-r5:SI-8" + ] + }, + { + "id": "MS.SECURITYSUITE.7.1", + "tests": [ + "CISA.MS.SECURITYSUITE.7.1" + ], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.7.2", + "tests": [ + "CISA.MS.SECURITYSUITE.7.2" + ], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-3" + ] + }, + { + "id": "MS.SECURITYSUITE.7.3", + "tests": [ + "CISA.MS.SECURITYSUITE.7.3" + ], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:SI-3", + "nist-800-53-r5:AU-12c" + ] + }, + { + "id": "MS.SECURITYSUITE.8.1", + "tests": [ + "CISA.MS.SECURITYSUITE.8.1" + ], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AC-4" + ] + }, + { + "id": "MS.SECURITYSUITE.8.2", + "tests": [ + "CISA.MS.SECURITYSUITE.8.2" + ], + "criticality": "SHOULD", + "related": [ + "nist-800-53-r5:AC-4" + ] + }, { "id": "MS.SHAREPOINT.1.1", "tests": [