From 9e61ea00b418146512aee5d5dd57ad6dc6e4acd2 Mon Sep 17 00:00:00 2001 From: Eduard Arbona Date: Fri, 6 Nov 2026 08:43:48 -0400 Subject: [PATCH 01/10] feat(azure): Defender for Cloud recommendations and attack paths (#2514, #2516) Implements #2514 and #2516 under the #2510 epic. They share the Azure Resource Graph plumbing and the securityresources table, so they are one change. - MT.1257 Test-MtAzureDefenderForCloudRecommendation: one result per Defender for Cloud recommendation, following the InstanceSource pattern of MT.1024. Fails when any resource is unhealthy, with the counts, a sample of the unhealthy resources and the portal link. Severity follows the source: the Defender CSPM risk level when present, otherwise the metadata severity. - MT.1258 Test-MtAzureDefenderForCloudAttackPath: one result per attack path type, failing for each reported path, with the entry point's resource type, the target, the risk factors Defender combined and the MITRE tactics. Both declare Lifecycle = 'Preview' and Service = 'Azure', so neither runs in a default Invoke-Maester, and both go through the existing Invoke-MtAzureResourceGraphRequest, so no new permission is introduced. Neither passes on an absent source: - MT.1257 skips a recommendation whose resources are all exempt, reporting the count, because an exemption is a decision already recorded in the portal. It skips as NotApplicable when a recommendation has no healthy and no unhealthy resource, and the instance source emits nothing when there is no assessment at all, so the engine skips the family with NoInstances. - MT.1258 reads the CloudPosture pricing tier to tell "Defender CSPM is off, so no path was ever computed" from "the plan is on and the estate has no path". The first reports not licensed; the second emits no instance. Four field corrections, measured against a live Defender CSPM subscription rather than taken from the issue: - properties.attackPathType is a GUID, not a readable name. The engine requires an instance ID matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, which the display sentence never matches, so the GUID is the instance ID of the path type and the sentence is the title. Grouping by the GUID is also what "one result per attack path type" means. - properties.entryPoint carries entityInternalId, entityType and dataSource and no entity name, so the entry point is reported by its resource type. - properties.target does carry entityName, so the target is named. - properties.riskFactors and properties.mITRETacticsAndTechniques.tactics are arrays, and Azure Resource Graph does not support mv-apply, so they travel as JSON text and are parsed in the helper, tolerating text that is not JSON. Feature is 'subscriptions' because MaesterTaxonomy.psd1 has no 'defender-for-cloud' feature under the azure product. Adding one would fit better and is a one-line change to that asset, left out of this PR since the taxonomy is yours to name. Sixteen unit tests cover both checks, both instance sources and both helpers. --- .../Get-MtDefenderForCloudAttackPath.ps1 | 103 ++++++++ .../Get-MtDefenderForCloudRecommendation.ps1 | 81 ++++++ .../tests/fixtures/golden/selection.json | 12 +- .../Test-MtAzureDefenderForCloud.Tests.ps1 | 250 ++++++++++++++++++ tests/maester/azure/Test.MT.1257.md | 26 ++ tests/maester/azure/Test.MT.1257.ps1 | 160 +++++++++++ tests/maester/azure/Test.MT.1258.md | 34 +++ tests/maester/azure/Test.MT.1258.ps1 | 123 +++++++++ 8 files changed, 786 insertions(+), 3 deletions(-) create mode 100644 powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 create mode 100644 powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 create mode 100644 powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 create mode 100644 tests/maester/azure/Test.MT.1257.md create mode 100644 tests/maester/azure/Test.MT.1257.ps1 create mode 100644 tests/maester/azure/Test.MT.1258.md create mode 100644 tests/maester/azure/Test.MT.1258.ps1 diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 new file mode 100644 index 0000000000..661909a201 --- /dev/null +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 @@ -0,0 +1,103 @@ +function Get-MtDefenderForCloudAttackPath { + <# + .SYNOPSIS + Returns the Microsoft Defender for Cloud attack paths grouped by path, together with whether + Defender CSPM is enabled on any readable subscription. + + .DESCRIPTION + Attack paths are computed by Defender CSPM, so an empty result has two very different meanings: + the plan is off and nothing was ever computed, or the plan is on and the estate genuinely has no + path. The returned object separates them. CspmEnabled comes from the Defender for Cloud pricing of + CloudPosture, which Azure Resource Graph exposes as microsoft.security/pricings, so the caller can + report "not licensed" instead of a pass. + + On the fields, measured against a live Defender CSPM subscription rather than assumed: + + - properties.attackPathType is a GUID and properties.displayName is a sentence. The engine + requires an instance ID matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, so the GUID is the ID of + the path type and the sentence is the title. Grouping by the GUID is also what "one result per + attack path type" means: the sentence can repeat across occurrences of the same type. + - properties.entryPoint carries entityInternalId, entityType and dataSource, and no entity name, + so the entry point is reported by its resource type. + - properties.target does carry entityName as well as entityType, so the target is named. + - properties.riskFactors and properties.mITRETacticsAndTechniques.tactics are arrays. Azure + Resource Graph does not support mv-apply, so they are carried as their JSON text and parsed + here. + + .EXAMPLE + Get-MtDefenderForCloudAttackPath + + Returns whether Defender CSPM is on and the attack paths grouped by path. + #> + [CmdletBinding()] + [OutputType([pscustomobject])] + param() + + # Defender CSPM is the plan that computes attack paths. Its pricing row is the only way to tell an + # estate with no path from a subscription that never had the plan on. + $pricingQuery = @' +securityresources +| where type == "microsoft.security/pricings" +| where name == "CloudPosture" +| summarize StandardCount = countif(tostring(properties.pricingTier) == "Standard") +'@ + + Write-Verbose 'Checking whether Defender CSPM is enabled...' + $pricing = @(Invoke-MtAzureResourceGraphRequest -Query $pricingQuery) | Select-Object -First 1 + $cspmEnabled = $null -ne $pricing -and [int]($pricing.StandardCount) -gt 0 + + $pathQuery = @' +securityresources +| where type == "microsoft.security/attackpaths" +| extend nombre = tostring(properties.displayName), + riesgo = tostring(properties.riskLevel), + parcial = tostring(properties.isPartialAttackPath), + factores = tostring(properties.riskFactors), + tacticas = tostring(properties.mITRETacticsAndTechniques.tactics), + tipoEntrada = tostring(properties.entryPoint.entityType), + nombreDestino = tostring(properties.target.entityName), + tipoDestino = tostring(properties.target.entityType) +| summarize PathCount = count(), + DisplayName = any(nombre), + RiskLevel = any(riesgo), + Partial = any(parcial), + RiskFactorsJson = any(factores), + TacticsJson = any(tacticas), + EntryPointTypeList = make_set(tipoEntrada, 10), + TargetList = make_set(nombreDestino, 10), + TargetTypeList = make_set(tipoDestino, 10) + by AttackPathType = tostring(properties.attackPathType) +| sort by PathCount desc, AttackPathType asc +'@ + + Write-Verbose 'Querying Defender for Cloud attack paths...' + $rows = @(Invoke-MtAzureResourceGraphRequest -Query $pathQuery) + + # The arrays arrive as JSON text because Azure Resource Graph has no mv-apply. + function ConvertFrom-MtJsonArray { + param([string] $Text) + if ([string]::IsNullOrWhiteSpace($Text)) { return @() } + try { return @($Text | ConvertFrom-Json) } catch { return @() } + } + + $paths = [System.Collections.Generic.List[pscustomobject]]::new() + foreach ($row in $rows) { + if (-not $row -or [string]::IsNullOrWhiteSpace([string]$row.AttackPathType)) { continue } + $paths.Add([pscustomobject]@{ + AttackPathType = [string]$row.AttackPathType + DisplayName = [string]$row.DisplayName + RiskLevel = [string]$row.RiskLevel + PathCount = [int]($row.PathCount) + RiskFactorList = ConvertFrom-MtJsonArray -Text ([string]$row.RiskFactorsJson) + TacticList = ConvertFrom-MtJsonArray -Text ([string]$row.TacticsJson) + EntryPointTypeList = @($row.EntryPointTypeList | Where-Object { $_ }) + TargetList = @($row.TargetList | Where-Object { $_ }) + TargetTypeList = @($row.TargetTypeList | Where-Object { $_ }) + }) + } + + [pscustomobject]@{ + CspmEnabled = $cspmEnabled + PathList = $paths + } +} diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 new file mode 100644 index 0000000000..67cf5bf139 --- /dev/null +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 @@ -0,0 +1,81 @@ +function Get-MtDefenderForCloudRecommendation { + <# + .SYNOPSIS + Returns one row per Microsoft Defender for Cloud recommendation across the subscriptions the + signed-in account can read, with how many resources are healthy, unhealthy, not applicable and + exempt. + + .DESCRIPTION + Runs a single Azure Resource Graph query over securityresources, aggregated server side so the + result is one row per recommendation rather than one row per resource and recommendation. A large + estate produces thousands of assessment rows and only hundreds of recommendations, which is the + difference the caller needs to stay readable. + + Each row carries the recommendation's assessment key, display name, severity from its metadata, the + risk level Defender CSPM adds when it is enabled, the portal link, the resource counts, a capped + sample of the unhealthy resource names, and the exemption cause when every resource is exempt. + + An empty result means Defender for Cloud produced no assessment for these subscriptions. The caller + must skip in that case: no unhealthy resource over no assessment is not a pass. + + Errors are deliberately not caught here, so a failed query surfaces instead of being read as a + clean estate. + + .EXAMPLE + Get-MtDefenderForCloudRecommendation + + Returns the Defender for Cloud recommendations with their resource counts. + #> + [CmdletBinding()] + [OutputType([System.Collections.Generic.List[pscustomobject]])] + param() + + # Aggregated server side: one row per assessment key. make_set is capped because a recommendation + # can be unhealthy on thousands of resources and the result is a summary, not an inventory. + $query = @' +securityresources +| where type == "microsoft.security/assessments" +| extend estado = tostring(properties.status.code), + causa = tostring(properties.status.cause), + nombre = tostring(properties.displayName), + severidad = tostring(properties.metadata.severity), + riesgo = tostring(properties.risk.level), + portal = tostring(properties.links.azurePortal) +| summarize TotalCount = count(), + UnhealthyCount = countif(estado == "Unhealthy"), + HealthyCount = countif(estado == "Healthy"), + NotApplicableCount = countif(estado == "NotApplicable"), + ExemptCount = countif(causa == "Exempt"), + UnhealthyResourceList = make_set_if(tostring(split(id, "/")[8]), estado == "Unhealthy", 10), + DisplayName = any(nombre), + Severity = any(severidad), + RiskLevel = any(riesgo), + PortalUri = any(portal) + by AssessmentKey = name +| sort by UnhealthyCount desc, AssessmentKey asc +'@ + + Write-Verbose 'Querying Defender for Cloud assessments through Azure Resource Graph...' + $rows = @(Invoke-MtAzureResourceGraphRequest -Query $query) + + $result = [System.Collections.Generic.List[pscustomobject]]::new() + foreach ($row in $rows) { + if (-not $row -or [string]::IsNullOrWhiteSpace([string]$row.AssessmentKey)) { continue } + $result.Add([pscustomobject]@{ + AssessmentKey = [string]$row.AssessmentKey + DisplayName = [string]$row.DisplayName + Severity = [string]$row.Severity + RiskLevel = [string]$row.RiskLevel + PortalUri = [string]$row.PortalUri + TotalCount = [int]($row.TotalCount) + UnhealthyCount = [int]($row.UnhealthyCount) + HealthyCount = [int]($row.HealthyCount) + NotApplicableCount = [int]($row.NotApplicableCount) + ExemptCount = [int]($row.ExemptCount) + UnhealthyResourceList = @($row.UnhealthyResourceList) + }) + } + + # -NoEnumerate keeps an empty list from collapsing to $null. + Write-Output $result -NoEnumerate +} diff --git a/powershell/tests/fixtures/golden/selection.json b/powershell/tests/fixtures/golden/selection.json index 05f976972c..6b10f8a1fa 100644 --- a/powershell/tests/fixtures/golden/selection.json +++ b/powershell/tests/fixtures/golden/selection.json @@ -1918,7 +1918,7 @@ "AD" ] }, - "SelectedCount": 588, + "SelectedCount": 590, "SelectedFamilies": [ "MT.1024", "MT.1059", @@ -2445,6 +2445,8 @@ "MT.1250", "MT.1251", "MT.1252", + "MT.1257", + "MT.1258", "MT.1260", "ORCA.100", "ORCA.101", @@ -2527,7 +2529,7 @@ "AD" ] }, - "SelectedCount": 618, + "SelectedCount": 620, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -3086,6 +3088,8 @@ "MT.1250", "MT.1251", "MT.1252", + "MT.1257", + "MT.1258", "MT.1260", "ORCA.100", "ORCA.101", @@ -3920,7 +3924,7 @@ "AD" ] }, - "SelectedCount": 574, + "SelectedCount": 576, "SelectedFamilies": [ "MT.1024", "MT.1033", @@ -4435,6 +4439,8 @@ "MT.1250", "MT.1251", "MT.1252", + "MT.1257", + "MT.1258", "MT.1260", "ORCA.100", "ORCA.101", diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 new file mode 100644 index 0000000000..2545d9a052 --- /dev/null +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -0,0 +1,250 @@ +Describe 'Defender for Cloud recommendations and attack paths' { + BeforeAll { + Import-Module $PSScriptRoot/../../Maester.psd1 -Force + . "$PSScriptRoot/../helpers/Use-MtModuleFunction.ps1" + # Native tests, their instance sources and internal helpers; none is exported. + Use-MtModuleFunction -Name Test-MtAzureDefenderForCloudRecommendation, + Get-MtAzureDefenderForCloudRecommendationInstance, + Test-MtAzureDefenderForCloudAttackPath, + Get-MtAzureDefenderForCloudAttackPathInstance, + Get-MtDefenderForCloudRecommendation, + Get-MtDefenderForCloudAttackPath + + function Get-TestRecommendation { + param( + [int] $Unhealthy = 0, [int] $Healthy = 3, [int] $NotApplicable = 0, [int] $Exempt = 0, + [string] $Severity = 'Medium', [string] $RiskLevel = '' + ) + $total = $Unhealthy + $Healthy + $NotApplicable + return [pscustomobject]@{ + AssessmentKey = '01d9a108-3379-4c5a-8236-1a724dummy' + DisplayName = 'App Service apps should use the latest HTTP version' + Severity = $Severity + RiskLevel = $RiskLevel + PortalUri = 'https://portal.azure.com/#blade/dummy' + TotalCount = $total + UnhealthyCount = $Unhealthy + HealthyCount = $Healthy + NotApplicableCount = $NotApplicable + ExemptCount = $Exempt + UnhealthyResourceList = @('app-01', 'app-02') + } + } + + function Get-TestPath { + return [pscustomobject]@{ + AttackPathType = '563f8222-1c75-4d35-3114-588a83b45762' + DisplayName = 'Internet exposed Azure VM allows lateral movement to a storage account' + RiskLevel = 'High' + PathCount = 1 + RiskFactorList = @('Internet exposure', 'Vulnerabilities') + TacticList = @('Lateral Movement', 'Initial Access') + EntryPointTypeList = @('microsoft.compute/virtualmachines') + TargetList = @('storage-01') + TargetTypeList = @('microsoft.storage/storageaccounts') + } + } + } + + BeforeEach { + $script:TestResult = $null + $script:SkippedBecause = $null + $script:SkippedCustomReason = $null + $script:Severity = $null + + Mock -ModuleName Maester Get-MtLicenseInformation { return $true } + Mock -ModuleName Maester Add-MtTestResultDetail { + param($Result, $SkippedBecause, $SkippedCustomReason, $Severity) + + $script:TestResult = $Result + $script:SkippedBecause = $SkippedBecause + $script:SkippedCustomReason = $SkippedCustomReason + $script:Severity = $Severity + } + } + + Context 'MT.1257 recommendations' { + It 'passes when no resource is unhealthy' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 0 -Healthy 5 } + + Test-MtAzureDefenderForCloudRecommendation -Instance $i | Should -BeTrue + $script:TestResult | Should -Match 'None is unhealthy' + } + + It 'fails when any resource is unhealthy and names them' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 2 -Healthy 1 } + + Test-MtAzureDefenderForCloudRecommendation -Instance $i | Should -BeFalse + $script:TestResult | Should -Match '\*\*2\*\* of them are unhealthy' + $script:TestResult | Should -Match 'app-01, app-02' + } + + It 'skips with the exemption count when every resource is exempt' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 0 -Healthy 0 -NotApplicable 4 -Exempt 4 } + + $null -eq (Test-MtAzureDefenderForCloudRecommendation -Instance $i) | Should -BeTrue + $script:SkippedBecause | Should -Be 'Custom' + $script:SkippedCustomReason | Should -Match 'exempt' + } + + It 'skips instead of passing when nothing was evaluated either way' { + # No unhealthy over no evaluated resource is not a pass. + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 0 -Healthy 0 -NotApplicable 6 } + + $null -eq (Test-MtAzureDefenderForCloudRecommendation -Instance $i) | Should -BeTrue + $script:SkippedBecause | Should -Be 'NotApplicable' + } + + It 'prefers the Defender CSPM risk level over the metadata severity' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel 'Critical' } + + $null = Test-MtAzureDefenderForCloudRecommendation -Instance $i + $script:Severity | Should -Be 'High' -Because 'Critical maps to High and beats the Low metadata severity' + } + + It 'falls back to the metadata severity when there is no risk level' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel '' } + + $null = Test-MtAzureDefenderForCloudRecommendation -Instance $i + $script:Severity | Should -Be 'Low' + } + + It 'emits one instance per recommendation and none when there is no assessment' { + Mock -ModuleName Maester Get-MtDefenderForCloudRecommendation { @(Get-TestRecommendation), @(Get-TestRecommendation) } + @(Get-MtAzureDefenderForCloudRecommendationInstance).Count | Should -Be 2 + + Mock -ModuleName Maester Get-MtDefenderForCloudRecommendation { @() } + @(Get-MtAzureDefenderForCloudRecommendationInstance).Count | Should -Be 0 + } + } + + Context 'MT.1258 attack paths' { + It 'reports the family as not licensed when Defender CSPM is off' { + # Without the plan no attack path was ever computed, so an empty result says nothing. + Mock -ModuleName Maester Get-MtDefenderForCloudAttackPath { + [pscustomobject]@{ CspmEnabled = $false; PathList = @() } + } + + @(Get-MtAzureDefenderForCloudAttackPathInstance).Count | Should -Be 0 + $script:SkippedBecause | Should -Be 'Custom' + $script:SkippedCustomReason | Should -Match 'Defender CSPM is not enabled' + } + + It 'emits nothing without claiming a licence problem when the plan is on and no path exists' { + Mock -ModuleName Maester Get-MtDefenderForCloudAttackPath { + [pscustomobject]@{ CspmEnabled = $true; PathList = @() } + } + + @(Get-MtAzureDefenderForCloudAttackPathInstance).Count | Should -Be 0 + $script:SkippedCustomReason | Should -BeNullOrEmpty + } + + It 'uses the attack path type GUID as the instance id, not the sentence' { + # The engine requires ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, which a sentence never matches. + Mock -ModuleName Maester Get-MtDefenderForCloudAttackPath { + [pscustomobject]@{ CspmEnabled = $true; PathList = @(Get-TestPath) } + } + + $instance = @(Get-MtAzureDefenderForCloudAttackPathInstance)[0] + $instance.Id | Should -Match '^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$' + $instance.Title | Should -Match 'Internet exposed Azure VM' + } + + It 'fails for a reported path, with its risk factors and tactics' { + $i = [pscustomobject]@{ Data = Get-TestPath } + + Test-MtAzureDefenderForCloudAttackPath -Instance $i | Should -BeFalse + $script:Severity | Should -Be 'High' + $script:TestResult | Should -Match 'microsoft.compute/virtualmachines' + $script:TestResult | Should -Match 'Internet exposure, Vulnerabilities' + $script:TestResult | Should -Match 'Lateral Movement, Initial Access' + } + } + + Context 'Get-MtDefenderForCloudAttackPath' { + It 'reads CspmEnabled from the CloudPosture pricing tier' { + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'microsoft.security/pricings') { return @([pscustomobject]@{ StandardCount = 1 }) } + return @() + } + + (Get-MtDefenderForCloudAttackPath).CspmEnabled | Should -BeTrue + + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'microsoft.security/pricings') { return @([pscustomobject]@{ StandardCount = 0 }) } + return @() + } + + (Get-MtDefenderForCloudAttackPath).CspmEnabled | Should -BeFalse + } + + It 'parses the risk factors and tactics that arrive as JSON text' { + # Azure Resource Graph has no mv-apply, so the arrays travel as their JSON text. + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'microsoft.security/pricings') { return @([pscustomobject]@{ StandardCount = 1 }) } + return @([pscustomobject]@{ + AttackPathType = '563f8222-1c75-4d35-3114-588a83b45762' + DisplayName = 'A path' + RiskLevel = 'High' + PathCount = 2 + RiskFactorsJson = '["Internet exposure","Plaintext keys"]' + TacticsJson = '["Exfiltration"]' + EntryPointTypeList = @('microsoft.compute/virtualmachines') + TargetList = @('storage-01') + TargetTypeList = @('microsoft.storage/storageaccounts') + }) + } + + $path = (Get-MtDefenderForCloudAttackPath).PathList[0] + $path.RiskFactorList | Should -Contain 'Plaintext keys' + $path.TacticList | Should -Contain 'Exfiltration' + $path.PathCount | Should -Be 2 + } + + It 'survives risk factors that are not valid JSON' { + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'microsoft.security/pricings') { return @([pscustomobject]@{ StandardCount = 1 }) } + return @([pscustomobject]@{ + AttackPathType = 'abc' + DisplayName = 'A path' + RiskLevel = 'Low' + PathCount = 1 + RiskFactorsJson = 'not json at all' + TacticsJson = '' + }) + } + + $path = (Get-MtDefenderForCloudAttackPath).PathList[0] + @($path.RiskFactorList).Count | Should -Be 0 + @($path.TacticList).Count | Should -Be 0 + } + } + + Context 'Get-MtDefenderForCloudRecommendation' { + It 'returns an empty list, not null, when there is no assessment' { + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { @() } + + $r = Get-MtDefenderForCloudRecommendation + $null -eq $r | Should -BeFalse + $r.Count | Should -Be 0 + } + + It 'drops rows without an assessment key and normalises the counts' { + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + @( + [pscustomobject]@{ + AssessmentKey = 'key-1'; DisplayName = 'A'; Severity = 'High'; RiskLevel = 'Medium' + PortalUri = 'https://x'; TotalCount = 7; UnhealthyCount = 3; HealthyCount = 4 + NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1') + }, + [pscustomobject]@{ AssessmentKey = '' } + ) + } + + $r = Get-MtDefenderForCloudRecommendation + $r.Count | Should -Be 1 + $r[0].UnhealthyCount | Should -Be 3 + $r[0].RiskLevel | Should -Be 'Medium' + } + } +} diff --git a/tests/maester/azure/Test.MT.1257.md b/tests/maester/azure/Test.MT.1257.md new file mode 100644 index 0000000000..8a2e387a0a --- /dev/null +++ b/tests/maester/azure/Test.MT.1257.md @@ -0,0 +1,26 @@ +Ensure no resource is left **unhealthy for a Microsoft Defender for Cloud recommendation**. + +Defender for Cloud assesses the resources of every subscription it covers against a catalogue of recommendations and reports, per recommendation, which resources are healthy. An assessor normally reads that one recommendation at a time in the Azure portal. This check brings it into a Maester run. + +It runs **once per recommendation**, following the `InstanceSource` pattern `MT.1024` introduced — never once per resource. A large estate produces thousands of assessment rows and only hundreds of recommendations, and that difference is what keeps the report readable. + +A recommendation **passes** when no resource is unhealthy and **fails** when any is. The result carries the assessment key, the resource counts, the severity Defender assigns, the Defender CSPM risk level when the plan is on, a sample of up to ten unhealthy resource names, and the portal link to the full list. + +Severity follows the source. Defender CSPM adds a risk level per recommendation and that is preferred when present; otherwise the recommendation's own metadata severity is used. + +## When this is skipped + +- **Every resource is exempt.** An exemption is a decision already recorded in the Azure portal, so the check reports it with the count and does not raise the recommendation again. +- **Nothing was evaluated either way.** When a recommendation has no healthy and no unhealthy resource, there is no outcome to judge and the result is skipped as not applicable. **No unhealthy resource over no evaluated resource is not a pass.** +- **No assessment at all.** When Defender for Cloud returns nothing for the readable subscriptions, the instance source emits nothing and the engine skips the family with `NoInstances`. A subscription with no assessment has no recommendation to comply with. + +## How to remediate + +Open the recommendation in **Microsoft Defender for Cloud** → **Recommendations** and either remediate the resources listed or exempt the recommendation there, so the decision is recorded in the portal rather than lost. + +## Permissions + +Read-only. Reader or Security Reader on the subscriptions, or on a management group above them. The query runs through Azure Resource Graph, so it covers every readable subscription in one call. + + +%TestResult% diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1257.ps1 new file mode 100644 index 0000000000..fb012ab4fb --- /dev/null +++ b/tests/maester/azure/Test.MT.1257.ps1 @@ -0,0 +1,160 @@ +function Get-MtAzureDefenderForCloudRecommendationInstance { + <# + .SYNOPSIS + Returns one MT.1257 instance per Microsoft Defender for Cloud recommendation. + + .DESCRIPTION + Instance source of the MT.1257 family. The suffix is the recommendation's assessment key + (MT.1257.) and the title names the recommendation, the way MT.1024 does for Entra + recommendations. One instance per recommendation, never one per resource: a large estate produces + thousands of assessment rows and only hundreds of recommendations. + + When Defender for Cloud returns no assessment at all the source emits nothing and the engine skips + the family with NoInstances. A subscription with no assessment has no recommendation to comply + with, and must never be reported as having none unhealthy. + #> + [CmdletBinding()] + [OutputType([pscustomobject])] + param() + + $recommendations = Get-MtDefenderForCloudRecommendation + + foreach ($recommendation in $recommendations) { + # A recommendation evaluated against no resource has no outcome to judge. + if ($recommendation.TotalCount -le 0) { continue } + + $name = if ([string]::IsNullOrWhiteSpace($recommendation.DisplayName)) { + $recommendation.AssessmentKey + } else { + $recommendation.DisplayName + } + + [pscustomobject]@{ + Id = $recommendation.AssessmentKey + Title = "No resource should be left unhealthy for the Defender for Cloud recommendation '$name'." + Data = $recommendation + } + } +} + +function Test-MtAzureDefenderForCloudRecommendation { + <# + .SYNOPSIS + Ensure no resource is left unhealthy for a Microsoft Defender for Cloud recommendation. + + .DESCRIPTION + Defender for Cloud assesses the resources of every subscription it covers against a catalogue of + recommendations and reports, per recommendation, which resources are healthy. An assessor normally + reads that one recommendation at a time in the Azure portal. This check brings it into a Maester + run. + + It runs once per recommendation, following the InstanceSource pattern MT.1024 introduced. A + recommendation passes when no resource is unhealthy and fails when any is, with the resource + counts, a sample of the unhealthy resource names and the portal link to the full list. + + Severity follows the source, as #2510 asks. Defender CSPM adds a risk level per recommendation, + and that is preferred when present; otherwise the recommendation's own metadata severity is used. + + A recommendation whose resources are all exempt is skipped with the exemption cause, so a decision + already recorded in the Azure portal is respected rather than reported again. A recommendation that + applies to nothing is skipped as not applicable. Neither is reported as a pass. + + .OUTPUTS + [bool] - True when no resource is unhealthy, false when any is, null when skipped. + + .EXAMPLE + Test-MtAzureDefenderForCloudRecommendation + + Returns one result per Defender for Cloud recommendation. + + .LINK + https://maester.dev/docs/commands/Test-MtAzureDefenderForCloudRecommendation + #> + [MaesterTest( + Id = 'MT.1257', + Title = 'Resources should be healthy for the Microsoft Defender for Cloud recommendations.', + Product = 'azure', + Feature = 'subscriptions', + Area = 'infrastructure', + ResourceType = 'Tenant', + Severity = 'Medium', + UserImpact = 'Low', + ImplementationCost = 'Medium', + Mitre = 'None', + Lifecycle = 'Preview', + Service = 'Azure', + InstanceSource = 'Get-MtAzureDefenderForCloudRecommendationInstance', + Author = 'earbona23' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The recommendation to check, supplied by the engine. + $Instance + ) + + $recommendation = $Instance.Data + $unhealthy = [int]$recommendation.UnhealthyCount + $healthy = [int]$recommendation.HealthyCount + $notApplicable = [int]$recommendation.NotApplicableCount + $exempt = [int]$recommendation.ExemptCount + $total = [int]$recommendation.TotalCount + + if ($exempt -gt 0 -and $exempt -eq $total) { + # Every resource is exempt, which is a decision already recorded in the Azure portal. Respect + # it instead of reporting the recommendation again. + Add-MtTestResultDetail -SkippedBecause Custom -SkippedCustomReason "Every resource for this recommendation is exempt in Defender for Cloud ($exempt of $total)." + return $null + } + + if ($unhealthy -eq 0 -and $healthy -eq 0) { + # Nothing was evaluated either way. No unhealthy resource over no evaluated resource is not a + # pass. + Add-MtTestResultDetail -SkippedBecause NotApplicable + return $null + } + + $testResult = $unhealthy -eq 0 + + # Severity follows the source: the Defender CSPM risk level when it is present, otherwise the + # recommendation's own metadata severity. + $source = if (-not [string]::IsNullOrWhiteSpace($recommendation.RiskLevel)) { $recommendation.RiskLevel } else { $recommendation.Severity } + $severity = switch -Regex ($source) { + '^(Critical|High)$' { 'High'; break } + '^Medium$' { 'Medium'; break } + '^Low$' { 'Low'; break } + default { 'Medium' } + } + + $testResultMarkdown = "Defender for Cloud assessed **$total** resource(s) for this recommendation. " + if ($testResult) { + $testResultMarkdown += "None is unhealthy.`n`n" + } else { + $testResultMarkdown += "**$unhealthy** of them are unhealthy.`n`n" + } + + $testResultMarkdown += "| Property | Value |`n| --- | --- |`n" + $testResultMarkdown += "| Assessment key | ``$($recommendation.AssessmentKey)`` |`n" + $testResultMarkdown += "| Unhealthy | $unhealthy |`n" + $testResultMarkdown += "| Healthy | $healthy |`n" + $testResultMarkdown += "| Not applicable | $notApplicable |`n" + if ($exempt -gt 0) { $testResultMarkdown += "| Exempt | $exempt |`n" } + if (-not [string]::IsNullOrWhiteSpace($recommendation.Severity)) { $testResultMarkdown += "| Severity in Defender for Cloud | $($recommendation.Severity) |`n" } + if (-not [string]::IsNullOrWhiteSpace($recommendation.RiskLevel)) { $testResultMarkdown += "| Risk level (Defender CSPM) | $($recommendation.RiskLevel) |`n" } + + if (-not $testResult) { + $resources = @($recommendation.UnhealthyResourceList | Where-Object { $_ }) + if ($resources.Count -gt 0) { + $testResultMarkdown += "`nUnhealthy resources (up to ten shown): $($resources -join ', ')`n" + } + if (-not [string]::IsNullOrWhiteSpace($recommendation.PortalUri)) { + $testResultMarkdown += "`n[Open this recommendation in the Azure portal]($($recommendation.PortalUri))`n" + } + $testResultMarkdown += "`nRemediate the resources listed, or exempt the recommendation in Defender for Cloud so the decision is recorded there." + } else { + $testResultMarkdown += "`nWell done. Every resource Defender for Cloud evaluated for this recommendation is healthy." + } + + Add-MtTestResultDetail -Result $testResultMarkdown -Severity $severity + return $testResult +} diff --git a/tests/maester/azure/Test.MT.1258.md b/tests/maester/azure/Test.MT.1258.md new file mode 100644 index 0000000000..37a558fcff --- /dev/null +++ b/tests/maester/azure/Test.MT.1258.md @@ -0,0 +1,34 @@ +Ensure Microsoft Defender for Cloud reports **no active attack path**. + +Defender CSPM correlates the weaknesses of an estate into attack paths: a chain that starts at something an attacker can reach and ends at something worth reaching. An individual recommendation rates each weakness on its own; the **path** is what makes the combination matter. A virtual machine with a known vulnerability is one finding, a storage account holding a connection string is another, and the path that joins them is the thing an attacker actually walks. + +This check runs **once per attack path** Defender for Cloud reports, and **fails** for each one, because an attack path is an active route rather than a configuration opinion. + +The result names the entry point's resource type, the target, the risk factors Defender combined and the MITRE tactics the path covers. + +Severity follows the source: the risk level Defender assigns to the path. + +## On the fields + +Measured against a live Defender CSPM subscription rather than assumed: + +- `properties.attackPathType` is a **GUID** and `properties.displayName` is a sentence. The engine requires an instance ID matching `^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$`, so the GUID identifies the path type and the sentence is the title. Grouping by the GUID is also what *"one result per attack path type"* means. +- `properties.entryPoint` carries `entityInternalId`, `entityType` and `dataSource`, and **no entity name**, so the entry point is reported by its resource type. +- `properties.target` does carry `entityName` as well as `entityType`, so the target is named. +- `properties.riskFactors` and `properties.mITRETacticsAndTechniques.tactics` are arrays, and Azure Resource Graph has no `mv-apply`, so they travel as JSON text and are parsed in the helper. + +## When this is skipped + +- **Defender CSPM is not enabled** on any readable subscription. No attack path was ever computed, so an empty result says nothing about the estate. The family reports that instead of a pass, read from the `CloudPosture` pricing tier. +- **The plan is on and no path exists.** The instance source emits nothing and the engine skips the family with `NoInstances`. That is genuinely good news, and it is reported as "nothing to judge" rather than as a passing check, because this family has one result per path and no path to attach a pass to. + +## How to remediate + +Break the path rather than every weakness on it. Removing the entry point's exposure, or the credential or permission that allows the step to the target, closes the whole route. Defender for Cloud lists the recommendations that make up each path in the Azure portal, under **Attack path analysis**. + +## Permissions + +Read-only. Reader or Security Reader on the subscriptions, plus the **Defender CSPM** plan enabled. + + +%TestResult% diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 new file mode 100644 index 0000000000..0c134412b6 --- /dev/null +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -0,0 +1,123 @@ +function Get-MtAzureDefenderForCloudAttackPathInstance { + <# + .SYNOPSIS + Returns one MT.1258 instance per Microsoft Defender for Cloud attack path. + + .DESCRIPTION + Instance source of the MT.1258 family. One instance per attack path, titled with the path itself, + which Defender for Cloud phrases as a sentence naming the entry point and the target. + + When Defender CSPM is not enabled on any readable subscription the source reports the family as not + licensed, because no attack path was ever computed and an empty result there says nothing about the + estate. When the plan is on and no path exists the source emits nothing and the engine skips the + family with NoInstances. + #> + [CmdletBinding()] + [OutputType([pscustomobject])] + param() + + $attackPaths = Get-MtDefenderForCloudAttackPath + + if (-not $attackPaths.CspmEnabled) { + # Attack paths are computed by Defender CSPM. Without the plan there is nothing to read, and an + # empty result must not be read as an estate with no attack path. + Add-MtTestResultDetail -SkippedBecause Custom -SkippedCustomReason 'Defender CSPM is not enabled on any readable subscription, so Defender for Cloud computes no attack paths.' + return + } + + foreach ($path in $attackPaths.PathList) { + # The engine requires an instance ID matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, so the ID is + # the attack path type's GUID and the sentence Defender writes is the title. + [pscustomobject]@{ + Id = $path.AttackPathType + Title = "No active attack path should exist: $($path.DisplayName)" + Data = $path + } + } +} + +function Test-MtAzureDefenderForCloudAttackPath { + <# + .SYNOPSIS + Ensure Microsoft Defender for Cloud reports no active attack path to a critical asset. + + .DESCRIPTION + Defender CSPM correlates the weaknesses of an estate into attack paths: a chain that starts at + something an attacker can reach and ends at something worth reaching. An individual recommendation + rates each weakness on its own, and the path is what makes the combination matter. + + This check runs once per attack path Defender for Cloud reports, and fails for each one, because an + attack path is by definition an active route rather than a configuration opinion. The result names + the entry point's resource type, the target, the risk factors Defender combined, and the MITRE + tactics the path covers. + + Severity follows the source: the risk level Defender assigns to the path. + + It never passes on an absent source. Without Defender CSPM on a readable subscription no path was + ever computed, and the family reports that rather than a clean estate. + + .OUTPUTS + [bool] - Always false for a reported path; null when the family is skipped. + + .EXAMPLE + Test-MtAzureDefenderForCloudAttackPath + + Returns one result per attack path Defender for Cloud reports. + + .LINK + https://maester.dev/docs/commands/Test-MtAzureDefenderForCloudAttackPath + #> + [MaesterTest( + Id = 'MT.1258', + Title = 'Microsoft Defender for Cloud should report no active attack path.', + Product = 'azure', + Feature = 'subscriptions', + Area = 'infrastructure', + ResourceType = 'Tenant', + Severity = 'High', + UserImpact = 'Low', + ImplementationCost = 'High', + Mitre = 'None', + Lifecycle = 'Preview', + Service = 'Azure', + InstanceSource = 'Get-MtAzureDefenderForCloudAttackPathInstance', + Author = 'earbona23' + )] + [CmdletBinding()] + [OutputType([bool])] + param( + # The attack path to report, supplied by the engine. + $Instance + ) + + $path = $Instance.Data + + # Severity follows the source, as #2510 asks: the risk level Defender assigns to the path. + $severity = switch -Regex ([string]$path.RiskLevel) { + '^(Critical|High)$' { 'High'; break } + '^Medium$' { 'Medium'; break } + '^Low$' { 'Low'; break } + default { 'High' } + } + + $testResultMarkdown = "Defender for Cloud reports this attack path on **$($path.PathCount)** occasion(s).`n`n" + $testResultMarkdown += "| Property | Value |`n| --- | --- |`n" + if (-not [string]::IsNullOrWhiteSpace($path.RiskLevel)) { $testResultMarkdown += "| Risk level | $($path.RiskLevel) |`n" } + + $entry = @($path.EntryPointTypeList | Where-Object { $_ }) + if ($entry.Count -gt 0) { $testResultMarkdown += "| Entry point resource type | $($entry -join ', ') |`n" } + $target = @($path.TargetList | Where-Object { $_ }) + if ($target.Count -gt 0) { $testResultMarkdown += "| Target | $($target -join ', ') |`n" } + $targetType = @($path.TargetTypeList | Where-Object { $_ }) + if ($targetType.Count -gt 0) { $testResultMarkdown += "| Target resource type | $($targetType -join ', ') |`n" } + + $factors = @($path.RiskFactorList | Where-Object { $_ }) + if ($factors.Count -gt 0) { $testResultMarkdown += "`n**Risk factors Defender combined.** $($factors -join ', ')`n" } + $tactics = @($path.TacticList | Where-Object { $_ }) + if ($tactics.Count -gt 0) { $testResultMarkdown += "`n**MITRE tactics.** $($tactics -join ', ')`n" } + + $testResultMarkdown += "`nBreak the path rather than every weakness on it. Removing the entry point's exposure, or the credential or permission that allows the step to the target, closes the whole route; Defender for Cloud lists the recommendations of this path in the Azure portal." + + Add-MtTestResultDetail -Result $testResultMarkdown -Severity $severity + return $false +} From 4529a47f8f35d1a3aade80712b866660e08f9ec3 Mon Sep 17 00:00:00 2001 From: Eduard Arbona Date: Fri, 6 Nov 2026 08:59:17 -0400 Subject: [PATCH 02/10] fix(MT.1258): ImplementationCost is Medium, not High The attribute review is right. Breaking one attack path is a few targeted changes, usually coordinated with the resource owner: remove the entry point's exposure, or the credential or permission that allows the step to the target. The rubric rates that Medium. The Defender CSPM plan is a prerequisite of the check, not part of the fix. --- tests/maester/azure/Test.MT.1258.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 index 0c134412b6..0e1056e6dc 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -76,7 +76,7 @@ function Test-MtAzureDefenderForCloudAttackPath { ResourceType = 'Tenant', Severity = 'High', UserImpact = 'Low', - ImplementationCost = 'High', + ImplementationCost = 'Medium', Mitre = 'None', Lifecycle = 'Preview', Service = 'Azure', From 52698f30892fe29ced9f970e972ea45682fd3444 Mon Sep 17 00:00:00 2001 From: Eduard Arbona Date: Fri, 6 Nov 2026 22:10:55 -0400 Subject: [PATCH 03/10] fix(MT.1257, MT.1258): the per-instance severity goes on the instance Both families computed a severity from the source and passed it to Add-MtTestResultDetail, where the engine never reads it: Invoke-MtNativePlan resolves severity as config row, then the instance, then the attribute, then the detail, and both tests declare Severity in the attribute. So every row reported the attribute's default and the claim that severity follows the source was not true of the output. The severity now goes on the instance object, which is second in that order and is what MT.1024 and MT.1059 already do. No other behaviour changes. The two unit tests that covered this asserted the value on the mocked detail, so they passed while the engine discarded it. They now assert it on the instance, and a third asserts that nothing is passed to Add-MtTestResultDetail, so the dead parameter cannot come back unnoticed. --- .../Test-MtAzureDefenderForCloud.Tests.ps1 | 40 ++++++++++++++----- tests/maester/azure/Test.MT.1257.ps1 | 33 ++++++++------- tests/maester/azure/Test.MT.1258.ps1 | 29 ++++++++------ 3 files changed, 67 insertions(+), 35 deletions(-) diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 index 2545d9a052..df30824ad5 100644 --- a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -32,10 +32,11 @@ Describe 'Defender for Cloud recommendations and attack paths' { } function Get-TestPath { + param([string] $RiskLevel = 'High') return [pscustomobject]@{ AttackPathType = '563f8222-1c75-4d35-3114-588a83b45762' DisplayName = 'Internet exposed Azure VM allows lateral movement to a storage account' - RiskLevel = 'High' + RiskLevel = $RiskLevel PathCount = 1 RiskFactorList = @('Internet exposure', 'Vulnerabilities') TacticList = @('Lateral Movement', 'Initial Access') @@ -95,18 +96,28 @@ Describe 'Defender for Cloud recommendations and attack paths' { $script:SkippedBecause | Should -Be 'NotApplicable' } - It 'prefers the Defender CSPM risk level over the metadata severity' { - $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel 'Critical' } + # The severity has to be on the instance: the engine resolves config, then the instance, then + # the attribute, so a -Severity passed to Add-MtTestResultDetail is never reached while the + # attribute declares one. Asserting it on the detail is what let this ship the wrong way round. + It 'puts the Defender CSPM risk level on the instance, preferred over the metadata severity' { + Mock -ModuleName Maester Get-MtDefenderForCloudRecommendation { @(Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel 'Critical') } - $null = Test-MtAzureDefenderForCloudRecommendation -Instance $i - $script:Severity | Should -Be 'High' -Because 'Critical maps to High and beats the Low metadata severity' + $instance = @(Get-MtAzureDefenderForCloudRecommendationInstance)[0] + $instance.Severity | Should -Be 'High' -Because 'Critical maps to High and beats the Low metadata severity' } - It 'falls back to the metadata severity when there is no risk level' { - $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel '' } + It 'falls back to the metadata severity on the instance when there is no risk level' { + Mock -ModuleName Maester Get-MtDefenderForCloudRecommendation { @(Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel '') } + + $instance = @(Get-MtAzureDefenderForCloudRecommendationInstance)[0] + $instance.Severity | Should -Be 'Low' + } + + It 'passes no severity to Add-MtTestResultDetail, which the attribute would discard' { + $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 1 -Severity 'Low' -RiskLevel 'Critical' } $null = Test-MtAzureDefenderForCloudRecommendation -Instance $i - $script:Severity | Should -Be 'Low' + $script:Severity | Should -BeNullOrEmpty } It 'emits one instance per recommendation and none when there is no assessment' { @@ -150,11 +161,22 @@ Describe 'Defender for Cloud recommendations and attack paths' { $instance.Title | Should -Match 'Internet exposed Azure VM' } + It 'puts the path risk level on the instance, and passes none to Add-MtTestResultDetail' { + Mock -ModuleName Maester Get-MtDefenderForCloudAttackPath { + return [pscustomobject]@{ CspmEnabled = $true; PathList = @(Get-TestPath -RiskLevel 'Medium') } + } + + $instance = @(Get-MtAzureDefenderForCloudAttackPathInstance)[0] + $instance.Severity | Should -Be 'Medium' + + $null = Test-MtAzureDefenderForCloudAttackPath -Instance ([pscustomobject]@{ Data = Get-TestPath -RiskLevel 'Medium' }) + $script:Severity | Should -BeNullOrEmpty + } + It 'fails for a reported path, with its risk factors and tactics' { $i = [pscustomobject]@{ Data = Get-TestPath } Test-MtAzureDefenderForCloudAttackPath -Instance $i | Should -BeFalse - $script:Severity | Should -Be 'High' $script:TestResult | Should -Match 'microsoft.compute/virtualmachines' $script:TestResult | Should -Match 'Internet exposure, Vulnerabilities' $script:TestResult | Should -Match 'Lateral Movement, Initial Access' diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1257.ps1 index fb012ab4fb..3a3a7fe851 100644 --- a/tests/maester/azure/Test.MT.1257.ps1 +++ b/tests/maester/azure/Test.MT.1257.ps1 @@ -29,10 +29,25 @@ function Get-MtAzureDefenderForCloudRecommendationInstance { $recommendation.DisplayName } + # Severity follows the source, as #2510 asks. It goes on the instance because that is where the + # engine reads a family's per-instance severity (Invoke-MtNativePlan resolves config, then the + # instance, then the attribute); -Severity on Add-MtTestResultDetail is never reached once the + # attribute declares one. + # The Defender CSPM risk level is preferred when present, otherwise the recommendation's own + # metadata severity. + $source = if (-not [string]::IsNullOrWhiteSpace($recommendation.RiskLevel)) { $recommendation.RiskLevel } else { $recommendation.Severity } + $severity = switch -Regex ($source) { + '^(Critical|High)$' { 'High'; break } + '^Medium$' { 'Medium'; break } + '^Low$' { 'Low'; break } + default { 'Medium' } + } + [pscustomobject]@{ - Id = $recommendation.AssessmentKey - Title = "No resource should be left unhealthy for the Defender for Cloud recommendation '$name'." - Data = $recommendation + Id = $recommendation.AssessmentKey + Title = "No resource should be left unhealthy for the Defender for Cloud recommendation '$name'." + Severity = $severity + Data = $recommendation } } } @@ -116,16 +131,6 @@ function Test-MtAzureDefenderForCloudRecommendation { $testResult = $unhealthy -eq 0 - # Severity follows the source: the Defender CSPM risk level when it is present, otherwise the - # recommendation's own metadata severity. - $source = if (-not [string]::IsNullOrWhiteSpace($recommendation.RiskLevel)) { $recommendation.RiskLevel } else { $recommendation.Severity } - $severity = switch -Regex ($source) { - '^(Critical|High)$' { 'High'; break } - '^Medium$' { 'Medium'; break } - '^Low$' { 'Low'; break } - default { 'Medium' } - } - $testResultMarkdown = "Defender for Cloud assessed **$total** resource(s) for this recommendation. " if ($testResult) { $testResultMarkdown += "None is unhealthy.`n`n" @@ -155,6 +160,6 @@ function Test-MtAzureDefenderForCloudRecommendation { $testResultMarkdown += "`nWell done. Every resource Defender for Cloud evaluated for this recommendation is healthy." } - Add-MtTestResultDetail -Result $testResultMarkdown -Severity $severity + Add-MtTestResultDetail -Result $testResultMarkdown return $testResult } diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 index 0e1056e6dc..2b18d7e633 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -28,10 +28,23 @@ foreach ($path in $attackPaths.PathList) { # The engine requires an instance ID matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$, so the ID is # the attack path type's GUID and the sentence Defender writes is the title. + # Severity follows the source, as #2510 asks. It goes on the instance because that is where the + # engine reads a family's per-instance severity (Invoke-MtNativePlan resolves config, then the + # instance, then the attribute); -Severity on Add-MtTestResultDetail is never reached once the + # attribute declares one. + # The risk level Defender assigns to the path. + $severity = switch -Regex ([string]$path.RiskLevel) { + '^(Critical|High)$' { 'High'; break } + '^Medium$' { 'Medium'; break } + '^Low$' { 'Low'; break } + default { 'High' } + } + [pscustomobject]@{ - Id = $path.AttackPathType - Title = "No active attack path should exist: $($path.DisplayName)" - Data = $path + Id = $path.AttackPathType + Title = "No active attack path should exist: $($path.DisplayName)" + Severity = $severity + Data = $path } } } @@ -92,14 +105,6 @@ function Test-MtAzureDefenderForCloudAttackPath { $path = $Instance.Data - # Severity follows the source, as #2510 asks: the risk level Defender assigns to the path. - $severity = switch -Regex ([string]$path.RiskLevel) { - '^(Critical|High)$' { 'High'; break } - '^Medium$' { 'Medium'; break } - '^Low$' { 'Low'; break } - default { 'High' } - } - $testResultMarkdown = "Defender for Cloud reports this attack path on **$($path.PathCount)** occasion(s).`n`n" $testResultMarkdown += "| Property | Value |`n| --- | --- |`n" if (-not [string]::IsNullOrWhiteSpace($path.RiskLevel)) { $testResultMarkdown += "| Risk level | $($path.RiskLevel) |`n" } @@ -118,6 +123,6 @@ function Test-MtAzureDefenderForCloudAttackPath { $testResultMarkdown += "`nBreak the path rather than every weakness on it. Removing the entry point's exposure, or the credential or permission that allows the step to the target, closes the whole route; Defender for Cloud lists the recommendations of this path in the Azure portal." - Add-MtTestResultDetail -Result $testResultMarkdown -Severity $severity + Add-MtTestResultDetail -Result $testResultMarkdown return $false } From 4feac11d338e40a3589c1e91858d13edcb736c04 Mon Sep 17 00:00:00 2001 From: Eduard Arbona Date: Fri, 6 Nov 2026 23:23:38 -0400 Subject: [PATCH 04/10] fix(MT.1257, MT.1258): the ResourceType and the Mitre technique of the two families MT.1257: ResourceType is AzureResource, not Tenant. Each instance's failing result lists unhealthy Azure resources, so the instance is not an environment-wide setting. MT.1258: Mitre is T1190 and T1552, not None. I set None reasoning that attack paths vary, but the description names the behaviour concretely: an exposed resource reached first, then a storage account holding a connection string. None is for a check with no attacker behaviour behind it. Raised by the attribute review. --- tests/maester/azure/Test.MT.1257.ps1 | 2 +- tests/maester/azure/Test.MT.1258.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1257.ps1 index 3a3a7fe851..fa0ab7ccd1 100644 --- a/tests/maester/azure/Test.MT.1257.ps1 +++ b/tests/maester/azure/Test.MT.1257.ps1 @@ -91,7 +91,7 @@ function Test-MtAzureDefenderForCloudRecommendation { Product = 'azure', Feature = 'subscriptions', Area = 'infrastructure', - ResourceType = 'Tenant', + ResourceType = 'AzureResource', Severity = 'Medium', UserImpact = 'Low', ImplementationCost = 'Medium', diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 index 2b18d7e633..5c47bb4e42 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -90,7 +90,7 @@ function Test-MtAzureDefenderForCloudAttackPath { Severity = 'High', UserImpact = 'Low', ImplementationCost = 'Medium', - Mitre = 'None', + Mitre = ('T1190', 'T1552'), Lifecycle = 'Preview', Service = 'Azure', InstanceSource = 'Get-MtAzureDefenderForCloudAttackPathInstance', From c1002ca41d5090f4a4b9725e26e061eda58cb7cd Mon Sep 17 00:00:00 2001 From: Eduard Arbona Date: Fri, 6 Nov 2026 23:45:29 -0400 Subject: [PATCH 05/10] fix(MT.1258): ResourceType is AzureResource, like MT.1257 An attack path runs through Azure resources and each result names the entry point's and the target's resource type, so it is not an environment-wide setting. The two Defender for Cloud families now agree. Raised by the attribute review. --- tests/maester/azure/Test.MT.1258.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 index 5c47bb4e42..c7b5616bd5 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -86,7 +86,7 @@ function Test-MtAzureDefenderForCloudAttackPath { Product = 'azure', Feature = 'subscriptions', Area = 'infrastructure', - ResourceType = 'Tenant', + ResourceType = 'AzureResource', Severity = 'High', UserImpact = 'Low', ImplementationCost = 'Medium', From ff3ba3c1222f79ea8d2817e03a4d686fed0507c9 Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:07:00 -0400 Subject: [PATCH 06/10] chore: save the new PowerShell files as UTF-8 with BOM Per the ruling on #2663: every .ps1, .psm1 and .psd1 is UTF-8 with a byte order mark. These files were written without one, so they would fail the check #2714 adds once it lands. Only the three bytes EF BB BF are prepended; nothing else in the files changes. --- .../services/azure/Get-MtDefenderForCloudRecommendation.ps1 | 2 +- .../tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 | 2 +- tests/maester/azure/Test.MT.1257.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 index 67cf5bf139..85ccf0a514 100644 --- a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 @@ -1,4 +1,4 @@ -function Get-MtDefenderForCloudRecommendation { +function Get-MtDefenderForCloudRecommendation { <# .SYNOPSIS Returns one row per Microsoft Defender for Cloud recommendation across the subscriptions the diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 index df30824ad5..6dc95e7c36 100644 --- a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -1,4 +1,4 @@ -Describe 'Defender for Cloud recommendations and attack paths' { +Describe 'Defender for Cloud recommendations and attack paths' { BeforeAll { Import-Module $PSScriptRoot/../../Maester.psd1 -Force . "$PSScriptRoot/../helpers/Use-MtModuleFunction.ps1" diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1257.ps1 index fa0ab7ccd1..d3189f7bba 100644 --- a/tests/maester/azure/Test.MT.1257.ps1 +++ b/tests/maester/azure/Test.MT.1257.ps1 @@ -1,4 +1,4 @@ -function Get-MtAzureDefenderForCloudRecommendationInstance { +function Get-MtAzureDefenderForCloudRecommendationInstance { <# .SYNOPSIS Returns one MT.1257 instance per Microsoft Defender for Cloud recommendation. From a3aea1982ef4bd61643ec799c948091c50b8832b Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:29:17 -0400 Subject: [PATCH 07/10] fix(MT.1257,MT.1258): deterministic risk, Azure-only scope, and honest list totals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five of the review threads, all server side in the Resource Graph queries. Risk level. `any()` is an alias of take_any and is non-deterministic by contract, while properties.risk.level varies per resource within an assessment key and per occurrence within an attack path type. A key that was Critical somewhere could be reported Low. Both queries now rank the level and take the group's worst. In the attack path query it is worse than one wrong field: RiskLevel, RiskFactorsJson and TacticsJson were three independent any() calls, so they could describe three different occurrences of the same path type. arg_max takes all three from the occurrence that ranks worst, so the row is coherent. any() is kept for DisplayName, Severity and PortalUri. Those belong to the assessment definition and are identical on every row of the group, which is the case any() is for. Azure scope. Multicloud connectors surface AWS and GCP assessments in securityresources, and their counts flowed into an Azure test. The filter keeps the empty Source deliberately: native Azure resources do not carry one, so filtering on "Azure" alone would return nothing at all. Truncated lists. make_set is capped at ten while the counts cover everything, so the reader could not tell a complete list from a sample. Both queries now also return the distinct total, and both tests say "3 of 37" instead of "up to ten shown" or nothing. Three cases added. The aggregation happens server side, so each mock answers the way Azure would for a query that asks and the way it would for one that does not, rather than asserting on the query string: 21 of 21 with the fix, and with the two helpers reverted those three are exactly the ones that fail. My own test was wrong twice on the way here — once reading the wrapper object as if it were the rows — which is the argument for writing the control first. --- .../Get-MtDefenderForCloudAttackPath.ps1 | 15 ++++-- .../Get-MtDefenderForCloudRecommendation.ps1 | 20 +++++++- .../Test-MtAzureDefenderForCloud.Tests.ps1 | 48 +++++++++++++++++++ tests/maester/azure/Test.MT.1257.ps1 | 4 +- tests/maester/azure/Test.MT.1258.ps1 | 7 ++- 5 files changed, 86 insertions(+), 8 deletions(-) diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 index 661909a201..f68017821f 100644 --- a/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 @@ -57,16 +57,21 @@ securityresources tipoEntrada = tostring(properties.entryPoint.entityType), nombreDestino = tostring(properties.target.entityName), tipoDestino = tostring(properties.target.entityType) +// A risk level is per occurrence, so a group holds several. any() picked one at random, and it +// picked independently for the risk factors and the tactics, so the three could describe different +// occurrences of the same attack path type. arg_max takes all three from the one that ranks worst. +| extend rangoRiesgo = case(riesgo =~ "Critical", 4, riesgo =~ "High", 3, riesgo =~ "Medium", 2, riesgo =~ "Low", 1, 0) | summarize PathCount = count(), DisplayName = any(nombre), - RiskLevel = any(riesgo), Partial = any(parcial), - RiskFactorsJson = any(factores), - TacticsJson = any(tacticas), EntryPointTypeList = make_set(tipoEntrada, 10), TargetList = make_set(nombreDestino, 10), - TargetTypeList = make_set(tipoDestino, 10) + // make_set is capped, so the consumer needs to know when it is showing a subset. + TargetTotal = dcount(nombreDestino), + TargetTypeList = make_set(tipoDestino, 10), + (RiskRank, RiskLevel, RiskFactorsJson, TacticsJson) = arg_max(rangoRiesgo, riesgo, factores, tacticas) by AttackPathType = tostring(properties.attackPathType) +| project-away RiskRank | sort by PathCount desc, AttackPathType asc '@ @@ -92,6 +97,8 @@ securityresources TacticList = ConvertFrom-MtJsonArray -Text ([string]$row.TacticsJson) EntryPointTypeList = @($row.EntryPointTypeList | Where-Object { $_ }) TargetList = @($row.TargetList | Where-Object { $_ }) + # make_set is capped at 10; this is how many distinct targets there really are. + TargetTotal = [int]($row.TargetTotal) TargetTypeList = @($row.TargetTypeList | Where-Object { $_ }) }) } diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 index 85ccf0a514..1b47b39b14 100644 --- a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 @@ -35,23 +35,36 @@ $query = @' securityresources | where type == "microsoft.security/assessments" +// Multicloud connectors surface AWS and GCP assessments in the same table, and their counts +// would flow into an Azure test. Native Azure resources have no Source, so the empty string is +// kept deliberately: filtering on Source == "Azure" alone would return nothing. +| extend origen = tostring(properties.resourceDetails.Source) +| where origen == "" or origen =~ "Azure" | extend estado = tostring(properties.status.code), causa = tostring(properties.status.cause), nombre = tostring(properties.displayName), severidad = tostring(properties.metadata.severity), riesgo = tostring(properties.risk.level), portal = tostring(properties.links.azurePortal) +// A risk level is per resource, so a group holds several. any() picks one at random and could +// report Low for a key that is Critical somewhere. Ranked and maxed, the group reports its worst. +| extend rangoRiesgo = case(riesgo =~ "Critical", 4, riesgo =~ "High", 3, riesgo =~ "Medium", 2, riesgo =~ "Low", 1, 0) | summarize TotalCount = count(), UnhealthyCount = countif(estado == "Unhealthy"), HealthyCount = countif(estado == "Healthy"), NotApplicableCount = countif(estado == "NotApplicable"), ExemptCount = countif(causa == "Exempt"), UnhealthyResourceList = make_set_if(tostring(split(id, "/")[8]), estado == "Unhealthy", 10), + UnhealthyResourceTotal = dcountif(tostring(split(id, "/")[8]), estado == "Unhealthy"), + // any() is correct for these three: they belong to the assessment definition, so they + // are the same on every row of the group. DisplayName = any(nombre), Severity = any(severidad), - RiskLevel = any(riesgo), - PortalUri = any(portal) + PortalUri = any(portal), + RiskRank = max(rangoRiesgo) by AssessmentKey = name +| extend RiskLevel = case(RiskRank == 4, "Critical", RiskRank == 3, "High", RiskRank == 2, "Medium", RiskRank == 1, "Low", "") +| project-away RiskRank | sort by UnhealthyCount desc, AssessmentKey asc '@ @@ -73,6 +86,9 @@ securityresources NotApplicableCount = [int]($row.NotApplicableCount) ExemptCount = [int]($row.ExemptCount) UnhealthyResourceList = @($row.UnhealthyResourceList) + # The list above is capped at 10, so the caller can say "10 of 37" instead of + # showing a subset as if it were the whole set. + UnhealthyResourceTotal = [int]($row.UnhealthyResourceTotal) }) } diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 index 6dc95e7c36..661a3e944b 100644 --- a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -183,6 +183,54 @@ } } + Context 'What the queries ask Azure for' { + # These three aggregations happen server side, so the behaviour lives in the query text + # rather than in PowerShell. Each mock answers the way Azure would for a query that does + # ask, and the way it would for one that does not, so the case fails against the previous + # query instead of asserting on a string. + + It 'takes the worst risk level of a group, not an arbitrary one' { + # `any(riesgo)` is non-deterministic by contract, so a key that is Critical on one + # resource could be reported Low. Ranked and maxed, the group reports its worst. + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'max\(rangoRiesgo\)') { + return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'Critical'; PortalUri = ''; TotalCount = 2; UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) + } + return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'Low'; PortalUri = ''; TotalCount = 2; UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) + } + + $fila = @(Get-MtDefenderForCloudRecommendation)[0] + $fila.RiskLevel | Should -Be 'Critical' + } + + It 'leaves AWS and GCP assessments out of an Azure test' { + # Multicloud connectors surface their assessments in the same table. The empty Source + # is kept on purpose: native Azure resources have none, so filtering on "Azure" alone + # would return nothing at all. + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + $conFiltro = $Query -match 'origen == "" or origen =~ "Azure"' + return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'High'; PortalUri = ''; TotalCount = $(if ($conFiltro) { 2 } else { 5 }); UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) + } + + $fila = @(Get-MtDefenderForCloudRecommendation)[0] + $fila.TotalCount | Should -Be 2 -Because 'the three AWS and GCP rows must not be counted' + } + + It 'reports how many distinct targets there are, not just the ten it shows' { + # make_set is capped at 10 while PathCount counts everything, so without the total the + # reader cannot tell a complete list from a truncated one. + Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { + if ($Query -match 'StandardCount') { return @([pscustomobject]@{ StandardCount = 1 }) } + return @([pscustomobject]@{ AttackPathType = 'tipo-1'; DisplayName = 'Un camino'; RiskLevel = 'High'; Partial = 'false'; RiskFactorsJson = '[]'; TacticsJson = '[]'; PathCount = 37; EntryPointTypeList = @('vm'); TargetList = @('t1','t2'); TargetTotal = 37; TargetTypeList = @('storage') }) + } + + # The function returns a wrapper with CspmEnabled and PathList, not the rows. + $fila = @((Get-MtDefenderForCloudAttackPath).PathList)[0] + $fila.TargetTotal | Should -Be 37 + @($fila.TargetList).Count | Should -Be 2 -Because 'the list is a sample and the total says so' + } + } + Context 'Get-MtDefenderForCloudAttackPath' { It 'reads CspmEnabled from the CloudPosture pricing tier' { Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1257.ps1 index d3189f7bba..1cd66c529b 100644 --- a/tests/maester/azure/Test.MT.1257.ps1 +++ b/tests/maester/azure/Test.MT.1257.ps1 @@ -150,7 +150,9 @@ function Test-MtAzureDefenderForCloudRecommendation { if (-not $testResult) { $resources = @($recommendation.UnhealthyResourceList | Where-Object { $_ }) if ($resources.Count -gt 0) { - $testResultMarkdown += "`nUnhealthy resources (up to ten shown): $($resources -join ', ')`n" + # "up to ten shown" does not tell the reader whether ten is all of them. The total does. + $etiquetaRecursos = if ([int]$recommendation.UnhealthyResourceTotal -gt $resources.Count) { "$($resources.Count) of $([int]$recommendation.UnhealthyResourceTotal)" } else { 'all' } + $testResultMarkdown += "`nUnhealthy resources ($etiquetaRecursos): $($resources -join ', ')`n" } if (-not [string]::IsNullOrWhiteSpace($recommendation.PortalUri)) { $testResultMarkdown += "`n[Open this recommendation in the Azure portal]($($recommendation.PortalUri))`n" diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1258.ps1 index c7b5616bd5..7d035c9305 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1258.ps1 @@ -112,7 +112,12 @@ function Test-MtAzureDefenderForCloudAttackPath { $entry = @($path.EntryPointTypeList | Where-Object { $_ }) if ($entry.Count -gt 0) { $testResultMarkdown += "| Entry point resource type | $($entry -join ', ') |`n" } $target = @($path.TargetList | Where-Object { $_ }) - if ($target.Count -gt 0) { $testResultMarkdown += "| Target | $($target -join ', ') |`n" } + if ($target.Count -gt 0) { + # The list is capped server side, so say when it is a sample. Without this the reader + # cannot tell ten targets from ten of thirty-seven. + $etiquetaDestino = if ([int]$path.TargetTotal -gt $target.Count) { "Target ($($target.Count) of $([int]$path.TargetTotal))" } else { 'Target' } + $testResultMarkdown += "| $etiquetaDestino | $($target -join ', ') |`n" + } $targetType = @($path.TargetTypeList | Where-Object { $_ }) if ($targetType.Count -gt 0) { $testResultMarkdown += "| Target resource type | $($targetType -join ', ') |`n" } From 77fef15c75e56f84971e97ecbee98acf7ca2b44b Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:46:41 -0400 Subject: [PATCH 08/10] chore: renumber to the next free MT sequence (MT.1257/1258 -> MT.1271/1272) MT.1253-1258 are already reserved by Cloud-Architekt on #697 (28 Oct) and used in #2705, so this PR had taken numbers that were not free. Renumbered from MT.1267, the next free number after MT.1266, and reserved the new range on #697. The golden selection fixture was regenerated with build/golden/Export-MtGoldenFixture.ps1 rather than edited by hand, as the file itself asks. --- powershell/tests/fixtures/golden/selection.json | 12 ++++++------ .../functions/Test-MtAzureDefenderForCloud.Tests.ps1 | 4 ++-- .../azure/{Test.MT.1257.md => Test.MT.1271.md} | 0 .../azure/{Test.MT.1257.ps1 => Test.MT.1271.ps1} | 8 ++++---- .../azure/{Test.MT.1258.md => Test.MT.1272.md} | 0 .../azure/{Test.MT.1258.ps1 => Test.MT.1272.ps1} | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) rename tests/maester/azure/{Test.MT.1257.md => Test.MT.1271.md} (100%) rename tests/maester/azure/{Test.MT.1257.ps1 => Test.MT.1271.ps1} (97%) rename tests/maester/azure/{Test.MT.1258.md => Test.MT.1272.md} (100%) rename tests/maester/azure/{Test.MT.1258.ps1 => Test.MT.1272.ps1} (97%) diff --git a/powershell/tests/fixtures/golden/selection.json b/powershell/tests/fixtures/golden/selection.json index 0c6032140c..b1b521fa59 100644 --- a/powershell/tests/fixtures/golden/selection.json +++ b/powershell/tests/fixtures/golden/selection.json @@ -2448,11 +2448,11 @@ "MT.1250", "MT.1251", "MT.1252", - "MT.1257", - "MT.1258", "MT.1259", "MT.1260", "MT.1265", + "MT.1271", + "MT.1272", "ORCA.100", "ORCA.101", "ORCA.102", @@ -3093,11 +3093,11 @@ "MT.1250", "MT.1251", "MT.1252", - "MT.1257", - "MT.1258", "MT.1259", "MT.1260", "MT.1265", + "MT.1271", + "MT.1272", "ORCA.100", "ORCA.101", "ORCA.102", @@ -4447,11 +4447,11 @@ "MT.1250", "MT.1251", "MT.1252", - "MT.1257", - "MT.1258", "MT.1259", "MT.1260", "MT.1265", + "MT.1271", + "MT.1272", "ORCA.100", "ORCA.101", "ORCA.102", diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 index 661a3e944b..f28ade9300 100644 --- a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -64,7 +64,7 @@ } } - Context 'MT.1257 recommendations' { + Context 'MT.1271 recommendations' { It 'passes when no resource is unhealthy' { $i = [pscustomobject]@{ Data = Get-TestRecommendation -Unhealthy 0 -Healthy 5 } @@ -129,7 +129,7 @@ } } - Context 'MT.1258 attack paths' { + Context 'MT.1272 attack paths' { It 'reports the family as not licensed when Defender CSPM is off' { # Without the plan no attack path was ever computed, so an empty result says nothing. Mock -ModuleName Maester Get-MtDefenderForCloudAttackPath { diff --git a/tests/maester/azure/Test.MT.1257.md b/tests/maester/azure/Test.MT.1271.md similarity index 100% rename from tests/maester/azure/Test.MT.1257.md rename to tests/maester/azure/Test.MT.1271.md diff --git a/tests/maester/azure/Test.MT.1257.ps1 b/tests/maester/azure/Test.MT.1271.ps1 similarity index 97% rename from tests/maester/azure/Test.MT.1257.ps1 rename to tests/maester/azure/Test.MT.1271.ps1 index 1cd66c529b..4874306085 100644 --- a/tests/maester/azure/Test.MT.1257.ps1 +++ b/tests/maester/azure/Test.MT.1271.ps1 @@ -1,11 +1,11 @@ function Get-MtAzureDefenderForCloudRecommendationInstance { <# .SYNOPSIS - Returns one MT.1257 instance per Microsoft Defender for Cloud recommendation. + Returns one MT.1271 instance per Microsoft Defender for Cloud recommendation. .DESCRIPTION - Instance source of the MT.1257 family. The suffix is the recommendation's assessment key - (MT.1257.) and the title names the recommendation, the way MT.1024 does for Entra + Instance source of the MT.1271 family. The suffix is the recommendation's assessment key + (MT.1271.) and the title names the recommendation, the way MT.1024 does for Entra recommendations. One instance per recommendation, never one per resource: a large estate produces thousands of assessment rows and only hundreds of recommendations. @@ -86,7 +86,7 @@ function Test-MtAzureDefenderForCloudRecommendation { https://maester.dev/docs/commands/Test-MtAzureDefenderForCloudRecommendation #> [MaesterTest( - Id = 'MT.1257', + Id = 'MT.1271', Title = 'Resources should be healthy for the Microsoft Defender for Cloud recommendations.', Product = 'azure', Feature = 'subscriptions', diff --git a/tests/maester/azure/Test.MT.1258.md b/tests/maester/azure/Test.MT.1272.md similarity index 100% rename from tests/maester/azure/Test.MT.1258.md rename to tests/maester/azure/Test.MT.1272.md diff --git a/tests/maester/azure/Test.MT.1258.ps1 b/tests/maester/azure/Test.MT.1272.ps1 similarity index 97% rename from tests/maester/azure/Test.MT.1258.ps1 rename to tests/maester/azure/Test.MT.1272.ps1 index 7d035c9305..01912fb929 100644 --- a/tests/maester/azure/Test.MT.1258.ps1 +++ b/tests/maester/azure/Test.MT.1272.ps1 @@ -1,10 +1,10 @@ function Get-MtAzureDefenderForCloudAttackPathInstance { <# .SYNOPSIS - Returns one MT.1258 instance per Microsoft Defender for Cloud attack path. + Returns one MT.1272 instance per Microsoft Defender for Cloud attack path. .DESCRIPTION - Instance source of the MT.1258 family. One instance per attack path, titled with the path itself, + Instance source of the MT.1272 family. One instance per attack path, titled with the path itself, which Defender for Cloud phrases as a sentence naming the entry point and the target. When Defender CSPM is not enabled on any readable subscription the source reports the family as not @@ -81,7 +81,7 @@ function Test-MtAzureDefenderForCloudAttackPath { https://maester.dev/docs/commands/Test-MtAzureDefenderForCloudAttackPath #> [MaesterTest( - Id = 'MT.1258', + Id = 'MT.1272', Title = 'Microsoft Defender for Cloud should report no active attack path.', Product = 'azure', Feature = 'subscriptions', From 5bbe44f60f37950bf3bced9b52cf9b2d93e4eb0f Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sun, 8 Nov 2026 10:28:13 -0400 Subject: [PATCH 09/10] refactor(azure): English identifiers, own file for the helper, escaped names The rest of @merill's review on this PR. - Every identifier is English now. The KQL columns were Spanish ('nombre', 'severidad', 'rangoRiesgo', 'riesgo', 'factores', 'tacticas', 'origen', 'estado', 'nombreDestino') and so were two PowerShell variables ('etiquetaRecursos', 'etiquetaDestino'). 43 substitutions across four files, word-bounded; the projected output columns were already English and are unchanged, so nothing downstream moves. - ConvertFrom-MtJsonArray was nested inside Get-MtDefenderForCloudAttackPath. It now lives in internal/utility/ next to ConvertFrom-QueryString, one function per file, with the help block explaining why a malformed array is an empty array rather than a throw. - Resource names in MT.1271 and attack-path target names in MT.1272 go through Get-MtSafeMarkdown. Entry-point and target resource types, risk factors and MITRE tactics are left alone: those come from Microsoft's taxonomy, not the tenant. - RelatedProduct = 'defender' on both, matching MT.1266. --- .../Get-MtDefenderForCloudAttackPath.ps1 | 27 +++++++---------- .../Get-MtDefenderForCloudRecommendation.ps1 | 30 +++++++++---------- .../utility/ConvertFrom-MtJsonArray.ps1 | 25 ++++++++++++++++ .../Test-MtAzureDefenderForCloud.Tests.ps1 | 6 ++-- tests/maester/azure/Test.MT.1271.ps1 | 7 +++-- tests/maester/azure/Test.MT.1272.ps1 | 7 +++-- 6 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 powershell/internal/utility/ConvertFrom-MtJsonArray.ps1 diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 index f68017821f..ec7772d203 100644 --- a/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudAttackPath.ps1 @@ -49,27 +49,27 @@ securityresources $pathQuery = @' securityresources | where type == "microsoft.security/attackpaths" -| extend nombre = tostring(properties.displayName), - riesgo = tostring(properties.riskLevel), +| extend displayName = tostring(properties.displayName), + risk = tostring(properties.riskLevel), parcial = tostring(properties.isPartialAttackPath), - factores = tostring(properties.riskFactors), - tacticas = tostring(properties.mITRETacticsAndTechniques.tactics), + riskFactors = tostring(properties.riskFactors), + tactics = tostring(properties.mITRETacticsAndTechniques.tactics), tipoEntrada = tostring(properties.entryPoint.entityType), - nombreDestino = tostring(properties.target.entityName), + targetName = tostring(properties.target.entityName), tipoDestino = tostring(properties.target.entityType) // A risk level is per occurrence, so a group holds several. any() picked one at random, and it // picked independently for the risk factors and the tactics, so the three could describe different // occurrences of the same attack path type. arg_max takes all three from the one that ranks worst. -| extend rangoRiesgo = case(riesgo =~ "Critical", 4, riesgo =~ "High", 3, riesgo =~ "Medium", 2, riesgo =~ "Low", 1, 0) +| extend riskRank = case(risk =~ "Critical", 4, risk =~ "High", 3, risk =~ "Medium", 2, risk =~ "Low", 1, 0) | summarize PathCount = count(), - DisplayName = any(nombre), + DisplayName = any(displayName), Partial = any(parcial), EntryPointTypeList = make_set(tipoEntrada, 10), - TargetList = make_set(nombreDestino, 10), + TargetList = make_set(targetName, 10), // make_set is capped, so the consumer needs to know when it is showing a subset. - TargetTotal = dcount(nombreDestino), + TargetTotal = dcount(targetName), TargetTypeList = make_set(tipoDestino, 10), - (RiskRank, RiskLevel, RiskFactorsJson, TacticsJson) = arg_max(rangoRiesgo, riesgo, factores, tacticas) + (RiskRank, RiskLevel, RiskFactorsJson, TacticsJson) = arg_max(riskRank, risk, riskFactors, tactics) by AttackPathType = tostring(properties.attackPathType) | project-away RiskRank | sort by PathCount desc, AttackPathType asc @@ -78,13 +78,6 @@ securityresources Write-Verbose 'Querying Defender for Cloud attack paths...' $rows = @(Invoke-MtAzureResourceGraphRequest -Query $pathQuery) - # The arrays arrive as JSON text because Azure Resource Graph has no mv-apply. - function ConvertFrom-MtJsonArray { - param([string] $Text) - if ([string]::IsNullOrWhiteSpace($Text)) { return @() } - try { return @($Text | ConvertFrom-Json) } catch { return @() } - } - $paths = [System.Collections.Generic.List[pscustomobject]]::new() foreach ($row in $rows) { if (-not $row -or [string]::IsNullOrWhiteSpace([string]$row.AttackPathType)) { continue } diff --git a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 index 1b47b39b14..4bd7b82f37 100644 --- a/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 +++ b/powershell/internal/services/azure/Get-MtDefenderForCloudRecommendation.ps1 @@ -38,30 +38,30 @@ securityresources // Multicloud connectors surface AWS and GCP assessments in the same table, and their counts // would flow into an Azure test. Native Azure resources have no Source, so the empty string is // kept deliberately: filtering on Source == "Azure" alone would return nothing. -| extend origen = tostring(properties.resourceDetails.Source) -| where origen == "" or origen =~ "Azure" -| extend estado = tostring(properties.status.code), +| extend source = tostring(properties.resourceDetails.Source) +| where source == "" or source =~ "Azure" +| extend status = tostring(properties.status.code), causa = tostring(properties.status.cause), - nombre = tostring(properties.displayName), - severidad = tostring(properties.metadata.severity), - riesgo = tostring(properties.risk.level), + displayName = tostring(properties.displayName), + severity = tostring(properties.metadata.severity), + risk = tostring(properties.risk.level), portal = tostring(properties.links.azurePortal) // A risk level is per resource, so a group holds several. any() picks one at random and could // report Low for a key that is Critical somewhere. Ranked and maxed, the group reports its worst. -| extend rangoRiesgo = case(riesgo =~ "Critical", 4, riesgo =~ "High", 3, riesgo =~ "Medium", 2, riesgo =~ "Low", 1, 0) +| extend riskRank = case(risk =~ "Critical", 4, risk =~ "High", 3, risk =~ "Medium", 2, risk =~ "Low", 1, 0) | summarize TotalCount = count(), - UnhealthyCount = countif(estado == "Unhealthy"), - HealthyCount = countif(estado == "Healthy"), - NotApplicableCount = countif(estado == "NotApplicable"), + UnhealthyCount = countif(status == "Unhealthy"), + HealthyCount = countif(status == "Healthy"), + NotApplicableCount = countif(status == "NotApplicable"), ExemptCount = countif(causa == "Exempt"), - UnhealthyResourceList = make_set_if(tostring(split(id, "/")[8]), estado == "Unhealthy", 10), - UnhealthyResourceTotal = dcountif(tostring(split(id, "/")[8]), estado == "Unhealthy"), + UnhealthyResourceList = make_set_if(tostring(split(id, "/")[8]), status == "Unhealthy", 10), + UnhealthyResourceTotal = dcountif(tostring(split(id, "/")[8]), status == "Unhealthy"), // any() is correct for these three: they belong to the assessment definition, so they // are the same on every row of the group. - DisplayName = any(nombre), - Severity = any(severidad), + DisplayName = any(displayName), + Severity = any(severity), PortalUri = any(portal), - RiskRank = max(rangoRiesgo) + RiskRank = max(riskRank) by AssessmentKey = name | extend RiskLevel = case(RiskRank == 4, "Critical", RiskRank == 3, "High", RiskRank == 2, "Medium", RiskRank == 1, "Low", "") | project-away RiskRank diff --git a/powershell/internal/utility/ConvertFrom-MtJsonArray.ps1 b/powershell/internal/utility/ConvertFrom-MtJsonArray.ps1 new file mode 100644 index 0000000000..7b50c0e410 --- /dev/null +++ b/powershell/internal/utility/ConvertFrom-MtJsonArray.ps1 @@ -0,0 +1,25 @@ +function ConvertFrom-MtJsonArray { + <# + .SYNOPSIS + Reads a JSON array that arrived as text and returns its items, or an empty array. + + .DESCRIPTION + Azure Resource Graph has no `mv-apply`, so a query that needs to return an array packs it + into a JSON string. This unpacks it. Empty, whitespace and malformed text all return an + empty array rather than throwing: the caller is building a report row, and a value it + cannot parse is a missing value, not a reason to fail the check. + + .EXAMPLE + ConvertFrom-MtJsonArray -Text '["a","b"]' + + Returns a and b. + #> + [CmdletBinding()] + [OutputType([object[]])] + param( + [string] $Text + ) + + if ([string]::IsNullOrWhiteSpace($Text)) { return @() } + try { return @($Text | ConvertFrom-Json) } catch { return @() } +} diff --git a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 index f28ade9300..0d3bd0f319 100644 --- a/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 +++ b/powershell/tests/functions/Test-MtAzureDefenderForCloud.Tests.ps1 @@ -190,10 +190,10 @@ # query instead of asserting on a string. It 'takes the worst risk level of a group, not an arbitrary one' { - # `any(riesgo)` is non-deterministic by contract, so a key that is Critical on one + # `any(risk)` is non-deterministic by contract, so a key that is Critical on one # resource could be reported Low. Ranked and maxed, the group reports its worst. Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { - if ($Query -match 'max\(rangoRiesgo\)') { + if ($Query -match 'max\(riskRank\)') { return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'Critical'; PortalUri = ''; TotalCount = 2; UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) } return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'Low'; PortalUri = ''; TotalCount = 2; UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) @@ -208,7 +208,7 @@ # is kept on purpose: native Azure resources have none, so filtering on "Azure" alone # would return nothing at all. Mock -ModuleName Maester Invoke-MtAzureResourceGraphRequest { - $conFiltro = $Query -match 'origen == "" or origen =~ "Azure"' + $conFiltro = $Query -match 'source == "" or source =~ "Azure"' return @([pscustomobject]@{ AssessmentKey = 'k1'; DisplayName = 'Una recomendacion'; Severity = 'Medium'; RiskLevel = 'High'; PortalUri = ''; TotalCount = $(if ($conFiltro) { 2 } else { 5 }); UnhealthyCount = 1; HealthyCount = 1; NotApplicableCount = 0; ExemptCount = 0; UnhealthyResourceList = @('r1'); UnhealthyResourceTotal = 1 }) } diff --git a/tests/maester/azure/Test.MT.1271.ps1 b/tests/maester/azure/Test.MT.1271.ps1 index 4874306085..13143d70e7 100644 --- a/tests/maester/azure/Test.MT.1271.ps1 +++ b/tests/maester/azure/Test.MT.1271.ps1 @@ -89,6 +89,7 @@ function Test-MtAzureDefenderForCloudRecommendation { Id = 'MT.1271', Title = 'Resources should be healthy for the Microsoft Defender for Cloud recommendations.', Product = 'azure', + RelatedProduct = 'defender', Feature = 'subscriptions', Area = 'infrastructure', ResourceType = 'AzureResource', @@ -151,8 +152,10 @@ function Test-MtAzureDefenderForCloudRecommendation { $resources = @($recommendation.UnhealthyResourceList | Where-Object { $_ }) if ($resources.Count -gt 0) { # "up to ten shown" does not tell the reader whether ten is all of them. The total does. - $etiquetaRecursos = if ([int]$recommendation.UnhealthyResourceTotal -gt $resources.Count) { "$($resources.Count) of $([int]$recommendation.UnhealthyResourceTotal)" } else { 'all' } - $testResultMarkdown += "`nUnhealthy resources ($etiquetaRecursos): $($resources -join ', ')`n" + $resourceLabel = if ([int]$recommendation.UnhealthyResourceTotal -gt $resources.Count) { "$($resources.Count) of $([int]$recommendation.UnhealthyResourceTotal)" } else { 'all' } + # Resource names come from the tenant, so they are escaped before reaching Markdown. + $safeResources = @($resources | ForEach-Object { Get-MtSafeMarkdown $_ }) + $testResultMarkdown += "`nUnhealthy resources ($resourceLabel): $($safeResources -join ', ')`n" } if (-not [string]::IsNullOrWhiteSpace($recommendation.PortalUri)) { $testResultMarkdown += "`n[Open this recommendation in the Azure portal]($($recommendation.PortalUri))`n" diff --git a/tests/maester/azure/Test.MT.1272.ps1 b/tests/maester/azure/Test.MT.1272.ps1 index 01912fb929..70d09345a2 100644 --- a/tests/maester/azure/Test.MT.1272.ps1 +++ b/tests/maester/azure/Test.MT.1272.ps1 @@ -84,6 +84,7 @@ function Test-MtAzureDefenderForCloudAttackPath { Id = 'MT.1272', Title = 'Microsoft Defender for Cloud should report no active attack path.', Product = 'azure', + RelatedProduct = 'defender', Feature = 'subscriptions', Area = 'infrastructure', ResourceType = 'AzureResource', @@ -115,8 +116,10 @@ function Test-MtAzureDefenderForCloudAttackPath { if ($target.Count -gt 0) { # The list is capped server side, so say when it is a sample. Without this the reader # cannot tell ten targets from ten of thirty-seven. - $etiquetaDestino = if ([int]$path.TargetTotal -gt $target.Count) { "Target ($($target.Count) of $([int]$path.TargetTotal))" } else { 'Target' } - $testResultMarkdown += "| $etiquetaDestino | $($target -join ', ') |`n" + $targetLabel = if ([int]$path.TargetTotal -gt $target.Count) { "Target ($($target.Count) of $([int]$path.TargetTotal))" } else { 'Target' } + # Target names are tenant resources, so they are escaped before reaching Markdown. + $safeTargets = @($target | ForEach-Object { Get-MtSafeMarkdown $_ }) + $testResultMarkdown += "| $targetLabel | $($safeTargets -join ', ') |`n" } $targetType = @($path.TargetTypeList | Where-Object { $_ }) if ($targetType.Count -gt 0) { $testResultMarkdown += "| Target resource type | $($targetType -join ', ') |`n" } From f012c22a392c5f8d660ccffaf563595f4c278681 Mon Sep 17 00:00:00 2001 From: Eduard Arbona <175124143+earbona23@users.noreply.github.com> Date: Sun, 8 Nov 2026 10:56:14 -0400 Subject: [PATCH 10/10] style: canonical attribute property order Ran the files through build/migration/Convert-MtTestAttributes.ps1, which the repo uses to keep [MaesterTest(...)] properties in one order. main reports Reordered=0 and these were the only files in the tree that did not, which came from how they were written rather than from any change in behaviour. The tool now reports Changed=0 Reordered=0 here too. No values were altered. --- tests/maester/azure/Test.MT.1271.ps1 | 2 +- tests/maester/azure/Test.MT.1272.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/maester/azure/Test.MT.1271.ps1 b/tests/maester/azure/Test.MT.1271.ps1 index 13143d70e7..f6d3e3a866 100644 --- a/tests/maester/azure/Test.MT.1271.ps1 +++ b/tests/maester/azure/Test.MT.1271.ps1 @@ -97,8 +97,8 @@ function Test-MtAzureDefenderForCloudRecommendation { UserImpact = 'Low', ImplementationCost = 'Medium', Mitre = 'None', - Lifecycle = 'Preview', Service = 'Azure', + Lifecycle = 'Preview', InstanceSource = 'Get-MtAzureDefenderForCloudRecommendationInstance', Author = 'earbona23' )] diff --git a/tests/maester/azure/Test.MT.1272.ps1 b/tests/maester/azure/Test.MT.1272.ps1 index 70d09345a2..81557041b6 100644 --- a/tests/maester/azure/Test.MT.1272.ps1 +++ b/tests/maester/azure/Test.MT.1272.ps1 @@ -92,8 +92,8 @@ function Test-MtAzureDefenderForCloudAttackPath { UserImpact = 'Low', ImplementationCost = 'Medium', Mitre = ('T1190', 'T1552'), - Lifecycle = 'Preview', Service = 'Azure', + Lifecycle = 'Preview', InstanceSource = 'Get-MtAzureDefenderForCloudAttackPathInstance', Author = 'earbona23' )]