summaryrefslogtreecommitdiff
path: root/scripts/Publish-Release.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Publish-Release.ps1')
-rw-r--r--scripts/Publish-Release.ps18
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/Publish-Release.ps1 b/scripts/Publish-Release.ps1
index 8ada466..78b97ef 100644
--- a/scripts/Publish-Release.ps1
+++ b/scripts/Publish-Release.ps1
@@ -17,7 +17,13 @@ $zip = Join-Path $outputRootPath "$bundleName.zip"
$checksum = "$zip.sha256"
New-Item -ItemType Directory -Force -Path $outputRootPath | Out-Null
-if (Test-Path -LiteralPath $bundle) { Remove-Item -LiteralPath $bundle -Recurse -Force }
+if (Test-Path -LiteralPath $bundle) {
+ $resolvedBundle = (Resolve-Path -LiteralPath $bundle).Path
+ if (-not $resolvedBundle.StartsWith($outputRootPath + [IO.Path]::DirectorySeparatorChar, [StringComparison]::OrdinalIgnoreCase)) {
+ throw 'Existing Release Bundle escaped the validated output root.'
+ }
+ Get-ChildItem -LiteralPath $resolvedBundle -Force | Remove-Item -Recurse -Force
+}
if (Test-Path -LiteralPath $zip) { Remove-Item -LiteralPath $zip -Force }
if (Test-Path -LiteralPath $checksum) { Remove-Item -LiteralPath $checksum -Force }