acquire.acquire.utils

Module Contents

Classes

StrEnum

Sortable and serializible string-based enum

Functions

create_argument_parser

parse_acquire_args

Parse and set the acquire command line arguments.

check_and_set_log_args

Check command line arguments which are related to logging.

check_and_set_acquire_args

Check the command line arguments and set some derived arguments.

get_user_name

is_user_admin

get_utc_now

get_utc_now_str

get_formatted_exception

format_output_name

persist_execution_report

normalize_path

Attributes

class acquire.acquire.utils.StrEnum

Bases: str, enum.Enum

Sortable and serializible string-based enum

acquire.acquire.utils.create_argument_parser(profiles: dict, volatile: dict, modules: dict) argparse.ArgumentParser
acquire.acquire.utils.parse_acquire_args(parser: argparse.ArgumentParser, config: dict[str, Any]) tuple[argparse.Namespace, list[str]]

Parse and set the acquire command line arguments.

The arguments are set to values supplied in config[arguments], when not changed from the default values specified in parser.

The config dict is added to the parsed command line arguments for convenience of later use.

Parameters:
  • parser – A parser for acquire command line arguments.

  • config – A dict of global configuration values.

Returns:

A command line arguments namespace

acquire.acquire.utils.check_and_set_log_args(args: argparse.Namespace)

Check command line arguments which are related to logging.

Also some arguments derived from the user supplied ones are set in the args namespace for convenience.

This function is separate from check_and_set_acquire_args() as logging needs to be setup as soon as possible when running acquire.

Parameters:

args – The namespace containing the command line arguments.

Raises:

ValueError – When an invalid combination of arguments is found.

acquire.acquire.utils.check_and_set_acquire_args(args: argparse.Namespace, upload_plugins: acquire.uploaders.plugin_registry.UploaderRegistry)

Check the command line arguments and set some derived arguments.

This function is separate from check_and_set_log_args() as logging needs to be setup as soon as possible when running acquire.

Parameters:
  • args – The namespace containing the command line arguments.

  • upload_plugins – The registry of available upload plugins.

Raises:

ValueError – When an invalid combination of arguments is found.

acquire.acquire.utils.get_user_name() str
acquire.acquire.utils.is_user_admin() bool
acquire.acquire.utils.get_utc_now() datetime.datetime
acquire.acquire.utils.get_utc_now_str() str
acquire.acquire.utils.get_formatted_exception() str
acquire.acquire.utils.format_output_name(prefix: str, postfix: str | None = None, ext: str | None = None) str
acquire.acquire.utils.persist_execution_report(path: pathlib.Path, report_data: dict) pathlib.Path
acquire.acquire.utils.DEVICE_SUBST
acquire.acquire.utils.SYSVOL_SUBST
acquire.acquire.utils.SYSVOL_UPPER_SUBST
acquire.acquire.utils.DRIVE_LOWER_SUBST
acquire.acquire.utils.normalize_path(target: dissect.target.Target, path: str | pathlib.Path, resolve_parents: bool = False, preserve_case: bool = True) str