Skip to content

Commit 2361da3

Browse files
authored
Merge pull request #1083 from microsoft/Feature-25411
Network 25411: TLS inspection is enabled and correctly configured for outbound traffic - Spec Update
2 parents 961242f + 8a86b54 commit 2361da3

1 file changed

Lines changed: 54 additions & 53 deletions

File tree

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

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.SYNOPSIS
33
TLS inspection is enabled and correctly configured for outbound traffic in Global Secure Access.
44
.DESCRIPTION
5-
Verifies that a TLS Inspection policy is properly configured. It will fail if no TLS Inspection policy exists, if the policy is not linked to a Security Profile, or if no Conditional Access policy assigning that Security Profile can be identified.
5+
Verifies that a TLS Inspection policy is properly configured. It will fail if no TLS Inspection policy exists, if the policy is not linked to a Baseline or Security Profile with an enabled policy link, or (for Security Profiles) if no enabled Conditional Access policy assigning that profile can be identified.
66
#>
77

88
function Test-Assessment-25411 {
@@ -38,8 +38,8 @@ function Test-Assessment-25411 {
3838
# Step 2: List all policies in the Baseline Profile and in each Security Profile
3939
Write-ZtProgress -Activity $activity -Status 'Querying filtering profiles and policies'
4040
$filteringProfiles = Invoke-ZtGraphRequest -RelativeUri 'networkAccess/filteringProfiles' -QueryParameters @{
41-
'$select' = 'id,name,description,state,version,priority'
42-
'$expand' = 'policies($select=id,state;$expand=policy($select=id,name,version)),conditionalAccessPolicies($select=id,displayName)'
41+
'$select' = 'id,name,description,state,priority'
42+
'$expand' = 'policies($select=id,state;$expand=policy($select=id,name,version))'
4343
} -ApiVersion beta
4444

4545
# Query all Conditional Access policies with details
@@ -50,8 +50,8 @@ function Test-Assessment-25411 {
5050

5151
#region Data Processing
5252
# Graph responses are automatically unwrapped by Invoke-ZtGraphRequest
53-
$enabledSecurityProfiles = @()
54-
$enabledBaseLineProfiles = @()
53+
$baselineProfileResults = [System.Collections.Generic.List[object]]::new()
54+
$securityProfileResults = [System.Collections.Generic.List[object]]::new()
5555

5656
# Iterate each TLS inspection policy and find linked profiles using the helper function
5757
foreach ($tlsPolicy in $tlsInspectionPolicies) {
@@ -67,24 +67,25 @@ function Test-Assessment-25411 {
6767
$linkedProfiles = Find-ZtProfilesLinkedToPolicy @findParams
6868

6969
foreach ($policyProfile in $linkedProfiles) {
70-
if ($policyProfile.ProfileType -eq 'Baseline Profile' -and $policyProfile.PassesCriteria -and $policyProfile.ProfileState -eq 'enabled') {
71-
$enabledBaseLineProfiles += [PSCustomObject]@{
70+
if ($policyProfile.ProfileType -eq 'Baseline Profile') {
71+
$baselineProfileResults.Add([PSCustomObject]@{
7272
ProfileId = $policyProfile.ProfileId
7373
ProfileName = $policyProfile.ProfileName
7474
ProfileState = $policyProfile.ProfileState
7575
ProfilePriority = $policyProfile.ProfilePriority
7676
TLSPolicyId = $tlsPolicy.id
7777
TLSPolicyName = $tlsPolicy.name
7878
TLSPolicyLinkState = $policyProfile.PolicyLinkState
79-
}
79+
})
8080
}
81-
elseif ($policyProfile.ProfileType -eq 'Security Profile' -and $policyProfile.PassesCriteria -and $policyProfile.ProfileState -eq 'enabled') {
81+
elseif ($policyProfile.ProfileType -eq 'Security Profile') {
8282
$matchedCAPolicies = @()
8383
if ($null -ne $policyProfile.CAPolicy) {
8484
$matchedCAPolicies = @($policyProfile.CAPolicy)
8585
}
8686

87-
$enabledSecurityProfiles += [PSCustomObject]@{
87+
# Collect all linked security profiles for table display (regardless of state or CA policy linkage)
88+
$securityProfileResults.Add([PSCustomObject]@{
8889
ProfileId = $policyProfile.ProfileId
8990
ProfileName = $policyProfile.ProfileName
9091
ProfileState = $policyProfile.ProfileState
@@ -93,18 +94,18 @@ function Test-Assessment-25411 {
9394
TLSPolicyName = $tlsPolicy.name
9495
TLSPolicyLinkState = $policyProfile.PolicyLinkState
9596
MatchedCAPolicies = $matchedCAPolicies
96-
CAPolicyCount = $matchedCAPolicies.Count
97-
DefaultAction = if ($null -ne $tlsPolicy.settings) {
98-
$tlsPolicy.settings.defaultAction
99-
}
100-
else {
101-
'unknown'
102-
}
103-
}
97+
PassesCriteria = $policyProfile.PassesCriteria
98+
})
10499
}
105100
}
106101
}
107102

103+
# Baseline profiles that pass: both policy link state and profile state must be enabled
104+
$enabledBaselineProfiles = @($baselineProfileResults | Where-Object { $_.ProfileState -eq 'enabled' -and $_.TLSPolicyLinkState -eq 'enabled' })
105+
106+
# Security profiles that pass: profile enabled, policy link enabled, and at least one enabled CA policy linked
107+
$enabledSecurityProfiles = @($securityProfileResults | Where-Object { $_.ProfileState -eq 'enabled' -and $_.TLSPolicyLinkState -eq 'enabled' -and $_.PassesCriteria })
108+
108109
#endregion Data Processing
109110
#region Assessment logic
110111

@@ -114,13 +115,8 @@ function Test-Assessment-25411 {
114115

115116
if ($null -eq $tlsInspectionPolicies -or $tlsInspectionPolicies.Count -eq 0) {
116117
$testResultMarkdown = "❌ TLS Inspection Policy has not been properly configured. `n`n%TestResult%"
117-
$passed = $false
118118
}
119-
elseif ($enabledBaseLineProfiles.Count -gt 0) {
120-
$testResultMarkdown = "✅ TLS Inspection Policy is enabled and properly configured to inspect encrypted outbound traffic.`n`n%TestResult%"
121-
$passed = $true
122-
}
123-
elseif ($enabledSecurityProfiles.Count -gt 0) {
119+
elseif ($enabledBaselineProfiles.Count -gt 0 -or $enabledSecurityProfiles.Count -gt 0) {
124120
$testResultMarkdown = "✅ TLS Inspection Policy is enabled and properly configured to inspect encrypted outbound traffic.`n`n%TestResult%"
125121
$passed = $true
126122
}
@@ -133,47 +129,52 @@ function Test-Assessment-25411 {
133129

134130
#region Report Generation
135131

136-
if ($enabledBaseLineProfiles.Count -gt 0) {
132+
if ($baselineProfileResults.Count -gt 0) {
137133

138134
$mdInfo += "`n## TLS Inspection Policies Linked to Baseline Profiles`n`n"
139-
$mdInfo += "| Linked Profile Name | Linked Profile Priority | Linked Policy Name | Policy Link State | Profile State |`n"
135+
$mdInfo += "| Linked profile name | Linked profile priority | Linked policy name | Policy link state | Profile state |`n"
140136
$mdInfo += "| :--- | :--- | :--- | :--- | :--- |`n"
141-
foreach ($policy in $enabledBaseLineProfiles) {
142-
$baseLineProfilePortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditProfileMenuBlade.MenuView/~/basics/profileId/$(($policy.ProfileId))"
137+
foreach ($policy in $baselineProfileResults) {
138+
$baselineProfilePortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditProfileMenuBlade.MenuView/~/basics/profileId/$(($policy.ProfileId))"
143139
$tlsPolicyPortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditTlsInspectionPolicyMenuBlade.MenuView/~/basics/policyId/$(($policy.TLSPolicyId))"
144140
$profileName = Get-SafeMarkdown -Text $policy.ProfileName
145141
$profilePriority = $policy.ProfilePriority
146142
$tlsPolicyName = Get-SafeMarkdown -Text $policy.TLSPolicyName
147-
$tlsPolicyLinkState = $policy.TLSPolicyLinkState
148-
$profileState = $policy.ProfileState
149-
$mdInfo += "| [$profileName]($baseLineProfilePortalLink) | $profilePriority | [$tlsPolicyName]($tlsPolicyPortalLink) | $tlsPolicyLinkState | $profileState |`n"
143+
$tlsPolicyLinkState = if ($policy.TLSPolicyLinkState -eq 'enabled') { '✅ Enabled' } else { '❌ Disabled' }
144+
$profileState = if ($policy.ProfileState -eq 'enabled') { '✅ Enabled' } else { '❌ Disabled' }
145+
$mdInfo += "| [$profileName]($baselineProfilePortalLink) | $profilePriority | [$tlsPolicyName]($tlsPolicyPortalLink) | $tlsPolicyLinkState | $profileState |`n"
150146
}
151147
}
152148

153-
if ($enabledSecurityProfiles.Count -gt 0) {
154-
$mdInfo += "`n## Security Profiles Linked to Conditional Access Policies`n`n"
155-
$mdInfo += "| Linked Profile Name | Linked Profile Priority | CA Policy Names | CA Policy State | Profile State | TLS Inspection Policy Name | Default Action |`n"
149+
if ($securityProfileResults.Count -gt 0) {
150+
$mdInfo += "`n## TLS Inspection Policies Linked to Security Profiles`n`n"
151+
$mdInfo += "| Linked profile name | Linked profile priority | Linked policy name | Policy link state | Profile state | CA policy name | CA policy state |`n"
156152
$mdInfo += "| :--- | :--- | :--- | :--- | :--- | :--- | :--- |`n"
157-
foreach ($enabledProfile in $enabledSecurityProfiles) {
158-
$securityProfilePortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditProfileMenuBlade.MenuView/~/basics/profileId/$(($enabledProfile.ProfileId))"
159-
$tlsPolicyPortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditTlsInspectionPolicyMenuBlade.MenuView/~/basics/policyId/$(($enabledProfile.TLSPolicyId))"
160-
$profileName = Get-SafeMarkdown -Text $enabledProfile.ProfileName
161-
$profilePriority = $enabledProfile.ProfilePriority
162-
# Build CA policy links
163-
$caPolicyLinksMarkdown = @()
164-
$caPolicyStatesList = @()
165-
foreach ($caPolicy in $enabledProfile.MatchedCAPolicies) {
166-
$caPolicyPortalLink = "https://entra.microsoft.com/#view/Microsoft_AAD_ConditionalAccess/PolicyBlade/policyId/$($caPolicy.Id)"
167-
$safeName = Get-SafeMarkdown -Text $caPolicy.DisplayName
168-
$caPolicyLinksMarkdown += "[$safeName]($caPolicyPortalLink)"
169-
$caPolicyStatesList += $caPolicy.State
153+
foreach ($profile in $securityProfileResults) {
154+
$securityProfilePortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditProfileMenuBlade.MenuView/~/basics/profileId/$(($profile.ProfileId))"
155+
$tlsPolicyPortalLink = "https://entra.microsoft.com/#view/Microsoft_Azure_Network_Access/EditTlsInspectionPolicyMenuBlade.MenuView/~/basics/policyId/$(($profile.TLSPolicyId))"
156+
$profileName = Get-SafeMarkdown -Text $profile.ProfileName
157+
$profilePriority = $profile.ProfilePriority
158+
$tlsPolicyName = Get-SafeMarkdown -Text $profile.TLSPolicyName
159+
$tlsPolicyLinkState = if ($profile.TLSPolicyLinkState -eq 'enabled') { '✅ Enabled' } else { '❌ Disabled' }
160+
$profileState = if ($profile.ProfileState -eq 'enabled') { '✅ Enabled' } else { '❌ Disabled' }
161+
if ($profile.MatchedCAPolicies.Count -gt 0) {
162+
$caPolicyLinksMarkdown = [System.Collections.Generic.List[string]]::new()
163+
$caPolicyStatesList = [System.Collections.Generic.List[string]]::new()
164+
foreach ($caPolicy in $profile.MatchedCAPolicies) {
165+
$caPolicyPortalLink = "https://entra.microsoft.com/#view/Microsoft_AAD_ConditionalAccess/PolicyBlade/policyId/$($caPolicy.Id)"
166+
$safeName = Get-SafeMarkdown -Text $caPolicy.DisplayName
167+
$caPolicyLinksMarkdown.Add("[$safeName]($caPolicyPortalLink)")
168+
$caPolicyStatesList.Add($(if ($caPolicy.State -eq 'enabled') { '✅ Enabled' } elseif ($caPolicy.State -eq 'enabledForReportingButNotEnforced') { '⚠️ Report Only' } else { '❌ Disabled' }))
169+
}
170+
$caPolicyNamesLinked = $caPolicyLinksMarkdown -join ', '
171+
$caPolicyStates = $caPolicyStatesList -join ', '
172+
}
173+
else {
174+
$caPolicyNamesLinked = 'Missing'
175+
$caPolicyStates = 'Missing'
170176
}
171-
$caPolicyNamesLinked = $caPolicyLinksMarkdown -join ', '
172-
$caPolicyStates = $caPolicyStatesList -join ', '
173-
$profileState = $enabledProfile.ProfileState
174-
$tlsPolicyName = Get-SafeMarkdown -Text $enabledProfile.TLSPolicyName
175-
$defaultAction = $enabledProfile.DefaultAction
176-
$mdInfo += "| [$profileName]($securityProfilePortalLink) | $profilePriority | $caPolicyNamesLinked | $caPolicyStates | $profileState | [$tlsPolicyName]($tlsPolicyPortalLink) | $defaultAction |`n"
177+
$mdInfo += "| [$profileName]($securityProfilePortalLink) | $profilePriority | [$tlsPolicyName]($tlsPolicyPortalLink) | $tlsPolicyLinkState | $profileState | $caPolicyNamesLinked | $caPolicyStates |`n"
177178
}
178179
}
179180

0 commit comments

Comments
 (0)