Skip to content
56 changes: 53 additions & 3 deletions build/golden/Export-MtLegacyIdTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
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.
GeneratedFrom is the last commit that touched the scanned Pester test files. Current native test IDs,
titles and function names are read from the working tree so legacy checks can map to their native replacements.

.EXAMPLE
./build/golden/Export-MtLegacyIdTable.ps1
Expand Down Expand Up @@ -55,6 +54,21 @@ $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'
# CISA moved the email malware checks to the Security Suite baseline.
'CISA.MS.EXO.09.5' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.9.5' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.10.3' = 'CISA.MS.SECURITYSUITE.1.2'
'CISA.MS.EXO.9.1' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.9.3' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.10.1' = 'CISA.MS.SECURITYSUITE.1.3'
'CISA.MS.EXO.10.2' = 'CISA.MS.SECURITYSUITE.1.3'
'MS.EXO.09.5' = 'CISA.MS.SECURITYSUITE.1.1'
'MS.EXO.9.5' = 'CISA.MS.SECURITYSUITE.1.1'
'MS.EXO.10.3' = 'CISA.MS.SECURITYSUITE.1.2'
'MS.EXO.9.1' = 'CISA.MS.SECURITYSUITE.1.1'
'MS.EXO.9.3' = 'CISA.MS.SECURITYSUITE.1.1'
'MS.EXO.10.1' = 'CISA.MS.SECURITYSUITE.1.3'
'MS.EXO.10.2' = 'CISA.MS.SECURITYSUITE.1.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'
Expand Down Expand Up @@ -263,6 +277,42 @@ foreach ($line in $treeLines) {
}
Write-Verbose "Current static IDs: $($currentIds.Count); family prefixes: $($familyPrefixes -join ', ')"

# Native tests are current checks after migration from the Pester format.
$nativeTestFiles = Get-ChildItem -Path (Join-Path $RepoRoot 'tests') -Recurse -File -Filter 'Test.*.ps1' |
Where-Object { $_.FullName -notmatch '[\\/]Custom[\\/]' }
foreach ($file in $nativeTestFiles) {
$tokens = $null
$parseErrors = $null
$ast = [System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref]$tokens, [ref]$parseErrors)
if ($parseErrors.Count -gt 0) {
throw "Cannot parse native test '$($file.FullName)': $($parseErrors[0].Message)"
}

$function = $ast.FindAll({
param($node)
$node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and
$node.Body.ParamBlock -and
($node.Body.ParamBlock.Attributes | Where-Object { $_.TypeName.Name -in 'MaesterTest', 'MaesterTestAttribute' })
}, $true) | Select-Object -First 1
if (-not $function) {
throw "Native test '$($file.FullName)' has no MaesterTest attribute."
}

$attribute = $function.Body.ParamBlock.Attributes | Where-Object { $_.TypeName.Name -in 'MaesterTest', 'MaesterTestAttribute' } | Select-Object -First 1
$id = $file.BaseName.Substring('Test.'.Length)
$title = $attribute.NamedArguments | Where-Object { $_.ArgumentName -eq 'Title' } | Select-Object -First 1
if (-not $title -or $title.Argument -isnot [System.Management.Automation.Language.StringConstantExpressionAst]) {
throw "Native test '$($file.FullName)' has no static title."
}

$currentIds[$id] = [pscustomobject]@{
Id = $id
Title = Get-NormalizedTitle $title.Argument.Value
Functions = @($function.Name)
Path = $file.FullName.Substring($RepoRoot.Length + 1).Replace('\', '/')
}
}

$titleIndex = @{}
$functionIndex = @{}
foreach ($c in $currentIds.Values) {
Expand Down
8 changes: 7 additions & 1 deletion build/golden/Export-MtLegacyTagTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ $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.
'MT1060' = 'MT.1060' # The drift family: four Its per folder in 2.x, one native family in 3.0.
'CISA.MS.EXO.9.1' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.9.3' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.9.5' = 'CISA.MS.SECURITYSUITE.1.1'
'CISA.MS.EXO.10.1' = 'CISA.MS.SECURITYSUITE.1.3'
'CISA.MS.EXO.10.2' = 'CISA.MS.SECURITYSUITE.1.3'
'CISA.MS.EXO.10.3' = 'CISA.MS.SECURITYSUITE.1.2'
}

