Skip to content

Commit 0308dc3

Browse files
authored
feature: 41050 - handle missing profile in Q1 scenario (#1511)
2 parents 707a647 + 7ffd111 commit 0308dc3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/powershell/tests/Test-Assessment.41050.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function Test-Assessment-41050 {
103103
}
104104
}
105105

106-
if ($controlProfileError -or $secureScoreError -or $null -eq $latestSecureScore -or $controlProfileById.Count -eq 0) {
106+
if ($controlProfileError -or $secureScoreError -or $null -eq $latestSecureScore) {
107107
$params = @{
108108
TestId = '41050'
109109
Title = 'Attack surface reduction (ASR) rules are enabled in block mode'
@@ -125,7 +125,7 @@ function Test-Assessment-41050 {
125125
$evaluationResults = @()
126126
foreach ($controlId in $asrControlIds) {
127127
$controlProfile = if ($controlProfileById.ContainsKey($controlId)) { $controlProfileById[$controlId] } else { $null }
128-
$matchingScore = if ($controlScoreByName.ContainsKey($controlId)) { $controlScoreByName[$controlId] } else { $null }
128+
$matchingScore = if ($null -ne $controlProfile -and $controlScoreByName.ContainsKey($controlId)) { $controlScoreByName[$controlId] } else { $null }
129129

130130
$score = if ($null -ne $matchingScore -and $null -ne $matchingScore.score) { $matchingScore.score } else { $null }
131131
$maxScore = if ($null -ne $controlProfile -and $null -ne $controlProfile.maxScore) { $controlProfile.maxScore } else { $null }
@@ -156,10 +156,13 @@ function Test-Assessment-41050 {
156156
catch { }
157157
}
158158

159+
$notApplicableReason = $null
159160
$status = if ($null -eq $controlProfile) {
160-
'Investigate'
161+
$notApplicableReason = 'profile not found'
162+
'N/A'
161163
}
162164
elseif ($null -eq $matchingScore) {
165+
$notApplicableReason = 'no applicable devices'
163166
'N/A'
164167
}
165168
elseif ($isIgnored) {
@@ -191,6 +194,7 @@ function Test-Assessment-41050 {
191194
ImplementationStatus = if ($null -ne $matchingScore -and -not [string]::IsNullOrWhiteSpace($matchingScore.implementationStatus)) { $matchingScore.implementationStatus } else { 'N/A' }
192195
LastModifiedDateTime = if ($null -ne $controlProfile) { $controlProfile.lastModifiedDateTime } else { $null }
193196
Status = $status
197+
NotApplicableReason = $notApplicableReason
194198
}
195199
}
196200

@@ -224,7 +228,7 @@ function Test-Assessment-41050 {
224228
'Pass' { '✅ Pass' }
225229
'Fail' { '❌ Fail' }
226230
'Investigate' { '⚠️ Investigate' }
227-
'N/A' { 'N/A (no applicable devices)' }
231+
'N/A' { "N/A ($($result.NotApplicableReason))" }
228232
default { 'Skipped' }
229233
}
230234
$lastModified = if ($result.LastModifiedDateTime) { Get-FormattedDate -DateString $result.LastModifiedDateTime } else { 'N/A' }

0 commit comments

Comments
 (0)