Skip to content

Commit

Permalink
Change script to add PIP package
Browse files Browse the repository at this point in the history
  • Loading branch information
sara-rn committed Jan 10, 2025
1 parent c7bf18f commit 6574bb5
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 14 deletions.
23 changes: 10 additions & 13 deletions .github/ISSUE_TEMPLATE/new_python_tool_pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
52 changes: 51 additions & 1 deletion scripts/utils/create_package_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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="",
Expand Down Expand Up @@ -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",
],
},
}


Expand Down

0 comments on commit 6574bb5

Please sign in to comment.