# The typed selector that takes the place of a tag. Only tags with an obvious one are listed.
Expand Down
126 changes: 87 additions & 39 deletions powershell/assets/Maester.LegacyIds.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"SchemaVersion": "1.0",
"GeneratedFrom": "fc6a9078bcdd59b5b2f788682fdcd2be27e15b9c",
"GeneratedFrom": "eb13e7a116e4063bec204e901e4847ae67c1f6f6",
"Entries": [
{
"LegacyId": "1.1.1 (L1) Ensure Administrative accounts are cloud-only",
Expand Down Expand Up @@ -29,15 +29,15 @@
{
"LegacyId": "2.1.3 (L1) Ensure notifications for internal users sending malware is Enabled",
"CurrentId": "CIS.M365.2.1.3",
"Rule": "function",
"Rule": "title",
"FirstSeenCommit": "6e0a967fc7e6c2ba3d711ae650b49402f145f624",
"LastSeenCommit": "6e0a967fc7e6c2ba3d711ae650b49402f145f624",
"LastSeenFile": "tests/cis/Test-MtCisInternalMalwareNotification.Tests.ps1"
},
{
"LegacyId": "2.1.3 (L1) Ensure notifications for internal users sending malware is Enabled (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.3",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenFile": "tests/cis/Test-MtCisInternalMalwareNotification.Tests.ps1"
Expand All @@ -53,7 +53,7 @@
{
"LegacyId": "2.1.4 (L2) Ensure Safe Attachments policy is enabled (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.4",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenFile": "tests/cis/Test-MtCisSafeAttachment.Tests.ps1"
Expand All @@ -69,23 +69,23 @@
{
"LegacyId": "2.1.6 (L1) Ensure Exchange Online Spam Policies are set to notify administrators",
"CurrentId": "CIS.M365.2.1.6",
"Rule": "function",
"Rule": "title",
"FirstSeenCommit": "811ca62ea0cd22285c9393b56acdd3e338ad5f0f",
"LastSeenCommit": "d559e19379a79601c1b0fbe83e21f0e1392ffebe",
"LastSeenFile": "tests/cis/Test-MtCisOutboundSpamFilterPolicy.Tests.ps1"
},
{
"LegacyId": "2.1.6 (L1) Ensure Exchange Online Spam Policies are set to notify administrators (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.6",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenCommit": "7e35b57b0f8c01aedc4a29d057a810830a98d873",
"LastSeenFile": "tests/cis/Test-MtCisOutboundSpamFilterPolicy.Tests.ps1"
},
{
"LegacyId": "2.1.7 (L1) Ensure that an anti-phishing policy has been created (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.7",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "2487d220155d59d0a35da593584baf23d58bdf41",
"LastSeenCommit": "2487d220155d59d0a35da593584baf23d58bdf41",
"LastSeenFile": "tests/cis/Test-MtCisSafeAntiPhishingPolicy.Tests.ps1"
Expand Down Expand Up @@ -957,15 +957,15 @@
{
"LegacyId": "CIS 2.1.3 (L1) Ensure notifications for internal users sending malware is Enabled (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.3",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "4df9d3e671e648ae838c919e29aa1d03e50474b4",
"LastSeenCommit": "8a08dabc56545cf42ebac9321351463a9f1b121e",
"LastSeenFile": "tests/cis/Test-MtCisInternalMalwareNotification.Tests.ps1"
},
{
"LegacyId": "CIS 2.1.4 (L2) Ensure Safe Attachments policy is enabled (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.4",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "4df9d3e671e648ae838c919e29aa1d03e50474b4",
"LastSeenCommit": "8a08dabc56545cf42ebac9321351463a9f1b121e",
"LastSeenFile": "tests/cis/Test-MtCisSafeAttachment.Tests.ps1"
Expand All @@ -981,15 +981,15 @@
{
"LegacyId": "CIS 2.1.6 (L1) Ensure Exchange Online Spam Policies are set to notify administrators (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.6",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "4df9d3e671e648ae838c919e29aa1d03e50474b4",
"LastSeenCommit": "8a08dabc56545cf42ebac9321351463a9f1b121e",
"LastSeenFile": "tests/cis/Test-MtCisOutboundSpamFilterPolicy.Tests.ps1"
},
{
"LegacyId": "CIS 2.1.7 (L1) Ensure that an anti-phishing policy has been created (Only Checks Default Policy)",
"CurrentId": "CIS.M365.2.1.7",
"Rule": "title",
"Rule": "function",
"FirstSeenCommit": "4df9d3e671e648ae838c919e29aa1d03e50474b4",
"LastSeenCommit": "8a08dabc56545cf42ebac9321351463a9f1b121e",
"LastSeenFile": "tests/cis/Test-MtCisSafeAntiPhishingPolicy.Tests.ps1"
Expand Down Expand Up @@ -1116,20 +1116,68 @@
},
{
"LegacyId": "CISA.MS.EXO.09.3",
"CurrentId": "CISA.MS.EXO.9.3",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "5810a0dc37538fe0c4884f55938f23f5c7d1d6cc",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockFileType.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.09.5",
"CurrentId": "CISA.MS.EXO.9.5",
"Rule": "title",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "5810a0dc37538fe0c4884f55938f23f5c7d1d6cc",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockExecutable.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.10.1",
"CurrentId": "CISA.MS.SECURITYSUITE.1.3",
"Rule": "manual",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareScan.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.10.2",
"CurrentId": "CISA.MS.SECURITYSUITE.1.3",
"Rule": "manual",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareAction.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.10.3",
"CurrentId": "CISA.MS.SECURITYSUITE.1.2",
"Rule": "manual",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareZap.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.9.1",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "d176a815b8cfef203cfe0672af5bc092385f05b9",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaAttachmentFilter.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.9.3",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "b2513b049671c82eede6415f708bb3560e6a8d06",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockFileType.Tests.ps1"
},
{
"LegacyId": "CISA.MS.EXO.9.5",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "b2513b049671c82eede6415f708bb3560e6a8d06",
"LastSeenCommit": "eb38f4357cdf3576600aeca7d8da3138f77a37ca",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockExecutable.Tests.ps1"
},
{
"LegacyId": "Configure which users are allowed to present in Teams meetings",
"CurrentId": "retired",
Expand All @@ -1140,8 +1188,8 @@
},
{
"LegacyId": "Ensure MailTips are enabled for end users",
"CurrentId": "MT.1039",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenFile": "tests/Maester/Exchange/Test-ExchangeSetting.Tests.ps1"
Expand Down Expand Up @@ -1188,8 +1236,8 @@
},
{
"LegacyId": "Ensure modern authentication for Exchange Online is enabled",
"CurrentId": "MT.1044",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenFile": "tests/Maester/Exchange/Test-ExchangeSetting.Tests.ps1"
Expand All @@ -1204,8 +1252,8 @@
},
{
"LegacyId": "Ensure users installing Outlook add-ins is not allowed",
"CurrentId": "MT.1041",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenCommit": "7cd563adfc02cdecb49b1b5e755f5c541bdd4beb",
"LastSeenFile": "tests/Maester/Exchange/Test-ExchangeSetting.Tests.ps1"
Expand Down Expand Up @@ -1796,8 +1844,8 @@
},
{
"LegacyId": "MS.EXO.09.1",
"CurrentId": "CISA.MS.EXO.9.1",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaAttachmentFilter.Tests.ps1"
Expand All @@ -1812,8 +1860,8 @@
},
{
"LegacyId": "MS.EXO.09.3",
"CurrentId": "CISA.MS.EXO.9.3",
"Rule": "title",
"CurrentId": "retired",
"Rule": "retired",
"FirstSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockFileType.Tests.ps1"
Expand All @@ -1828,8 +1876,8 @@
},
{
"LegacyId": "MS.EXO.09.5",
"CurrentId": "CISA.MS.EXO.9.5",
"Rule": "title",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenCommit": "062c1e6a1e0566789256aaea1e37b73dcdb11aed",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockExecutable.Tests.ps1"
Expand All @@ -1844,24 +1892,24 @@
},
{
"LegacyId": "MS.EXO.10.1",
"CurrentId": "CISA.MS.EXO.10.1",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.3",
"Rule": "manual",
"FirstSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareScan.Tests.ps1"
},
{
"LegacyId": "MS.EXO.10.2",
"CurrentId": "CISA.MS.EXO.10.2",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.3",
"Rule": "manual",
"FirstSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareAction.Tests.ps1"
},
{
"LegacyId": "MS.EXO.10.3",
"CurrentId": "CISA.MS.EXO.10.3",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.2",
"Rule": "manual",
"FirstSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaMalwareZap.Tests.ps1"
Expand Down Expand Up @@ -2124,8 +2172,8 @@
},
{
"LegacyId": "MS.EXO.9.1",
"CurrentId": "CISA.MS.EXO.9.1",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "9b5657a0506757ef2c2be95b93c115a921491522",
"LastSeenCommit": "1e22bb9c04dc04785d4a813e270b5359d71c6338",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaAttachmentFilter.Tests.ps1"
Expand All @@ -2140,8 +2188,8 @@
},
{
"LegacyId": "MS.EXO.9.3",
"CurrentId": "CISA.MS.EXO.9.3",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "9b5657a0506757ef2c2be95b93c115a921491522",
"LastSeenCommit": "e6db16c50cb93a790370609162c683a5d1338928",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockFileType.Tests.ps1"
Expand All @@ -2156,8 +2204,8 @@
},
{
"LegacyId": "MS.EXO.9.5",
"CurrentId": "CISA.MS.EXO.9.5",
"Rule": "prefix",
"CurrentId": "CISA.MS.SECURITYSUITE.1.1",
"Rule": "manual",
"FirstSeenCommit": "9b5657a0506757ef2c2be95b93c115a921491522",
"LastSeenCommit": "e6db16c50cb93a790370609162c683a5d1338928",
"LastSeenFile": "tests/cisa/exchange/Test-MtCisaBlockExecutable.Tests.ps1"
Expand Down
Loading
Loading