Skip to content

Commit

Permalink
Merge pull request #1263 from sara-rn/arguments-script-template
Browse files Browse the repository at this point in the history
Add arguments to script and template to install tools
  • Loading branch information
Ana06 authored Feb 4, 2025
2 parents 93ce8d3 + 194eda2 commit 65b5678
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/new_node_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ body:
label: Tool's description
description: |
The tool description should be short and not include version specific details or other information that is likely to change in a future version. Example: `Deobfuscator to remove common JS obfuscation techniques.`.
- 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`.
value: --help
- type: input
id: dependencies
attributes:
Expand Down
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/new_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ body:
label: Download SHA256 Hash
description: |
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 `
- 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`.
value: --help
- type: input
id: dependencies
attributes:
Expand Down
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/new_python_tool_pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ body:
label: Tool's description
description: |
The tool description should be short and not include version specific details or other information that is likely to change in a future version. Example: `FakeNet-NG is a dynamic network analysis tool.`
- 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`.
value: --help
- type: input
id: dependencies
attributes:
Expand Down
22 changes: 18 additions & 4 deletions scripts/utils/create_package_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

"""
Expand All @@ -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
"""

"""
Expand Down Expand Up @@ -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
"""

"""
Expand Down Expand Up @@ -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
"""

"""
Expand Down Expand Up @@ -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"),
)


Expand All @@ -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"),
)


Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -470,6 +480,7 @@ def get_script_directory():
"description",
"tool_name",
"category",
"arguments",
],
},
"SINGLE_EXE": {
Expand All @@ -486,6 +497,7 @@ def get_script_directory():
"target_url",
"target_hash",
"console_app",
"arguments",
],
},
"SINGLE_PS1": {
Expand Down Expand Up @@ -529,6 +541,7 @@ def get_script_directory():
"description",
"tool_name",
"category",
"arguments",
],
},
}
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/utils/create_package_template_from_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=<value>" format to avoid issues with if the value contains "-"
cmd_args.append(f"--{k}={v}")

create_package_template.main(cmd_args)

Expand Down

0 comments on commit 65b5678

Please sign in to comment.