IJPL-164957 Refine Windows Defender exclusions path comparison

Enhanced the `Test-Excluded` function to better handle directory paths by checking if the exclusion is a directory and ensuring it has more path segments than the excluded path. This improves the accuracy of determining whether a path should be excluded.

GitOrigin-RevId: e494da49d0722bbd599704d9e51c9d37e9a37987
This commit is contained in:
Vera Petrenkova
2024-11-19 12:34:58 +00:00
committed by intellij-monorepo-bot
parent b7166fa67e
commit d507e77016
+1 -1
View File
@@ -37,7 +37,7 @@ try {
# returns `$true` when a path is already covered by the exclusion list
function Test-Excluded ([string] $path, [string[]] $exclusions) {
foreach ($exclusion in $exclusions) {
if ([cultureinfo]::InvariantCulture.CompareInfo.IsPrefix($path, $exclusion, @("IgnoreCase"))) {
if (((Get-Item -Path $exclusion) -is [System.IO.DirectoryInfo]) -and ([cultureinfo]::InvariantCulture.CompareInfo.IsPrefix($path, $exclusion, @("IgnoreCase"))) -and ($exclusion.TrimEnd('\').split('\').Count -gt $path.TrimEnd('\').Split('\').Count)) {
return $true
}
}