From 8c481fa7e665ecd3c60042905ba9d339a7d0632e Mon Sep 17 00:00:00 2001 From: Sara Rincon Date: Fri, 24 Jan 2025 12:03:10 +0100 Subject: [PATCH] Add try-catch to VM-Pip-Install Add missing `try-catch` to `VM-Pip-Install` so that packages using this function (such as ida.plugin.hashdb.vm) don't have to add a try-catch. --- packages/common.vm/common.vm.nuspec | 2 +- .../common.vm/tools/vm.common/vm.common.psm1 | 14 ++++++++----- .../ida.plugin.hashdb.vm.nuspec | 2 +- .../tools/chocolateyinstall.ps1 | 21 ++++++++----------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/common.vm/common.vm.nuspec b/packages/common.vm/common.vm.nuspec index a66f7f0e4..711ea243e 100755 --- a/packages/common.vm/common.vm.nuspec +++ b/packages/common.vm/common.vm.nuspec @@ -2,7 +2,7 @@ common.vm - 0.0.0.20250122 + 0.0.0.20250124 Common libraries for VM-packages Mandiant diff --git a/packages/common.vm/tools/vm.common/vm.common.psm1 b/packages/common.vm/tools/vm.common/vm.common.psm1 index af2353e32..d4b2caa7b 100755 --- a/packages/common.vm/tools/vm.common/vm.common.psm1 +++ b/packages/common.vm/tools/vm.common/vm.common.psm1 @@ -1752,12 +1752,16 @@ function VM-Pip-Install { param ( [string]$libraries # Comma-separated list of libraries to install, example: "flare-capa", "flare-capa,tabulate" ) - # Create output file to log python module installation details - $outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR} + try { + # Create output file to log python module installation details + $outputFile = VM-New-Install-Log ${Env:VM_COMMON_DIR} - ForEach ($library in $libraries.Split(",")) { - # Ignore warning with `-W ignore` to avoid warnings like deprecation to fail the installation - Invoke-Expression "py -3.10 -W ignore -m pip install $library --disable-pip-version-check 2>&1 >> $outputFile" + ForEach ($library in $libraries.Split(",")) { + # Ignore warning with `-W ignore` to avoid warnings like deprecation to fail the installation + Invoke-Expression "py -3.10 -W ignore -m pip install $library --disable-pip-version-check 2>&1 >> $outputFile" + } + } catch { + VM-Write-Log-Exception $_ } } diff --git a/packages/ida.plugin.hashdb.vm/ida.plugin.hashdb.vm.nuspec b/packages/ida.plugin.hashdb.vm/ida.plugin.hashdb.vm.nuspec index 3175fcaaf..b6a20fd6e 100644 --- a/packages/ida.plugin.hashdb.vm/ida.plugin.hashdb.vm.nuspec +++ b/packages/ida.plugin.hashdb.vm/ida.plugin.hashdb.vm.nuspec @@ -2,7 +2,7 @@ ida.plugin.hashdb.vm - 1.10.0 + 1.10.0.20250124 OALabs Malware string hash lookup plugin for IDA Pro diff --git a/packages/ida.plugin.hashdb.vm/tools/chocolateyinstall.ps1 b/packages/ida.plugin.hashdb.vm/tools/chocolateyinstall.ps1 index 92d557dc7..a10f1f249 100644 --- a/packages/ida.plugin.hashdb.vm/tools/chocolateyinstall.ps1 +++ b/packages/ida.plugin.hashdb.vm/tools/chocolateyinstall.ps1 @@ -1,15 +1,12 @@ $ErrorActionPreference = 'Stop' Import-Module vm.common -Force -DisableNameChecking -try { - # Install requirements: https://github.com/OALabs/hashdb-ida/blob/1.10.0/requirements.txt - VM-Pip-Install requests - - $pluginName = 'hashdb.py' - $pluginUrl = 'https://github.com/OALabs/hashdb-ida/releases/download/1.10.0/hashdb.py' - $pluginSha256 = '8d153281ce9feccf00eb63c56fe0fbcc9534ce005635a91565c2340fbf5db651' - - VM-Install-IDA-Plugin -pluginName $pluginName -pluginUrl $pluginUrl -pluginSha256 $pluginSha256 -} catch { - VM-Write-Log-Exception $_ -} + +# Install requirements: https://github.com/OALabs/hashdb-ida/blob/1.10.0/requirements.txt +VM-Pip-Install requests + +$pluginName = 'hashdb.py' +$pluginUrl = 'https://github.com/OALabs/hashdb-ida/releases/download/1.10.0/hashdb.py' +$pluginSha256 = '8d153281ce9feccf00eb63c56fe0fbcc9534ce005635a91565c2340fbf5db651' + +VM-Install-IDA-Plugin -pluginName $pluginName -pluginUrl $pluginUrl -pluginSha256 $pluginSha256