Private/AzStackHci.Connectivity.Helpers.ps1

# ////////////////////////////////////////////////////////////////////////////
# Strict Mode v1 (PS 5.1 safe) - surfaces reads of uninitialised variables at runtime.
Set-StrictMode -Version 1.0

# Function to test version of PowerShell
# Returns $true on Windows PowerShell 5.1 and $false on PowerShell 6/7+.
# Uses PSEdition ('Desktop' = Windows PowerShell, 'Core' = PowerShell 6/7+) rather than a
# version-string comparison: it is the intent-revealing signal for "must be Windows PowerShell"
# and avoids the magic 5.1.99999.999 upper-bound constant. Callers own the user-facing message
# (this helper only returns a boolean; it never throws or writes an error).
Function Test-PowerShellVersion5 {
    param
    (
        [Parameter(Mandatory = $false)]
        [bool]$NoVerboseOutput = $false
    )

    if (-not $NoVerboseOutput) {
        Write-Verbose "PowerShell version $($PSVersionTable.PSVersion.ToString()) ($($PSVersionTable.PSEdition) edition) detected."
    }

    # 'Desktop' is Windows PowerShell (5.1); 'Core' is PowerShell 6/7+.
    return ($PSVersionTable.PSEdition -eq 'Desktop')
}



# ////////////////////////////////////////////////////////////////////////////
# Classify a single connectivity result row into a stable, machine-readable
# category (v0.6.7). Lets integrators branch on $row.ResultCategory instead of
# brittle free-text matching on $row.Note (e.g. the old config-gap heuristic
# -match 'WAS NOT USED|REQUIRED TO SPECIFY').
#
# Categories (mutually exclusive, evaluated in priority order):
# ConfigGap - a required parameter placeholder (e.g. -KeyVaultURL) was left
# unsubstituted, so the row carries the 'WAS NOT USED' /
# 'REQUIRED TO SPECIFY' Note marker. This is a setup/input gap,
# NOT a real network fault.
# PrivateLink - the endpoint resolved to an RFC1918 private IP (Private Link).
# SSLInspected - an untrusted certificate chain was seen (possible SSL inspection).
# Skipped - the endpoint was never tested. Covers (a) Arc-Gateway skip rows and
# skip-list rows (Layer7Status/TCPStatus literally 'Skipped'), and
# (b) untested wildcard-parent placeholder rows whose Layer7Status is
# still the initial EMPTY string because they never entered the
# DNS/TCP/Layer7 test loop. (A genuinely tested row ALWAYS ends with a
# non-empty Layer7Status - Success / Failed / N/A / 'Invalid port:' -
# so an empty/whitespace value unambiguously means "not tested".)
# Success - Layer7Status reported Success.
# ConnectivityFailure - any other terminal state where a test ran and did not pass
# (Failed, or N/A from a DNS-resolution failure, or 'Invalid port:').
#
# Precedence rationale: the three "diagnostic" categories (ConfigGap, PrivateLink,
# SSLInspected) describe WHY a row is special and are evaluated ahead of the generic
# Success / ConnectivityFailure split, because such rows usually ALSO carry
# Layer7Status='Failed' which would otherwise mask the real cause.
#
# NOTE on CRL/OCSP revocation-offline rows: these keep Layer7Status='Failed' + a
# '- CRL/OCSP unreachable' Layer7Response marker and are DELIBERATELY left as
# ConnectivityFailure here (NOT given their own category) to keep the ResultCategory
# enum stable for consumers. The run-level signal for them is the CRLOfflineDetected /
# CRLOfflineURLs container NoteProperties on the returned ArrayList (and JSON summary),
# mirroring how SSL inspection is ALSO surfaced as a container array - integrators that
# want to treat revocation-offline as a softer WARNING branch on those fields.
Function Get-ConnectivityResultCategory {
    [CmdletBinding()]
    [OutputType([string])]
    param(
        [Parameter(Mandatory = $true)]
        [psobject]$Row,

        # Run-level detection lists. Publish-Results passes a snapshot of the module-scope
        # state ($script:SSLInspectedURLs / $script:PrivateLinkDetectedArray); unit tests
        # pass synthetic lists. Default to empty so the helper is fully self-contained.
        [AllowNull()]
        [string[]]$SSLInspectedURLs = @(),

        [AllowNull()]
        [string[]]$PrivateLinkURLs = @()
    )

    # Bare property reads are safe under StrictMode v1.0 (it throws only on uninitialised
    # VARIABLES, not absent object properties); cast to [string] to coalesce $null to ''.
    $note = [string]$Row.Note
    $url  = [string]$Row.URL
    $l7   = [string]$Row.Layer7Status
    $tcp  = [string]$Row.TCPStatus

    # URL normalisation for the detection-list lookups (steps 2 & 3). The two run-level arrays
    # store the URL in DIFFERENT shapes:
    # * $script:PrivateLinkDetectedArray stores the bare result-row .URL (host[/path]) - it is
    # populated by matching $_.URL in Test-AzureLocalConnectivity, so it already aligns.
    # * $script:SSLInspectedURLs stores the SCHEME-PREFIXED request URL ('https://host/path')
    # because Test-Layer7Connectivity adds the value it actually requested.
    # The result-row .URL is the bare host+path with no scheme, so a raw -contains against the
    # SSL list silently MISSES (an SSL-inspected row then falls through to ConnectivityFailure).
    # Strip a leading http(s):// and any trailing '/' from BOTH the row URL and every list entry
    # so the comparison is scheme- and trailing-slash-insensitive. (-contains is already
    # case-insensitive for strings.)
    $normalizeUrl = { param($u) (([string]$u) -replace '^\s*https?://', '').TrimEnd('/') }
    $urlNorm = & $normalizeUrl $url
    $sslNorm = @(@($SSLInspectedURLs) | ForEach-Object { & $normalizeUrl $_ })
    $plNorm  = @(@($PrivateLinkURLs)  | ForEach-Object { & $normalizeUrl $_ })

    # 1. Config gap — required parameter placeholder was never substituted.
    if ($note -match 'WAS NOT USED|REQUIRED TO SPECIFY') { return 'ConfigGap' }

    # 2. Private Link — endpoint resolved to an RFC1918 address.
    if ($plNorm -and ($plNorm -contains $urlNorm)) { return 'PrivateLink' }

    # 3. SSL inspection — untrusted certificate chain observed (possible TLS interception).
    # Two signals, set in lockstep by AzStackHci.Layer7.Helpers.ps1; either is authoritative:
    # (a) the bare row URL appears in the run-level $script:SSLInspectedURLs snapshot, OR
    # (b) the row's own Layer7Response carries the '- SSL Inspection detected' marker.
    # (b) is read straight off the row, so it survives any URL-shape drift between the snapshot
    # (which stores the scheme-prefixed REQUEST url, possibly a redirect target) and the row's
    # .URL field. A CRL/OCSP-offline row is reclassified away from this marker before this helper runs, so it
    # correctly does NOT match here and stays a ConnectivityFailure.
    $l7Response = [string]$Row.Layer7Response
    if (($sslNorm -and ($sslNorm -contains $urlNorm)) -or ($l7Response -match 'SSL Inspection detected')) { return 'SSLInspected' }

    # 4. Skipped / not-tested. Three cases:
    # (a) Arc-Gateway / skip-list rows -> TCPStatus or Layer7Status literally 'Skipped'.
    # (b) Untested wildcard-parent / placeholder rows that never entered the test loop
    # -> Layer7Status is still the initial EMPTY string. A tested row always has a
    # non-empty Layer7Status, so empty/whitespace here means "never tested", NOT a
    # failure. Guard with -not IsNullOrWhiteSpace($note) is unnecessary because the
    # ConfigGap Note marker is already handled at step 1 above.
    if (($tcp -like 'Skipped*') -or ($l7 -eq 'Skipped') -or [string]::IsNullOrWhiteSpace($l7)) { return 'Skipped' }

    # 5. Success.
    if ($l7 -eq 'Success') { return 'Success' }

    # 6. Everything else is a terminal connectivity failure (Failed / N/A / 'Invalid port:').
    return 'ConnectivityFailure'
}



