Skip to content

Commit 47a634e

Browse files
[windows] implement checksum validation for Miniconda (#8506)
1 parent 929931f commit 47a634e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
################################################################################
22
## File: Install-Miniconda.ps1
33
## Desc: Install the latest version of Miniconda and set $env:CONDA
4+
## Supply chain security: checksum validation
45
################################################################################
56

67
$CondaDestination = "C:\Miniconda"
@@ -13,4 +14,19 @@ $ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestinatio
1314
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
1415
Set-SystemVariable -SystemVariable "CONDA" -Value $CondaDestination
1516

16-
Invoke-PesterTests -TestFile "Miniconda"
17+
#region Supply chain security
18+
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
19+
$distributorFileHash = $null
20+
21+
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
22+
23+
ForEach($node in $checksums) {
24+
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
25+
$distributorFileHash = $node.ChildNodes[7].InnerText
26+
}
27+
}
28+
29+
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
30+
#endregion
31+
32+
Invoke-PesterTests -TestFile "Miniconda"

0 commit comments

Comments
 (0)