Skip to content

Commit 73cdba7

Browse files
committed
Add support for INSTALLER_EXE templates
This commit adds support for creating package templates of type INSTALLER_EXE to deal with the installers these are distributed as EXE files.
1 parent 295f538 commit 73cdba7

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

.github/ISSUE_TEMPLATE/new_package.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ body:
3333
label: Package type
3434
description: |
3535
- **`ZIP_EXE`** - An executable tool distributed in a ZIP file
36+
- **`INSTALLER_EXE`** - An installer distributed as an EXE file
3637
- **`SINGLE_EXE`** - An executable tool (not an installer for the tool) distributed via direct/raw download
3738
- **`SINGLE_PS1`** - A PowerShell script distributed via direct/raw download
3839
- **`OTHER/UNKNOWN`** - A tool distributed in a different way than the ones described above. For example, an EXE or MSI installer for the tool. It is required that you provide details of how the tool is installed in the `Extra information` section. Note this type does not support automation, a PR would be appreciated!
3940
options:
4041
- ZIP_EXE
42+
- INSTALLER_EXE
4143
- SINGLE_EXE
4244
- SINGLE_PS1
4345
- OTHER/UNKNOWN
@@ -135,6 +137,12 @@ body:
135137
label: Download SHA256 Hash
136138
description: |
137139
SHA256 hash of the `.zip` file downloaded from the download url introduced in the previous field. The hash is used for verification purposes. Example: `62af5cce80dbbf5cdf961ec9515549334a2112056d4168fced75c892c24baa95 `
140+
- type: input
141+
id: target_file
142+
attributes:
143+
label: Main EXE file
144+
description: |
145+
Main EXE file name or path under the installed tool folder. Example: `bin\x86\tool.exe` or `tool.exe`
138146
- type: input
139147
id: arguments
140148
attributes:

categories.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ Utilities
3131
Visual Basic
3232
Web Application
3333
Wordlists
34+
VB

scripts/utils/create_package_template.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ def package_version(dependency_version):
118118
VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp ${console_app} -innerFolder ${inner_folder} -arguments $arguments
119119
"""
120120

121+
INSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Stop'
122+
Import-Module vm.common -Force -DisableNameChecking
123+
124+
$toolName = '{tool_name}'
125+
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)
126+
127+
$exeUrl = '{target_url}'
128+
$exeSha256 = '{target_hash}'
129+
130+
$toolDir = Join-Path ${{Env:RAW_TOOLS_DIR}} $toolName
131+
$executablePath = (Join-Path $toolDir '{target_file}')
132+
VM-Install-With-Installer $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /Dir=`"$($toolDir)`"" `
133+
$executablePath $exeUrl -sha256 $exeSha256
134+
"""
135+
121136
"""
122137
Needs the following format strings:
123138
tool_name="...", category="..."
@@ -228,6 +243,17 @@ def package_version(dependency_version):
228243
VM-Uninstall $toolName $category
229244
"""
230245

246+
UNINSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Continue'
247+
Import-Module vm.common -Force -DisableNameChecking
248+
249+
$toolName = '{tool_name}'
250+
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)
251+
252+
VM-Uninstall-With-Uninstaller $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"
253+
254+
VM-Uninstall $toolName $category
255+
"""
256+
231257
"""
232258
Needs the following format strings:
233259
tool_name="...", category="..."
@@ -280,6 +306,23 @@ def create_zip_exe_template(packages_path, **kwargs):
280306
)
281307

282308

309+
def create_installer_exe_template(packages_path, **kwargs):
310+
create_template(
311+
INSTALLER_EXE_TEMPLATE,
312+
uninstall_template=UNINSTALLER_EXE_TEMPLATE,
313+
packages_path=packages_path,
314+
pkg_name=kwargs.get("pkg_name"),
315+
version=kwargs.get("version"),
316+
authors=kwargs.get("authors"),
317+
description=kwargs.get("description"),
318+
tool_name=kwargs.get("tool_name"),
319+
category=kwargs.get("category"),
320+
target_url=kwargs.get("target_url"),
321+
target_hash=kwargs.get("target_hash"),
322+
target_file=kwargs.get("target_file"),
323+
)
324+
325+
283326
def create_node_template(packages_path, **kwargs):
284327
create_template(
285328
NODE_TEMPLATE,
@@ -388,6 +431,7 @@ def create_template(
388431
category="",
389432
target_url="",
390433
target_hash="",
434+
target_file="",
391435
shim_path="",
392436
dependency="",
393437
console_app="",
@@ -427,6 +471,7 @@ def create_template(
427471
arguments=arguments,
428472
target_url=target_url,
429473
target_hash=target_hash,
474+
target_file=target_file,
430475
shim_path=shim_path,
431476
console_app=console_app,
432477
inner_folder=inner_folder,
@@ -476,6 +521,22 @@ def get_script_directory():
476521
"target_hash",
477522
],
478523
},
524+
"INSTALLER_EXE": {
525+
"cb": create_installer_exe_template,
526+
"doc": "An installer distributed as an EXE file",
527+
"example": "<url>/tool.exe",
528+
"arguments": [
529+
"pkg_name",
530+
"version",
531+
"authors",
532+
"description",
533+
"tool_name",
534+
"category",
535+
"target_url",
536+
"target_hash",
537+
"target_file",
538+
],
539+
},
479540
"NODE": {
480541
"cb": create_node_template,
481542
"doc": "An tool from the JavaScript Package Registry installed with npm",
@@ -627,6 +688,7 @@ def main(argv=None):
627688
parser.add_argument("--dependency", type=str, default="", help="Metapackage dependency")
628689
parser.add_argument("--target_url", type=str, default="", help="URL to target file (zip or executable)")
629690
parser.add_argument("--target_hash", type=str, default="", help="SHA256 hash of target file (zip or executable)")
691+
parser.add_argument("--target_file", type=str, default="", help="EXE name/path under the installed tool folder")
630692
parser.add_argument("--shim_path", type=str, default="", help="Metapackage shim path")
631693
parser.add_argument(
632694
"--console_app",

0 commit comments

Comments
 (0)