From 898dc2c02e7726c7058a713646ee2f7a82544e51 Mon Sep 17 00:00:00 2001 From: Sean Killeen Date: Sat, 15 Dec 2018 20:12:53 -0500 Subject: [PATCH] (GH-981) Add option to use Get-FileHash for versions v4.x and above For compatibility reasons, Chocolatey suggests using `choco install checksum` to verify checksums. But, in Powershell v4 and beyond, users could choose to run `Get-FileHash` as well. This change adds a message in applicable powershell versions (v4.x and later) to suggest this course of action. --- .../helpers/functions/Get-CheckSumValid.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 index 9fafa4995b..bb2e422fa9 100644 --- a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 @@ -146,6 +146,9 @@ param( Write-Warning "Missing package checksums are not allowed (by default for HTTP/FTP, `n HTTPS when feature 'allowEmptyChecksumsSecure' is disabled) for `n safety and security reasons. Although we strongly advise against it, `n if you need this functionality, please set the feature `n 'allowEmptyChecksums' ('choco feature enable -n `n allowEmptyChecksums') `n or pass in the option '--allow-empty-checksums'. You can also pass `n checksums at runtime (recommended). See `choco install -?` for details." Write-Debug "If you are a maintainer attempting to determine the checksum for packaging purposes, please run `n 'choco install checksum' and run 'checksum -t sha256 -f $file' `n Ensure you do this for all remote resources." + if ($PSVersionTable.PSVersion.Major -ge 4){ + Write-Debug "Because you are running Powershell with a major version of v4 or greater, you could also opt to run `n '(Get-FileHash -Path $file -Algorithm SHA256).Hash' `n rather than install a separate tool." + } if ($env:ChocolateyPowerShellHost -eq 'true') { $statement = "The integrity of the file '$([System.IO.Path]::GetFileName($file))'"