mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Windows] Add checksum verification for Git (#8317)
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
## File: Install-Git.ps1
|
## File: Install-Git.ps1
|
||||||
## Desc: Install Git for Windows
|
## Desc: Install Git for Windows
|
||||||
|
## Supply chain security: Git - checksum validation, Hub CLI - managed by package manager
|
||||||
################################################################################
|
################################################################################
|
||||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||||
|
|
||||||
# Install the latest version of Git for Windows
|
# 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"
|
[string]$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe"
|
||||||
|
|
||||||
$installerFile = Split-Path $downloadUrl -Leaf
|
$installerFile = Split-Path $downloadUrl -Leaf
|
||||||
Install-Binary -Url $downloadUrl `
|
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
|
||||||
-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 (
|
-ArgumentList (
|
||||||
"/VERYSILENT", `
|
"/VERYSILENT", `
|
||||||
"/NORESTART", `
|
"/NORESTART", `
|
||||||
|
|||||||
Reference in New Issue
Block a user