Reject unsafe Windows update cache segments
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
ci / test (push) Waiting to run
ci / fuzz-smoke (push) Waiting to run
ci / windows-client (push) Waiting to run
ci / package-release (linux-x86_64, ubuntu-latest) (push) Waiting to run
ci / package-release (macos-aarch64, macos-14) (push) Waiting to run
ci / package-release (macos-x86_64, macos-13) (push) Waiting to run
ci / package-release (windows-x86_64, windows-latest) (push) Waiting to run
ci / publish-gitea-release (push) Blocked by required conditions
ci / remote-bench (push) Waiting to run
This commit is contained in:
@@ -276,10 +276,19 @@ function Normalize-PathForCompare($Path) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Assert-NoRelativePathSegments($Path) {
|
||||||
|
foreach ($segment in ($Path -split '[\\/]')) {
|
||||||
|
if ($segment -eq "." -or $segment -eq "..") {
|
||||||
|
throw "refusing unsafe update cache path: $Path"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Assert-SafeUpdateCache($Path) {
|
function Assert-SafeUpdateCache($Path) {
|
||||||
if (-not $Path) {
|
if (-not $Path) {
|
||||||
throw "refusing unsafe update cache path: $Path"
|
throw "refusing unsafe update cache path: $Path"
|
||||||
}
|
}
|
||||||
|
Assert-NoRelativePathSegments $Path
|
||||||
$full = Normalize-PathForCompare $Path
|
$full = Normalize-PathForCompare $Path
|
||||||
$root = Normalize-PathForCompare ([System.IO.Path]::GetPathRoot($full))
|
$root = Normalize-PathForCompare ([System.IO.Path]::GetPathRoot($full))
|
||||||
$homePath = Normalize-PathForCompare $HOME
|
$homePath = Normalize-PathForCompare $HOME
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ fn installers_refuse_prebuilts_without_checksums() {
|
|||||||
fn windows_installer_reuses_persistent_source_update_cache() {
|
fn windows_installer_reuses_persistent_source_update_cache() {
|
||||||
let ps1 = include_str!("../install.ps1");
|
let ps1 = include_str!("../install.ps1");
|
||||||
assert!(ps1.contains("DOSH_UPDATE_CACHE"));
|
assert!(ps1.contains("DOSH_UPDATE_CACHE"));
|
||||||
|
assert!(ps1.contains("Assert-NoRelativePathSegments($Path)"));
|
||||||
|
assert!(ps1.contains("Assert-NoRelativePathSegments $Path"));
|
||||||
|
assert!(ps1.contains("$segment -eq \".\" -or $segment -eq \"..\""));
|
||||||
assert!(ps1.contains("$sourceCache = Assert-SafeUpdateCache $UpdateCache"));
|
assert!(ps1.contains("$sourceCache = Assert-SafeUpdateCache $UpdateCache"));
|
||||||
assert!(ps1.contains("git -C $sourceCache fetch --depth 1 origin main"));
|
assert!(ps1.contains("git -C $sourceCache fetch --depth 1 origin main"));
|
||||||
assert!(ps1.contains("git -C $sourceCache checkout -q -B main FETCH_HEAD"));
|
assert!(ps1.contains("git -C $sourceCache checkout -q -B main FETCH_HEAD"));
|
||||||
|
|||||||
Reference in New Issue
Block a user