mandiant / VM-Packages

Chocolatey packages supporting the analysis environment projects FLARE-VM & Commando VM.
Apache License 2.0
123 stars 61 forks source link

Add helper function for Node tools #1000

Closed Ana06 closed 2 months ago

Ana06 commented 2 months ago

Introduce a VM-Install-Node-Tool-From-Zip helper function to install Node tools installed with npm and normally downloaded from a GitHub repository as a ZIP with an inner folder.

First step to address https://github.com/mandiant/VM-Packages/issues/999

I do not understand why PSAvoidUsingPositionalParameters has started complaining now in the linter, as we use positional parameters in many functions:

packages\common.vm\tools\vm.common\vm.common.psm1
1 rule violation found.    Severity distribution:  Error = 0, Warning = 0, Information = 1

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSAvoidUsingPositionalParameters    Information  vm.common. 393   Cmdlet 'VM-Install-From-Zip' has positional
                                                 psm1             parameter. Please use named parameters instead of
                                                                  positional parameters when calling a command.

Exclude this violation as it is of Information severity and we wouldneed to make a lot of changes to fix it.

Ana06 commented 2 months ago

@emtuls

I think we are missing the Try-Catch inside of VM-Install-Node-Tool-From-Zip

There is a try-catch inside VM-Install-From-Zip and apart from that we execute a variable assignation and the rest is executed after $ErrorActionPreference = 'Continue', so we do not need an extra try-catch.