# ////////////////////////////////////////////////////////////////////////////
# This function converts a hashtable to a string representation
Function Convert-HashTableToString {

    param
    (
        [Parameter(Mandatory = $true)]
        [System.Collections.Hashtable]
        $HashTable
    )

    begin {
        # Write-Verbose "Starting Convert-HashTableToString function"
    }

    process {
        $HashString = "@{"
        $Keys = $HashTable.keys
        foreach ($Key in $Keys)
        {
            $v = $HashTable[$key]
            if ($key -match "\s")
            {
                $HashString += "`"$key`"" + "=" + "`"$v`"" + ";"
            }
            else
            {
                $HashString += $key + "=" + "`"$v`"" + ";"
            }
        }
        $HashString += "}"

    } # End of process block

    end {
        # Write-Debug "Completed Convert-HashTableToString function"
        return $HashString
    }
}



# ////////////////////////////////////////////////////////////////////////////
# Function to extract domains from URLs
Function Get-DomainFromURL {
    param (
        [string]$url
    )

    begin {
        # Write-Verbose "Starting Get-DomainFromURL function"
    }

    process {
        # Remove the protocol (http:// or https://) and extract the domain and port
        $url = $url -replace "^https?://", ""
        # Check if the URL contains a port number
        # If the URL contains a port number, extract it
        if ($url -match ":(\d+)$") {
            $port = [int]($url -replace ".*:(\d+)$", '$1')
            $url = $url -replace ":(\d+)$", ""
        } else {
            $port = $null
        }
        $domain = $url -split '/' | Select-Object -First 1
        return @{ Domain = $domain; Port = $port }
    }

    end {
        # Write-Debug "Completed Get-DomainFromURL function"
    }
}


# ////////////////////////////////////////////////////////////////////////////
# Helper function to normalize URL with protocol based on port
# This is a private helper function for Test-Layer7Connectivity
Function Initialize-WebRequestUrl {
    param (
        [Parameter(Mandatory=$true)]
        [string]$url,
        [Parameter(Mandatory=$true)]
        [int]$port
    )

    # Check if the port is 80 for HTTP or port 443, 8084 or 8443 for HTTPS and update the URL accordingly
    if ($port -eq $script:PORT_HTTPS -or $port -eq $script:PORT_HTTPS_ALT1 -or $port -eq $script:PORT_HTTPS_ALT2) {
        if($url -notmatch "^https://") {
            # If the URL does not start with https://, add it
            $url = "https://$url"
        }
    } elseif($port -eq $script:PORT_HTTP) {
        if($url -notmatch "^http://") {
            # If the URL does not start with http://, add it
            $url = "http://$url"
        }
    } else {
        # For custom ports, use http as the default
        if($url -notmatch "^http") {
            Write-Verbose "Custom port $port detected, using http as the default"
            $url = "http://$url"
        }
    }

    return $url
}


# ////////////////////////////////////////////////////////////////////////////
# Helper function to register a redirected URL into the RedirectedResults array
# Prevents duplicates by checking both RedirectedResults and Results arrays.
# Called from the redirect-handling section of Test-Layer7Connectivity.
function Get-ConnectivityResourceUrl {
    param (
        [Parameter(Mandatory=$true)][string]$Url,
        [Parameter(Mandatory=$true)][int]$Port
    )

    if ($Url -notmatch '^https?://') {
        $scheme = if ($Port -eq 80) { 'http' } else { 'https' }
        $Url = '{0}://{1}' -f $scheme, $Url
    }
    $builder = [System.UriBuilder]::new($Url)
    if ($builder.Scheme -notin @('http', 'https')) { throw 'Only HTTP and HTTPS resources are supported.' }
    $builder.Port = $Port
    $builder.Fragment = ''
    return $builder.Uri.AbsoluteUri
}

function Get-ConnectivityRowResourceUrl {
    param ([Parameter(Mandatory=$true)]$Row)
    $resource = [string]$Row.URL
    if ($Row.PSObject.Properties['redirect'] -and $Row.redirect) { $resource = [string]$Row.redirect }
    if ($resource.Contains('*')) { return '' }
    return Get-ConnectivityResourceUrl -Url $resource -Port $Row.Port
}

function Resolve-ConnectivityRedirectUrl {
    param ([Parameter(Mandatory=$true)][uri]$BaseUri, [Parameter(Mandatory=$true)][string]$Location)
    $target = [uri]::new($BaseUri, $Location)
    if ($target.Scheme -notin @('http', 'https')) { throw 'Only HTTP and HTTPS redirect targets are supported.' }
    return Get-ConnectivityResourceUrl -Url $target.AbsoluteUri -Port $target.Port
}

function Test-ConnectivityRedirectAdvisory {
    param ([Parameter(Mandatory=$true)]$Row)
    return ($Row.PSObject.Properties['RedirectDisposition'] -and $Row.RedirectDisposition -eq 'Advisory' -and
        $Row.PSObject.Properties['ResultCategory'] -and $Row.ResultCategory -eq 'ConnectivityFailure')
}

function Initialize-ConnectivityRedirectMetadata {
    param ([Parameter(Mandatory=$true)]$Row)
    $defaults = [ordered]@{
        RedirectDisposition = 'NotRedirect'
        RedirectReason = ''
        RedirectOriginUrls = [string[]]@()
        RedirectTargetUrl = ''
    }
    foreach ($property in $defaults.Keys) {
        if (-not $Row.PSObject.Properties[$property]) {
            Add-Member -InputObject $Row -NotePropertyName $property -NotePropertyValue $defaults[$property]
        }
    }
}

function Merge-ConnectivityRedirectRow {
    param ([Parameter(Mandatory=$true)]$Row)
    $target = Get-ConnectivityRowResourceUrl -Row $Row
    $existing = $script:RedirectedResults | Where-Object {
        (Get-ConnectivityRowResourceUrl -Row $_) -ceq $target
    } | Select-Object -First 1
    if ($existing) {
        foreach ($property in @('RedirectOriginUrls', 'RedirectParentUrls')) {
            if ($Row.PSObject.Properties[$property]) {
                $values = [string[]]@($Row.$property)
                if ($existing.PSObject.Properties[$property]) { $values += [string[]]@($existing.$property) }
                $unique = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::Ordinal)
                foreach ($value in $values) { [void]$unique.Add($value) }
                Add-Member -InputObject $existing -NotePropertyName $property -NotePropertyValue ([string[]]@($unique | Sort-Object -CaseSensitive)) -Force
            }
        }
    } else {
        [void]$script:RedirectedResults.Add($Row)
    }
}

function Update-ConnectivityRedirectDisposition {
    $inventory = @($script:Results | Where-Object {
        $_.Source -match '^(GitHub|Environment Checker)( Wildcard)?$' -or
        $_.Source -match '^(?!(?:Redirect for|Test for) ).+ SBE(?: Wildcard)?$'
    })
    foreach ($result in $script:Results) { Initialize-ConnectivityRedirectMetadata -Row $result }
    foreach ($redirectRow in $script:RedirectedResults) {
        Initialize-ConnectivityRedirectMetadata -Row $redirectRow
        $target = [uri](Get-ConnectivityRowResourceUrl -Row $redirectRow)
        $redirectRow.RedirectTargetUrl = $target.AbsoluteUri
        $redirectRow.RedirectDisposition = 'Advisory'
        $redirectRow.RedirectReason = 'Destination requirement unverified; discovered while following redirects during connectivity testing. Review the ''RedirectOriginUrls'' column for source details.'
        $requiredTarget = @($inventory | Where-Object {
            $_.Port -eq $target.Port -and $target.Host -like (Get-DomainFromURL -url $_.URL).Domain
        }).Count -gt 0
        if ($requiredTarget) {
            $redirectRow.RedirectDisposition = 'RequiredDependency'
            $redirectRow.RedirectReason = 'Destination matches an applicable inventory endpoint and port.'
        }
    }
    for ($pass = 0; $pass -le $script:RedirectedResults.Count; $pass++) {
        $changed = $false
        foreach ($redirectRow in $script:RedirectedResults) {
            if (-not $redirectRow.PSObject.Properties['RedirectParentUrls']) { continue }
            foreach ($parentUrl in $redirectRow.RedirectParentUrls) {
                $parent = [uri]$parentUrl
                foreach ($parentRow in @($script:RedirectedResults | Where-Object { $_.RedirectTargetUrl -ceq $parentUrl })) {
                    foreach ($origin in $parentRow.RedirectOriginUrls) {
                        if ($redirectRow.RedirectOriginUrls -cnotcontains $origin) {
                            $redirectRow.RedirectOriginUrls = [string[]]@($redirectRow.RedirectOriginUrls + $origin)
                            $changed = $true
                        }
                    }
                }
                $requiredParent = @($script:RedirectedResults | Where-Object {
                    $_.RedirectTargetUrl -ceq $parentUrl -and $_.RedirectDisposition -eq 'RequiredDependency'
                }).Count -gt 0
                $intentionalLink = ($parent.Host -eq 'aka.ms' -and $parent.AbsolutePath -ne '/') -or
                    ($parent.Host -eq 'go.microsoft.com' -and $parent.AbsolutePath.TrimEnd('/') -eq '/fwlink' -and $parent.Query -match '(?i)[?&]linkid=\d+(?:&|$)')
                if ($intentionalLink) {
                    $requiredParent = $requiredParent -or @($inventory | Where-Object {
                        -not $_.IsWildcard -and (Get-ConnectivityRowResourceUrl -Row $_) -ceq $parentUrl
                    }).Count -gt 0
                }
                if ($requiredParent -and $redirectRow.RedirectDisposition -ne 'RequiredDependency') {
                    $redirectRow.RedirectDisposition = 'RequiredDependency'
                    $redirectRow.RedirectReason = 'Dependency of an applicable required redirect chain.'
                    $changed = $true
                }
            }
        }
        if (-not $changed) { break }
    }
}

Function Add-RedirectedUrlToResults {
    param (
        [Parameter(Mandatory=$true)]
        [string]$RedirectedURL,

        [Parameter(Mandatory=$true)]
        [string]$FullRedirectUrl,

        [Parameter(Mandatory=$true)]
        [int]$DestinationPort,

        [Parameter(Mandatory=$true)]
        [string]$OriginalURL,

        [Parameter(Mandatory=$true)]
        [int]$OriginalPort,

        [string]$ParentUrl
    )

    Write-HostAzS "Redirected to '$FullRedirectUrl'" -ForegroundColor Yellow

    # Update the Note on the original result to show the redirect target (only if not already set)
    $ResultsToUpdate = $script:Results | Where-Object { $_.url -eq $OriginalURL -and ($_.Port -eq $OriginalPort) }
    ForEach ($ResultToUpdate in $ResultsToUpdate) {
        if (-not($ResultToUpdate.Note -like "Redirects to *")) {
            if ($ResultToUpdate.Note) {
                $ResultToUpdate.Note = "Redirects to '$($RedirectedURL)' - $($ResultToUpdate.Note)"
            } else {
                $ResultToUpdate.Note = "Redirects to '$($RedirectedURL)'"
            }
        }
    }

    if ([string]::IsNullOrWhiteSpace($RedirectedURL)) {
        Write-Warning "Redirected URL is null for $FullRedirectUrl, skipping"
        return
    }

    $originUrl = Get-ConnectivityResourceUrl -Url $OriginalURL -Port $OriginalPort
    if (-not $ParentUrl) { $ParentUrl = $originUrl }
    $targetUrl = Get-ConnectivityResourceUrl -Url $FullRedirectUrl -Port $DestinationPort
    $OriginalResult = @($script:Results) + @($script:RedirectedResults) | Where-Object {
        -not $_.IsWildcard -and (Get-ConnectivityRowResourceUrl -Row $_) -ceq $originUrl
    } | Select-Object -First 1
    $originUrls = [string[]]@($originUrl)
    $originalSource = 'Connectivity probe'
    if ($OriginalResult) {
        $originalSource = $OriginalResult.Source
        if ($OriginalResult.PSObject.Properties['RedirectOriginUrls'] -and $OriginalResult.RedirectOriginUrls.Count) {
            $originUrls = [string[]]@($OriginalResult.RedirectOriginUrls)
        }
    }
    Merge-ConnectivityRedirectRow -Row ([PSCustomObject]@{
            RowID = 0
            MachineName = $env:COMPUTERNAME
            url = $RedirectedURL
            redirect = $targetUrl
            Port = $DestinationPort
            ArcGateway = $false
            IsWildcard = $false
            Source = "Redirect for $originalSource"
            Note = "Redirected URL from '$originUrl'; destination requirement evaluated separately."
            RedirectDisposition = 'Advisory'
            RedirectReason = 'Destination requirement unverified; discovered while following redirects during connectivity testing. Review the ''RedirectOriginUrls'' column for source details.'
            RedirectOriginUrls = $originUrls
            RedirectTargetUrl = $targetUrl
            RedirectParentUrls = [string[]]@($ParentUrl)
            TCPStatus = ""
            IPAddress = ""
            Layer7Status = ""
            Layer7Response = ""
            Layer7ResponseTime = ""
            CertificateSubject = ""
            CertificateIssuer = ""
            CertificateThumbprint = ""
            IntermediateCertificateIssuer = ""
            IntermediateCertificateSubject = ""
            IntermediateCertificateThumbprint = ""
            RootCertificateIssuer = ""
            RootCertificateSubject = ""
            RootCertificateThumbprint = ""
        })
    Update-ConnectivityRedirectDisposition
}


# ////////////////////////////////////////////////////////////////////////////
# Helper function to register a CRL / OCSP dependency URL as its own row in
# $script:Results. Called when Get-Layer7CertificateDetails classifies an HTTPS
# endpoint as "CRL/OCSP unreachable" (trusted chain, revocation offline).
#
# Dedupe strategy (two tiers):
# - OCSP: skip if ANY existing row already covers the same host+port=80
# (the OCSP protocol uses a single host, so host match = full coverage)
# - CRL: fall through to exact-URL match — different .crl files on the same
# host can be blocked independently by path-based proxy filtering
# When an identical URL was already added by a previous parent, the existing
# row's Source is extended to list both parents.
#
# Rows are appended directly to $script:Results with Layer7Status = "" so the
# existing remainingUrls loop in Test-AzureLocalConnectivity picks them up and
# tests them as first-class endpoints.
Function Add-CrlDependencyRowToResults {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)][ValidateSet('CRL','OCSP')][string]$Kind,
        [Parameter(Mandatory=$true)][string]$DependencyURL,
        [Parameter(Mandatory=$true)][string]$ParentURL
    )

    if ([string]::IsNullOrWhiteSpace($DependencyURL)) { return }
    $parentDomain = (Get-DomainFromURL -url $ParentURL).Domain
    $depDomain    = (Get-DomainFromURL -url $DependencyURL).Domain
    if ([string]::IsNullOrWhiteSpace($depDomain)) {
        Write-Debug "Add-CrlDependencyRowToResults: cannot parse domain from '$DependencyURL', skipping"
        return
    }

    # Tier 1 — dedupe against existing rows
    if ($Kind -eq 'OCSP') {
        # Host-level dedupe is sufficient for OCSP (single-host protocol)
        $existing = $script:Results | Where-Object {
            ((Get-DomainFromURL -url $_.URL).Domain -eq $depDomain) -and ($_.Port -eq $script:PORT_HTTP)
        } | Select-Object -First 1
        if ($existing) {
            Write-Debug "Add-CrlDependencyRowToResults: OCSP host '$depDomain' already in Results (row URL '$($existing.URL)'), skipping duplicate"
            return
        }
    } else {
        # CRL — exact URL dedupe (different .crl paths on same host can be independently blocked)
        $existingSame = $script:Results | Where-Object {
            ($_.URL -eq $DependencyURL) -and ($_.Port -eq $script:PORT_HTTP)
        } | Select-Object -First 1
        if ($existingSame) {
            # Same CRL URL already added — extend Source to reflect shared parent
            if ($existingSame.Source -notmatch [regex]::Escape($parentDomain)) {
                $existingSame.Source = "$($existingSame.Source); $parentDomain"
            }
            Write-Debug "Add-CrlDependencyRowToResults: CRL URL '$DependencyURL' already present — appended parent '$parentDomain' to Source"
            return
        }
    }

    # Tier 2 — append new row (Layer7Status="" so the remaining-URLs loop tests it)
    $sourcePrefix = if ($Kind -eq 'CRL') { 'CRL dependency for' } else { 'OCSP dependency for' }
    $script:Results.Add([PSCustomObject]@{
        RowID = 0
        MachineName = $env:COMPUTERNAME
        URL = $DependencyURL
        Port = $script:PORT_HTTP
        ArcGateway = $false
        IsWildcard = $false
        Source = "$sourcePrefix $parentDomain"
        Note = "Required for certificate revocation check of https://$parentDomain (HTTP port 80 must be reachable)"
        TCPStatus = ""
        IPAddress = ""
        Layer7Status = ""
        Layer7Response = ""
        Layer7ResponseTime = ""
        CertificateIssuer = ""
        CertificateSubject = ""
        CertificateThumbprint = ""
        IntermediateCertificateIssuer = ""
        IntermediateCertificateSubject = ""
        IntermediateCertificateThumbprint = ""
        RootCertificateIssuer = ""
        RootCertificateSubject = ""
        RootCertificateThumbprint = ""
    }) | Out-Null
    Write-Debug "Add-CrlDependencyRowToResults: appended $Kind dependency row '$DependencyURL' for parent '$parentDomain'"
}


# ////////////////////////////////////////////////////////////////////////////
# Helper function to initialize ServerCertificateValidationCallback for SSL bypass
# This is a private helper function for Test-Layer7Connectivity
Function Initialize-CertificateCallback {
    # IMPORTANT: This sets a PROCESS-WIDE callback on ServicePointManager.ServerCertificateValidationCallback
    # that accepts all certificates. This is intentional — the module needs to connect to endpoints even when
    # SSL inspection replaces certificates, so it can detect and report SSL inspection to the user.
    # The callback is reset to $null in the end block of Test-Layer7Connectivity and Test-AzureLocalConnectivity.

    # Check if ServerCertificateValidationCallback class is already defined
    if (-not ([System.Management.Automation.PSTypeName]'ServerCertificateValidationCallback').Type) {
        # Define the ServerCertificateValidationCallback class
        # This class is used to bypass SSL certificate validation, to allow for SSL inspection detection
        $CertCallback = @"
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class ServerCertificateValidationCallback
{
    public static void Ignore()
    {
        if(ServicePointManager.ServerCertificateValidationCallback == null)
        {
            ServicePointManager.ServerCertificateValidationCallback +=
                delegate
                (
                    Object obj,
                    X509Certificate certificate,
                    X509Chain chain,
                    SslPolicyErrors errors
                )
                {
                    return true;
                };
        }
    }
}
"@

        Add-Type $CertCallback
    }
    # Call the Ignore method to bypass SSL certificate validation.
    # PRECONDITION: the C# Ignore() only installs the accept-all delegate when
    # ServicePointManager.ServerCertificateValidationCallback is currently $null. If the
    # caller (or another loaded module) already set a callback, the bypass is NOT installed,
    # so SSL-inspection detection can be inconsistent in shared sessions. The caller
    # (Test-Layer7Connectivity / Test-AzureLocalConnectivity) captures and restores the
    # original callback in its finally block, so this never leaks across function calls.
    [ServerCertificateValidationCallback]::Ignore()
}


# ////////////////////////////////////////////////////////////////////////////
# Helper to set all connectivity result fields on a URL object to skip/N/A values.
# Used when a URL is skipped, wildcarded, or DNS resolution fails.
Function Set-UrlObjectSkipFields {
    param(
        [Parameter(Mandatory)][PSCustomObject]$UrlObject,
        [Parameter(Mandatory)][string]$TCPStatus,
        [Parameter(Mandatory)][string]$Layer7Status,
        [string]$IPAddress = "N/A",
        [string]$Layer7Response = "N/A",
        [string]$Layer7ResponseTime = "N/A"
    )
    $UrlObject.TCPStatus = $TCPStatus
    $UrlObject.IPAddress = $IPAddress
    $UrlObject.Layer7Status = $Layer7Status
    $UrlObject.Layer7Response = $Layer7Response
    $UrlObject.Layer7ResponseTime = $Layer7ResponseTime
    $UrlObject.CertificateIssuer = "N/A"
    $UrlObject.CertificateSubject = "N/A"
    $UrlObject.CertificateThumbprint = "N/A"
    $UrlObject.IntermediateCertificateIssuer = "N/A"
    $UrlObject.IntermediateCertificateSubject = "N/A"
    $UrlObject.IntermediateCertificateThumbprint = "N/A"
    $UrlObject.RootCertificateIssuer = "N/A"
    $UrlObject.RootCertificateSubject = "N/A"
    $UrlObject.RootCertificateThumbprint = "N/A"
}


# ////////////////////////////////////////////////////////////////////////////
# Helper to copy connectivity test results from an Invoke-EndpointConnectivityTest
# result hashtable to a URL result object.
Function Copy-ConnectivityResultsToUrlObject {
    param(
        [Parameter(Mandatory)][PSCustomObject]$UrlObject,
        [Parameter(Mandatory)][hashtable]$TestResult
    )
    $UrlObject.TCPStatus = $TestResult.TCPStatus
    foreach ($field in @('TCPDiagnostics', 'DNSDiagnostics', 'DNSFailureCode', 'DNSResolutionStatus')) {
        Add-Member -InputObject $UrlObject -NotePropertyName $field -NotePropertyValue $TestResult[$field] -Force
    }
    $UrlObject.IPAddress = $TestResult.IPAddress
    $UrlObject.Layer7Status = $TestResult.Layer7Status
    $UrlObject.Layer7Response = $TestResult.Layer7Response
    $UrlObject.Layer7ResponseTime = $TestResult.Layer7ResponseTime
    $UrlObject.CertificateIssuer = $TestResult.CertificateIssuer
    $UrlObject.CertificateSubject = $TestResult.CertificateSubject
    $UrlObject.CertificateThumbprint = $TestResult.CertificateThumbprint
    $UrlObject.IntermediateCertificateIssuer = $TestResult.CertificateIntermediateIssuer
    $UrlObject.IntermediateCertificateSubject = $TestResult.CertificateIntermediateSubject
    $UrlObject.IntermediateCertificateThumbprint = $TestResult.CertificateIntermediateThumbprint
    $UrlObject.RootCertificateIssuer = $TestResult.CertificateRootIssuer
    $UrlObject.RootCertificateSubject = $TestResult.CertificateRootSubject
    $UrlObject.RootCertificateThumbprint = $TestResult.CertificateRootThumbprint
}

# SIG # Begin signature block
# MIInQQYJKoZIhvcNAQcCoIInMjCCJy4CAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCNHlxwjKyG8RWW
# wrcwbKfhVyyB+sGrqYZ7ddE7PdkCUqCCDLowggX1MIID3aADAgECAhMzAAACHU0Z
# yE7XD1dIAAAAAAIdMA0GCSqGSIb3DQEBCwUAMFcxCzAJBgNVBAYTAlVTMR4wHAYD
# VQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBD
# b2RlIFNpZ25pbmcgUENBIDIwMjQwHhcNMjYwNDE2MTg1OTQzWhcNMjcwNDE1MTg1
# OTQzWjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UE
# BxMHUmVkbW9uZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYD
# VQQDExVNaWNyb3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IB
# DwAwggEKAoIBAQDQvewXxx9gZZFC6Ys1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