mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-11-16 01:44:10 +01:00
Refuse ambiguous Windows path aliases during recovery
This commit is contained in:
1 parent
43683b7aa3
commit
e8b018d5c9
2 files changed
+4
-1
No files matched your search
@@ -21,6 +21,9 @@ function Resolve-WelaFirewallRecoveryLogPath {
|
||||
# Only native Windows directory variables have reviewed meaning in old paths.
|
||||
$expanded=[regex]::Replace($Path,'(?i)%(systemroot|windir)%',[Text.RegularExpressions.MatchEvaluator]{param($m) [Environment]::GetFolderPath([Environment+SpecialFolder]::Windows)})
|
||||
if($expanded -notmatch '^[A-Za-z]:\\' -or $expanded -match '%' -or $expanded.Substring(2).Contains(':') -or $expanded.EndsWith('\') -or $expanded.Contains('/')){throw 'UNC/device/relative paths, unknown variables and alternate streams are unsupported.'}
|
||||
foreach($segment in $expanded.Substring(3).Split([char]'\')){
|
||||
if(-not $segment -or $segment -match '[ .]$' -or $segment -match '^(?i:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)'){throw 'Ambiguous path segments and Windows device aliases are unsupported.'}
|
||||
}
|
||||
if([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT){$null=Resolve-WelaArrivalPath $expanded}
|
||||
$expanded
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user