Reject unsafe Windows update cache roots
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
This commit is contained in:
+7
-1
@@ -320,7 +320,13 @@ function Assert-SafeUpdateCache($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
|
||||||
$homeCache = Normalize-PathForCompare (Join-Path $HOME ".cache")
|
$homeCache = Normalize-PathForCompare (Join-Path $HOME ".cache")
|
||||||
if ($full -eq $root -or $full -eq $homePath -or $full -eq $homeCache) {
|
$unsafe = $full -eq $root -or $full -eq $homePath -or $full -eq $homeCache
|
||||||
|
if (-not $unsafe -and $env:LOCALAPPDATA) {
|
||||||
|
$localAppData = Normalize-PathForCompare $env:LOCALAPPDATA
|
||||||
|
$localAppDataDosh = Normalize-PathForCompare (Join-Path $env:LOCALAPPDATA "dosh")
|
||||||
|
$unsafe = $full -eq $localAppData -or $full -eq $localAppDataDosh
|
||||||
|
}
|
||||||
|
if ($unsafe) {
|
||||||
throw "refusing unsafe update cache path: $Path"
|
throw "refusing unsafe update cache path: $Path"
|
||||||
}
|
}
|
||||||
$full
|
$full
|
||||||
|
|||||||
@@ -169,6 +169,11 @@ fn windows_installer_reuses_persistent_source_update_cache() {
|
|||||||
assert!(ps1.contains("Assert-NoRelativePathSegments($Path)"));
|
assert!(ps1.contains("Assert-NoRelativePathSegments($Path)"));
|
||||||
assert!(ps1.contains("Assert-NoRelativePathSegments $Path"));
|
assert!(ps1.contains("Assert-NoRelativePathSegments $Path"));
|
||||||
assert!(ps1.contains("$segment -eq \".\" -or $segment -eq \"..\""));
|
assert!(ps1.contains("$segment -eq \".\" -or $segment -eq \"..\""));
|
||||||
|
assert!(ps1.contains("$localAppData = Normalize-PathForCompare $env:LOCALAPPDATA"));
|
||||||
|
assert!(ps1.contains(
|
||||||
|
"$localAppDataDosh = Normalize-PathForCompare (Join-Path $env:LOCALAPPDATA \"dosh\")"
|
||||||
|
));
|
||||||
|
assert!(ps1.contains("$full -eq $localAppData -or $full -eq $localAppDataDosh"));
|
||||||
assert!(ps1.contains("$sourceCache = Assert-SafeUpdateCache $UpdateCache"));
|
assert!(ps1.contains("$sourceCache = Assert-SafeUpdateCache $UpdateCache"));
|
||||||
assert!(ps1.contains(
|
assert!(ps1.contains(
|
||||||
"$fetchArgs = @(\"-C\", $sourceCache, \"fetch\", \"--depth\", \"1\", \"origin\", \"main\")"
|
"$fetchArgs = @(\"-C\", $sourceCache, \"fetch\", \"--depth\", \"1\", \"origin\", \"main\")"
|
||||||
|
|||||||
Reference in New Issue
Block a user