mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Adapt per review
This commit is contained in:
parent
63b7a5ee5e
commit
6ff2ee3367
20 changed files with 118 additions and 119 deletions
|
|
@ -25,17 +25,17 @@ function Test-InstallDir {
|
|||
return @{ Ok = $false; Reason = "-InstallDir must not contain the PATH separator ($([System.IO.Path]::PathSeparator))" }
|
||||
}
|
||||
|
||||
$inputSegments = $Dir.Split([char[]]@('\', '/'), [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
if ($inputSegments -contains "..") {
|
||||
return @{ Ok = $false; Reason = "-InstallDir must not contain path traversal segments" }
|
||||
}
|
||||
|
||||
$normalized = [System.IO.Path]::GetFullPath($Dir)
|
||||
$root = [System.IO.Path]::GetPathRoot($normalized)
|
||||
if ($normalized.TrimEnd('\', '/') -eq $root.TrimEnd('\', '/')) {
|
||||
return @{ Ok = $false; Reason = "-InstallDir cannot be a root or drive-root directory" }
|
||||
}
|
||||
|
||||
$segments = $normalized.Substring($root.Length).Split([char[]]@('\', '/'), [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
if ($segments -contains "..") {
|
||||
return @{ Ok = $false; Reason = "-InstallDir must not contain path traversal segments" }
|
||||
}
|
||||
|
||||
return @{ Ok = $true; Normalized = $normalized }
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue