Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add shell-completion commands #600

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies = [
"cryptography >=42.0.5",
"pyyaml >=6.0",
"pyahocorasick >= 2.0.0",
"quick-click-auto >= 1.0.5"
]
requires-python = ">= 3.8"

Expand Down
17 changes: 17 additions & 0 deletions src/mvt/android/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import logging

import click
from quick_click_auto import enable_click_shell_completion
from quick_click_auto.constants import ShellType

from mvt.common.cmd_check_iocs import CmdCheckIOCS
from mvt.common.help import (
Expand All @@ -31,6 +33,7 @@
HELP_MSG_HASHES,
HELP_MSG_CHECK_IOCS,
HELP_MSG_STIX2,
HELP_MSG_COMMAND_COMPLETION_ANDROID,
)
from mvt.common.logo import logo
from mvt.common.updates import IndicatorsUpdates
Expand Down Expand Up @@ -69,6 +72,20 @@ def version():
return


# ==============================================================================
# Command: shell-completion
# ==============================================================================


@cli.command("shell-completion", help=HELP_MSG_COMMAND_COMPLETION_ANDROID)
def shell_completion():
enable_click_shell_completion(
program_name="mvt-android",
shells={ShellType.BASH, ShellType.ZSH},
verbose=True,
)


# ==============================================================================
# Command: download-apks
# ==============================================================================
Expand Down
3 changes: 3 additions & 0 deletions src/mvt/common/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
HELP_MSG_EXTRACT_KEY = "Extract decryption key from an iTunes backup"
HELP_MSG_CHECK_IOS_BACKUP = "Extract artifacts from an iTunes backup"
HELP_MSG_CHECK_FS = "Extract artifacts from a full filesystem dump"
HELP_MSG_COMMAND_COMPLETION_IOS = "Activate tab autocompletion for mvt-ios."


# Android Specific
HELP_MSG_SERIAL = "Specify a device serial number or HOST:PORT connection string"
Expand All @@ -49,3 +51,4 @@
HELP_MSG_CHECK_BUGREPORT = "Check an Android Bug Report"
HELP_MSG_CHECK_ANDROID_BACKUP = "Check an Android Backup"
HELP_MSG_CHECK_ANDROIDQF = "Check data collected with AndroidQF"
HELP_MSG_COMMAND_COMPLETION_ANDROID = "Activate tab autocompletion for mvt-android."
20 changes: 20 additions & 0 deletions src/mvt/ios/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import os

import click
from quick_click_auto import enable_click_shell_completion
from quick_click_auto.constants import ShellType

from rich.prompt import Prompt

from mvt.common.cmd_check_iocs import CmdCheckIOCS
Expand Down Expand Up @@ -37,6 +40,7 @@
HELP_MSG_CHECK_IOCS,
HELP_MSG_STIX2,
HELP_MSG_CHECK_IOS_BACKUP,
HELP_MSG_COMMAND_COMPLETION_IOS,
)
from .cmd_check_backup import CmdIOSCheckBackup
from .cmd_check_fs import CmdIOSCheckFS
Expand Down Expand Up @@ -69,9 +73,25 @@ def version():
return


# ==============================================================================
# Command: shell-completion
# ==============================================================================


@cli.command("shell-completion", help=HELP_MSG_COMMAND_COMPLETION_IOS)
def shell_completion():
enable_click_shell_completion(
program_name="mvt-ios",
shells={ShellType.BASH},
verbose=True,
)


# ==============================================================================
# Command: decrypt-backup
# ==============================================================================


@cli.command(
"decrypt-backup", context_settings=CONTEXT_SETTINGS, help=HELP_MSG_DECRYPT_BACKUP
)
Expand Down
Loading