mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Windows] Add checksum verification for Git (#8317)
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
################################################################################
|
||||
## File: Install-Git.ps1
|
||||
## Desc: Install Git for Windows
|
||||
## Supply chain security: Git - checksum validation, Hub CLI - managed by package manager
|
||||
################################################################################
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
|
||||
# Install the latest version of Git for Windows
|
||||
$gitReleases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest"
|
||||
$repoURL = "https://api.github.com/repos/git-for-windows/git/releases/latest"
|
||||
$gitReleases = Invoke-RestMethod $repoURL
|
||||
[string]$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe"
|
||||
|
||||
$installerFile = Split-Path $downloadUrl -Leaf
|
||||
Install-Binary -Url $downloadUrl `
|
||||
-Name $installerFile `
|
||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
|
||||
|
||||
#region Supply chain security - Git
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$externalHash = Get-HashFromGitHubReleaseBody -Url $RepoURL -FileName $installerFile
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath `
|
||||
-ArgumentList (
|
||||
"/VERYSILENT", `
|
||||
"/NORESTART", `
|
||||
|
||||
Reference in New Issue
Block a user