From 241df526af00894fab02c5b5e03d2caed414da07 Mon Sep 17 00:00:00 2001 From: emtuls Date: Wed, 10 Apr 2024 10:51:17 -0400 Subject: [PATCH] Add signature verification to Regcool --- packages/regcool.vm/regcool.vm.nuspec | 2 +- .../regcool.vm/tools/chocolateyinstall.ps1 | 34 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packages/regcool.vm/regcool.vm.nuspec b/packages/regcool.vm/regcool.vm.nuspec index 660d11488..4f59a53d4 100644 --- a/packages/regcool.vm/regcool.vm.nuspec +++ b/packages/regcool.vm/regcool.vm.nuspec @@ -2,7 +2,7 @@ regcool.vm - 2.0.0.20240408 + 0.0.0.20240410 Kurt Zimmermann In addition to all the features that you can find in RegEdit and RegEdt32, RegCool adds many powerful features that allow you to work faster and more efficiently with registry related tasks diff --git a/packages/regcool.vm/tools/chocolateyinstall.ps1 b/packages/regcool.vm/tools/chocolateyinstall.ps1 index c63a327a0..210c23a50 100644 --- a/packages/regcool.vm/tools/chocolateyinstall.ps1 +++ b/packages/regcool.vm/tools/chocolateyinstall.ps1 @@ -3,8 +3,38 @@ Import-Module vm.common -Force -DisableNameChecking $toolName = 'RegCool' $category = 'Registry' +$toolDir = Join-Path ${Env:RAW_TOOLS_DIR} $toolName $zipUrl = 'https://kurtzimmermann.com/files/RegCoolX64.zip' -$zipSha256 = '7bf7ba799059b4ec4035c504de6ea27ea2e9440379b4ec25d09cb58f17ce609b' -VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp $false -innerFolder $false +try { + # Download zip + $packageArgs = @{ + packageName = $env:ChocolateyPackageName + file = Join-Path ${Env:TEMP} $toolName + url = $zipUrl + } + $filePath = Get-ChocolateyWebFile @packageArgs + + # Extract zip + Get-ChocolateyUnzip -FileFullPath $filePath -Destination $toolDir + + # Check signature of all unzip files + Get-ChildItem -Path "$toolDir\*.{exe,dll}" | ForEach-Object { + VM-Assert-Signature $_.FullName + } +} catch { + # Remove files with invalid signature + Remove-Item $toolDir -Recurse -Force -ea 0 | Out-Null + VM-Write-Log-Exception $_ +} + +try { + $shortcutDir = Join-Path ${Env:TOOL_LIST_DIR} $category + $shortcut = Join-Path $shortcutDir "$toolname.lnk" + $toolPath = Join-Path $toolDir "$toolName.exe" + Install-ChocolateyShortcut -shortcutFilePath $shortcut -targetPath $toolPath + VM-Assert-Path $shortcut +} catch { + VM-Write-Log-Exception $_ +}