chocolatey / home

The place to start for issues with areas of Chocolatey that are infrastructure related, or really any issues could be started here. There is also choco for the CLI client, Chocolatey GUI for the GUI.
Apache License 2.0
29 stars 10 forks source link

Package Validator failing to detect proper use of Install-ChocolateyPackage #307

Closed pauby closed 8 months ago

pauby commented 8 months ago

Checklist

What You Are Seeing?

Package Validator is failing this package version with the error:

Package automation scripts download a remote file without validating the checksum.

The chocolateyInstall.ps1 is captured completely below (so we have it) and can be found on GitHub:

$checksum = '23fea4333b4f1a9c8f8bb13455056acc7f57119672ba015676925bc1982c8f87'
$checksum64 = 'f4b68aee4625d73dc983fe40d49b91ec5765b4d9dd44ff964f35556d6ee7d869'

$32DllPath = Join-Path -Path $Env:SystemRoot -ChildPath (Join-Path -Path 'system32' -ChildPath 'msodbcsql17.dll')
$64DllPath = Join-Path -Path $Env:SystemRoot -ChildPath (Join-Path -Path 'syswow64' -ChildPath 'msodbcsql17.dll')
# Check if the file is missing or the version number is older
$32BitNeeded = -not(Test-path $32DllPath) -or (([Version]$(Get-ItemProperty -Path $32DllPath).VersionInfo.ProductVersion) -lt [Version]$Env:ChocolateyPackageVersion)
$64BitNeeded = -not(Test-path $64DllPath) -or (([Version]$(Get-ItemProperty -Path $64DllPath).VersionInfo.ProductVersion) -lt [Version]$Env:ChocolateyPackageVersion)

$updateNeeded = ($32BitNeeded -or $64BitNeeded -or $Env:ChocolateyForce)
if ($updateNeeded) {
    Install-ChocolateyPackage -PackageName $packageName `
        -FileType $installerType `
        -SilentArgs $silentArgs `
        -Url $url `
        -Url64bit $url64 `
        -ValidExitCodes @(0) `
        -Checksum $checksum `
        -ChecksumType $checksumType `
        -Checksum64 $checksum64 `
        -ChecksumType64 $checksumType
} else {
    Write-Warning "Package not installed as the odbc driver is already present. Use --force to force the a re-installation."
}

It was suggested that quotes around the variables were causing the problem (which have now been removed). It was also suggested the if statement was causing it.

What is Expected?

The package should pass validation.

How Did You Get This To Happen?

See the 'What you are seeing section'. This was a package submitted to Chocolatey Community Repository.

System Details

Installed Packages

N/A (Package Validator is failing it)

Output Log

As this is Package Validation, there are no logs outside of the [package page](https://community.chocolatey.org/packages/sqlserver-odbcdriver-17/17.10.5.1).

Additional Context

When this has been fixed, tests need to be added to catch this in future.

┆Issue is synchronized with this Gitlab issue by Unito