From c737c6989b1b0f41869ffcd1204774a64bf5ddb8 Mon Sep 17 00:00:00 2001 From: Sara Rincon Date: Fri, 24 Jan 2025 12:03:10 +0100 Subject: [PATCH 1/2] Add arguments to script and template to install tools Add the optional arguments parameter to the install script and ISSUE templates. The wrapper install script must translate the parameter to parameter= because the value might contain - or -- --- .github/ISSUE_TEMPLATE/new_node_package.yml | 7 ++++++ .github/ISSUE_TEMPLATE/new_package.yml | 7 ++++++ .../ISSUE_TEMPLATE/new_python_tool_pip.yml | 7 ++++++ scripts/utils/create_package_template.py | 22 +++++++++++++++---- .../create_package_template_from_json.py | 4 ++-- 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/new_node_package.yml b/.github/ISSUE_TEMPLATE/new_node_package.yml index 96ca27ec4..e89740f33 100644 --- a/.github/ISSUE_TEMPLATE/new_node_package.yml +++ b/.github/ISSUE_TEMPLATE/new_node_package.yml @@ -46,6 +46,13 @@ body: placeholder: ex. 0.0.0.20240513 validations: required: true + - type: input + id: arguments + attributes: + label: Arguments + description: | + Command-line arguments to pass to the tool when running it from the `Tools` directory. For example `--help`. + placeholder: ex. --help - type: dropdown id: category validations: diff --git a/.github/ISSUE_TEMPLATE/new_package.yml b/.github/ISSUE_TEMPLATE/new_package.yml index bc15971c7..f7d023435 100644 --- a/.github/ISSUE_TEMPLATE/new_package.yml +++ b/.github/ISSUE_TEMPLATE/new_package.yml @@ -62,6 +62,13 @@ body: placeholder: ex. 1.4.11 validations: required: true + - type: input + id: arguments + attributes: + label: Arguments + description: | + Command-line arguments to pass to the tool when running it from the `Tools` directory. For example `--help`. + placeholder: ex. --help - type: dropdown id: category validations: diff --git a/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml b/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml index 3b464f6c1..524c9d29f 100644 --- a/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml +++ b/.github/ISSUE_TEMPLATE/new_python_tool_pip.yml @@ -46,6 +46,13 @@ body: placeholder: ex. 1.4.11 validations: required: true + - type: input + id: arguments + attributes: + label: Arguments + description: | + Command-line arguments to pass to the tool when running it from the `Tools` directory. For example `--help`. + placeholder: ex. --help - type: dropdown id: category validations: diff --git a/scripts/utils/create_package_template.py b/scripts/utils/create_package_template.py index d5e3941b4..cb390146a 100755 --- a/scripts/utils/create_package_template.py +++ b/scripts/utils/create_package_template.py @@ -107,8 +107,9 @@ def package_version(dependency_version): $zipUrl = '{target_url}' $zipSha256 = '{target_hash}' +$arguments = '{arguments}' -VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp ${console_app} -innerFolder ${inner_folder} +VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp ${console_app} -innerFolder ${inner_folder} -arguments $arguments """ """ @@ -120,8 +121,9 @@ def package_version(dependency_version): $toolName = '{tool_name}' $category = '{category}' +$arguments = '{arguments}' -VM-Install-Node-Tool -toolName $toolName -category $category -arguments "--help" +VM-Install-Node-Tool -toolName $toolName -category $category -arguments $arguments """ """ @@ -155,8 +157,9 @@ def package_version(dependency_version): $exeUrl = '{target_url}' $exeSha256 = '{target_hash}' +$arguments = '{arguments}' -VM-Install-Single-Exe $toolName $category $exeUrl -exeSha256 $exeSha256 -consoleApp ${console_app} +VM-Install-Single-Exe $toolName $category $exeUrl -exeSha256 $exeSha256 -consoleApp ${console_app} -arguments $arguments """ """ @@ -200,8 +203,9 @@ def package_version(dependency_version): $toolName = '{tool_name}' $category = '{category}' $version = '=={version}' +$arguments = '{arguments}' -VM-Install-With-Pip -toolName $toolName -category $category -version $version +VM-Install-With-Pip -toolName $toolName -category $category -version $version -arguments $arguments """ """ @@ -267,6 +271,7 @@ def create_zip_exe_template(packages_path, **kwargs): target_hash=kwargs.get("target_hash"), console_app=kwargs.get("console_app"), inner_folder=kwargs.get("inner_folder"), + arguments=kwargs.get("arguments"), ) @@ -281,6 +286,7 @@ def create_node_template(packages_path, **kwargs): description=kwargs.get("description"), tool_name=kwargs.get("tool_name"), category=kwargs.get("category"), + arguments=kwargs.get("arguments"), ) @@ -311,6 +317,7 @@ def create_single_exe_template(packages_path, **kwargs): description=kwargs.get("description"), tool_name=kwargs.get("tool_name"), category=kwargs.get("category"), + arguments=kwargs.get("arguments"), target_url=kwargs.get("target_url"), target_hash=kwargs.get("target_hash"), console_app=kwargs.get("console_app"), @@ -358,6 +365,7 @@ def create_pip_template(packages_path, **kwargs): description=kwargs.get("description"), tool_name=kwargs.get("tool_name"), category=kwargs.get("category"), + arguments=kwargs.get("arguments"), ) def create_template( @@ -377,6 +385,7 @@ def create_template( dependency="", console_app="", inner_folder="", + arguments="", ): pkg_path = os.path.join(packages_path, f"{pkg_name}.vm") try: @@ -408,6 +417,7 @@ def create_template( tool_name=tool_name, version=version, category=category, + arguments=arguments, target_url=target_url, target_hash=target_hash, shim_path=shim_path, @@ -470,6 +480,7 @@ def get_script_directory(): "description", "tool_name", "category", + "arguments", ], }, "SINGLE_EXE": { @@ -486,6 +497,7 @@ def get_script_directory(): "target_url", "target_hash", "console_app", + "arguments", ], }, "SINGLE_PS1": { @@ -529,6 +541,7 @@ def get_script_directory(): "description", "tool_name", "category", + "arguments", ], }, } @@ -601,6 +614,7 @@ def main(argv=None): parser.add_argument("--shim_path", type=str, default="", help="Metapackage shim path") parser.add_argument("--console_app", type=str, default="false", choices=["false", "true"], help="The tool is a console application, the shortcut should run it with `cmd /K $toolPath --help` to be able to see the output.") parser.add_argument("--inner_folder", type=str, default="false", choices=["false", "true"], help="The ZIP file unzip to a single folder that contains all the tools.") + parser.add_argument("--arguments", type=str, required=False, default="", help="Command-line arguments for the execution") args = parser.parse_args(args=argv) if args.type is None: diff --git a/scripts/utils/create_package_template_from_json.py b/scripts/utils/create_package_template_from_json.py index 79ba3512e..2b0afb3de 100755 --- a/scripts/utils/create_package_template_from_json.py +++ b/scripts/utils/create_package_template_from_json.py @@ -25,8 +25,8 @@ def main(): for k, v in pkg.items(): if k in ("why", "dependencies", "info"): continue - cmd_args.append(f"--{k}") - cmd_args.append(f"{v}") + # Use "--argument=" format to avoid issues with if the value contains "-" + cmd_args.append(f"--{k}={v}") create_package_template.main(cmd_args) From 311344360149dd8645214d2f59d69b6307da4c49 Mon Sep 17 00:00:00 2001 From: vm-packages Date: Mon, 3 Feb 2025 11:50:06 +0000 Subject: [PATCH 2/2] Add capesolo.vm --- packages/capesolo.vm/capesolo.vm.nuspec | 13 +++++++++++++ packages/capesolo.vm/tools/chocolateyinstall.ps1 | 9 +++++++++ packages/capesolo.vm/tools/chocolateyuninstall.ps1 | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 packages/capesolo.vm/capesolo.vm.nuspec create mode 100644 packages/capesolo.vm/tools/chocolateyinstall.ps1 create mode 100644 packages/capesolo.vm/tools/chocolateyuninstall.ps1 diff --git a/packages/capesolo.vm/capesolo.vm.nuspec b/packages/capesolo.vm/capesolo.vm.nuspec new file mode 100644 index 000000000..bc03ecb9b --- /dev/null +++ b/packages/capesolo.vm/capesolo.vm.nuspec @@ -0,0 +1,13 @@ + + + + capesolo.vm + 0.4.23 + kevoreilly, enzok, doomedraven + test + + + + + + diff --git a/packages/capesolo.vm/tools/chocolateyinstall.ps1 b/packages/capesolo.vm/tools/chocolateyinstall.ps1 new file mode 100644 index 000000000..185e2826a --- /dev/null +++ b/packages/capesolo.vm/tools/chocolateyinstall.ps1 @@ -0,0 +1,9 @@ +$ErrorActionPreference = 'Stop' +Import-Module vm.common -Force -DisableNameChecking + +$toolName = 'CAPEsolo' +$category = 'Debuggers' +$version = '==0.4.23' +$arguments = '--update-yara' + +VM-Install-With-Pip -toolName $toolName -category $category -version $version -arguments $arguments diff --git a/packages/capesolo.vm/tools/chocolateyuninstall.ps1 b/packages/capesolo.vm/tools/chocolateyuninstall.ps1 new file mode 100644 index 000000000..c1426157e --- /dev/null +++ b/packages/capesolo.vm/tools/chocolateyuninstall.ps1 @@ -0,0 +1,7 @@ +$ErrorActionPreference = 'Continue' +Import-Module vm.common -Force -DisableNameChecking + +$toolName = 'CAPEsolo' +$category = 'Debuggers' + +VM-Uninstall-With-Pip $toolName $category