Skip to content

Commit ae48752

Browse files
authored
[Windows] Add checksum validation for Stack (#8403)
1 parent 8b23f69 commit ae48752

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

images/win/scripts/Installers/Install-Stack.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
################################################################################
22
## File: Install-Stack.ps1
33
## Desc: Install Stack for Windows
4+
## Supply chain security: Stack - checksum validation
45
################################################################################
56

67
Write-Host "Get the latest Stack version..."
@@ -14,6 +15,13 @@ $StackToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY "stack\$Version"
1415
$DestinationPath = Join-Path $StackToolcachePath "x64"
1516
$StackArchivePath = Start-DownloadWithRetry -Url $DownloadUrl
1617

18+
#region Supply chain security - Stack
19+
$fileHash = (Get-FileHash -Path $StackArchivePath -Algorithm SHA256).Hash
20+
$hashUrl = $StackReleasesJson.assets | Where-Object { $_.name.EndsWith("$DownloadFilePattern.sha256") } | Select-Object -ExpandProperty "browser_download_url" -First 1
21+
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*$DownloadFilePattern*" }).Split(' ')[0]
22+
Use-ChecksumComparison $fileHash $externalHash
23+
#endregion
24+
1725
Write-Host "Expand stack archive"
1826
Extract-7Zip -Path $StackArchivePath -DestinationPath $DestinationPath
1927

0 commit comments

Comments
 (0)