From 93e9d16e20a031fad32ebd1a34e2a88233c2cc5e Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Thu, 19 Oct 2023 16:20:30 +0200 Subject: [PATCH] Add python3.vm Add python3.vm, a metapackage that installs python3 and re-adds chocolate shim path to the top of the path. This package is to be requested by all packages needing python3 to ensure they all install the same version and that the paths is being updated. --- .../didier-stevens-suite.vm.nuspec | 6 +++--- .../libraries.python3.vm.nuspec | 6 +++--- .../tools/chocolateyinstall.ps1 | 6 +++--- packages/python3.vm/python3.vm.nuspec | 13 +++++++++++++ packages/python3.vm/tools/chocolateyinstall.ps1 | 11 +++++++++++ scripts/test/lint.py | 1 + scripts/test/test_install.ps1 | 2 +- 7 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 packages/python3.vm/python3.vm.nuspec create mode 100644 packages/python3.vm/tools/chocolateyinstall.ps1 diff --git a/packages/didier-stevens-suite.vm/didier-stevens-suite.vm.nuspec b/packages/didier-stevens-suite.vm/didier-stevens-suite.vm.nuspec index 321b5c52d..583920a18 100644 --- a/packages/didier-stevens-suite.vm/didier-stevens-suite.vm.nuspec +++ b/packages/didier-stevens-suite.vm/didier-stevens-suite.vm.nuspec @@ -2,12 +2,12 @@ didier-stevens-suite.vm - 0.0.0.20230928 + 0.0.0.20231019 Didier Stevens - Tools colection by Didier Stevens + Tools collection by Didier Stevens - + diff --git a/packages/libraries.python3.vm/libraries.python3.vm.nuspec b/packages/libraries.python3.vm/libraries.python3.vm.nuspec index f04894963..52412356d 100644 --- a/packages/libraries.python3.vm/libraries.python3.vm.nuspec +++ b/packages/libraries.python3.vm/libraries.python3.vm.nuspec @@ -2,13 +2,13 @@ libraries.python3.vm - 0.0.0.20230927 - Metapackage to install common Python 3.9 libraries + 0.0.0.20231019 + Metapackage to install common Python libraries Several, check in pypi.org for every of the libraries - + diff --git a/packages/libraries.python3.vm/tools/chocolateyinstall.ps1 b/packages/libraries.python3.vm/tools/chocolateyinstall.ps1 index aaf7c9960..573d733dd 100644 --- a/packages/libraries.python3.vm/tools/chocolateyinstall.ps1 +++ b/packages/libraries.python3.vm/tools/chocolateyinstall.ps1 @@ -16,12 +16,12 @@ try { $modules = $modulesXml.modules.module foreach ($module in $modules) { Write-Host "[+] Attempting to install Python3 module: $($module.name)" - $intallValue = $module.name + $installValue = $module.name if ($module.url) { - $intallValue = $module.url + $installValue = $module.url } - Invoke-Expression "py -3.10 -m pip install $intallValue 2>&1 >> $outputFile" + Invoke-Expression "py -3.10 -m pip install $installValue 2>&1 >> $outputFile" if ($LastExitCode -eq 0) { Write-Host "`t[+] Installed Python 3.10 module: $($module.name)" -ForegroundColor Green diff --git a/packages/python3.vm/python3.vm.nuspec b/packages/python3.vm/python3.vm.nuspec new file mode 100644 index 000000000..3dc670e67 --- /dev/null +++ b/packages/python3.vm/python3.vm.nuspec @@ -0,0 +1,13 @@ + + + + python3.vm + 0.0.0.20231019 + Metapackage for Python 3 to ensure all packages use the same Python version. + Mandiant + + + + + + diff --git a/packages/python3.vm/tools/chocolateyinstall.ps1 b/packages/python3.vm/tools/chocolateyinstall.ps1 new file mode 100644 index 000000000..44a926c40 --- /dev/null +++ b/packages/python3.vm/tools/chocolateyinstall.ps1 @@ -0,0 +1,11 @@ +$ErrorActionPreference = 'Stop' +Import-Module vm.common -Force -DisableNameChecking + +try { + # Re-add shim path to the top of the path to ensure it is found before Python libraries + $shimPath = Join-Path $Env:ChocolateyInstall "bin" -Resolve + [Environment]::SetEnvironmentVariable("Path", "$shimPath;$Env:Path", "Machine") +} catch { + VM-Write-Log-Exception $_ +} + diff --git a/scripts/test/lint.py b/scripts/test/lint.py index e55713bef..82c2286c8 100644 --- a/scripts/test/lint.py +++ b/scripts/test/lint.py @@ -318,6 +318,7 @@ class UsesInvalidCategory(Lint): "notepadplusplus.vm", "notepadpp.plugin.", "npcap.vm", + "python3.vm", "x64dbgpy.vm", ] diff --git a/scripts/test/test_install.ps1 b/scripts/test/test_install.ps1 index d3f92cd38..5d60189ef 100644 --- a/scripts/test/test_install.ps1 +++ b/scripts/test/test_install.ps1 @@ -39,7 +39,7 @@ foreach ($package in $packages) { } -$exclude_tests = @("flarevm.installer.vm", "python3.vm", "installer.vm") +$exclude_tests = @("flarevm.installer.vm", "installer.vm") $failures = New-Object Collections.Generic.List[string] $failed = 0