diff --git a/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml b/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml index 91687b84..3225f615 100644 --- a/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml +++ b/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml @@ -7,27 +7,24 @@ body: attributes: value: | Thanks for contributing to [VM-Packages](https://github.com/mandiant/VM-Packages), your package proposal supports tools available for [FLARE-VM](https://github.com/mandiant/flare-vm) and [CommandoVM](https://github.com/mandiant/commando-vm)! :cupid: Please ensure that your suggested tool doesn't already exist within the set of [current packages](https://github.com/mandiant/VM-Packages/tree/main/packages) and that there is no [issue](https://github.com/mandiant/VM-Packages/issues?q=is%3Aopen+is%3Aissue+label%3A%22%3Anew%3A+package%22) proposal already. If the tool is not related malware analysis, incident response, penetration testing and other security related tasking, consider using directly the [Chocolatey community package](https://community.chocolatey.org/packages) if there is one for the tool. + - type: input + id: pkg_name + attributes: + label: Package Name + description: | + The convention is to use lowercase names with the following format: `toolname` or `tool-name` and without `.vm` appended. Example: `js-deobfuscator`. **Please add this name to the issue title as well** (keep the `.vm` in the title). + placeholder: ex. js-deobfuscator + validations: + required: true - type: input id: tool_name attributes: label: Tool Name description: | - The name of the tool being installed (usually the file name with the `.exe`), normally different from the package name. Example: `FakeNet-NG` (tool name) vs `fakenet-ng` (package name). + The name of the tool being installed, normally different from the package name. Example: `FakeNet-NG` (tool name) vs `fakenet-ng` (package name). placeholder: ex. magika validations: required: true - - type: dropdown - id: console_app - validations: - required: true - attributes: - label: Is the tool a console application? - description: | - The tool is a console application, the shortcut should run it with `cmd /K $toolPath --help` to be able to see the output. - Only supported by package types `ZIP_EXE` and `SINGLE_EXE`. - options: - - 'false' - - 'true' - type: input id: version attributes: diff --git a/scripts/utils/create_package_template.py b/scripts/utils/create_package_template.py index 1dbeb2af..50c5427c 100755 --- a/scripts/utils/create_package_template.py +++ b/scripts/utils/create_package_template.py @@ -178,6 +178,21 @@ def package_version(dependency_version): Needs the following format strings: tool_name="...", category="..." """ + +PIP_TEMPLATE = r"""$ErrorActionPreference = 'Stop' +Import-Module vm.common -Force -DisableNameChecking + +$toolName = '{tool_name}' +$category = '{category}' + +VM-Install-With-Pip -toolName $toolName -category $category +""" + +""" +Needs the following format strings: + tool_name="...", category="..." +""" + GENERIC_UNINSTALL_TEMPLATE = r"""$ErrorActionPreference = 'Continue' Import-Module vm.common -Force -DisableNameChecking @@ -211,6 +226,16 @@ def package_version(dependency_version): VM-Uninstall-IDA-Plugin -pluginName $pluginName """ +PIP_UNINSTALL_TEMPLATE = r"""$ErrorActionPreference = 'Continue' +Import-Module vm.common -Force -DisableNameChecking + +$pluginName = '{tool_name}' +$category = '{category}' + +VM-Uninstall-With-Pip $toolName $category + +""" + def create_zip_exe_template(packages_path, **kwargs): @@ -305,7 +330,19 @@ def create_ida_plugin_template(packages_path, **kwargs): target_url=kwargs.get("target_url"), target_hash=kwargs.get("target_hash"), ) - + +def create_pip_template(packages_path, **kwargs): + create_template( + PIP_TEMPLATE, + uninstall_template=PIP_UNINSTALL_TEMPLATE, + packages_path=packages_path, + pkg_name=kwargs.get("pkg_name"), + version=kwargs.get("version"), + authors=kwargs.get("authors"), + description=kwargs.get("description"), + tool_name=kwargs.get("tool_name"), + category=kwargs.get("category"), + ) def create_template( template="", @@ -464,6 +501,19 @@ def get_script_directory(): "shim_path", ], }, + "PIP": { + "cb": create_pip_template, + "doc": "A Python package installed with npm", + "example": "pip install magika", + "arguments": [ + "pkg_name", + "version", + "authors", + "description", + "tool_name", + "category", + ], + }, }