mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2026-01-02 15:27:16 +08:00
[windows] implement checksum validation for Miniconda (#8506)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
################################################################################
|
||||
## File: Install-Miniconda.ps1
|
||||
## Desc: Install the latest version of Miniconda and set $env:CONDA
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
$CondaDestination = "C:\Miniconda"
|
||||
@@ -13,4 +14,19 @@ $ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestinatio
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
|
||||
Set-SystemVariable -SystemVariable "CONDA" -Value $CondaDestination
|
||||
|
||||
Invoke-PesterTests -TestFile "Miniconda"
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
|
||||
$distributorFileHash = $null
|
||||
|
||||
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
|
||||
|
||||
ForEach($node in $checksums) {
|
||||
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
|
||||
$distributorFileHash = $node.ChildNodes[7].InnerText
|
||||
}
|
||||
}
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
#endregion
|
||||
|
||||
Invoke-PesterTests -TestFile "Miniconda"
|
||||
|
||||
Reference in New Issue
Block a user