Repository: microsoft/CSS-Exchange
File: Diagnostics/HealthChecker/Analyzer/Security/Invoke-AnalyzerSecurityCveCheck.ps1 (PowerShell)

Code before:
    }

    # Need to organize the list so oldest CVEs come out first.
    $monthOrder = @{
        "Jan" = 1
        "Feb" = 2
        "Mar" = 3
        "Apr" = 4
        "May" = 5
        "Jun" = 6
        "Jul" = 7
        "Aug" = 8
        "Sep" = 9
        "Oct" = 10
        "Nov" = 11
        "Dec" = 12
    }
    $unsortedKeys = @($suNameDictionary.Keys)
    $sortedKeys = New-Object System.Collections.Generic.List[string]

    foreach ($value in $unsortedKeys) {
        $month = $value.Substring(0, 3)
        $year = [int]$value.Substring(3, 2)

        # Only add values that are greater than or equal to our current CU year build.
        $cuReleaseYear = [int]([string]$exchangeInformation.BuildInformation.VersionInformation.ReleaseDate.Year).Substring(2)

        if ($year -lt $cuReleaseYear) {
            continue
        }

        $insertAt = 0
        while ($insertAt -lt $sortedKeys.Count) {

            $compareMonth = $sortedKeys[$insertAt].Substring(0, 3)
            $compareYear = [int]$sortedKeys[$insertAt].Substring(3, 2)
            # break to add at current spot in list
            if ($compareYear -gt $year) { break }
            elseif ( $compareYear -eq $year -and
                $monthOrder[$month] -lt $monthOrder[$compareMonth]) { break }

            $insertAt++
        }

        $sortedKeys.Insert($insertAt, $value)
    }

    Write-Verbose "We will only process $($sortedKeys.Count) CVEs based off this CU's Release Date $($exchangeInformation.BuildInformation.VersionInformation.ReleaseDate)"

    $stopWatchTestBuild = New-Object System.Diagnostics.Stopwatch


Review comment (suggestion):
The following might be better to avoid multiple casting and string operations. What do you think?

```suggestion
        $cuReleaseYear = $exchangeInformation.BuildInformation.VersionInformation.ReleaseDate.Year % 100
```

Code after:
    }

    # Need to organize the list so oldest CVEs come out first.
    $monthOrder = @{
        "Jan" = 1
        "Feb" = 2
        "Mar" = 3
        "Apr" = 4
        "May" = 5
        "Jun" = 6
        "Jul" = 7
        "Aug" = 8
        "Sep" = 9
        "Oct" = 10
        "Nov" = 11
        "Dec" = 12
    }
    $unsortedKeys = @($suNameDictionary.Keys)
    $sortedKeys = New-Object System.Collections.Generic.List[string]

    foreach ($value in $unsortedKeys) {
        $month = $value.Substring(0, 3)
        $year = [int]$value.Substring(3, 2)

        # Only add values that are greater than or equal to our current CU year build.
        $cuReleaseYear = $exchangeInformation.BuildInformation.VersionInformation.ReleaseDate.Year % 100

        if ($year -lt $cuReleaseYear) {
            continue
        }

        $insertAt = 0
        while ($insertAt -lt $sortedKeys.Count) {

            $compareMonth = $sortedKeys[$insertAt].Substring(0, 3)
            $compareYear = [int]$sortedKeys[$insertAt].Substring(3, 2)
            # break to add at current spot in list
            if ($compareYear -gt $year) { break }
            elseif ( $compareYear -eq $year -and
                $monthOrder[$month] -lt $monthOrder[$compareMonth]) { break }

            $insertAt++
        }

        $sortedKeys.Insert($insertAt, $value)
    }

    Write-Verbose "We will only process $($sortedKeys.Count) CVEs based off this CU's Release Date $($exchangeInformation.BuildInformation.VersionInformation.ReleaseDate)"

    $stopWatchTestBuild = New-Object System.Diagnostics.Stopwatch