OpenrelikWorkerCommon.ArchiveUtils (openrelik_worker_common v0.1.0)

Copy Markdown View Source

Helper functions for extracting archives (openrelik_worker_common.archive_utils).

Summary

Functions

extract_archive(input_file, output_folder, log_file, file_filter_or_opts \\ [], archive_password \\ nil, ignore_prompts \\ true, file_exclusion_filter \\ [])

@spec extract_archive(
  map(),
  String.t(),
  String.t(),
  list() | keyword(),
  String.t() | nil,
  boolean(),
  list()
) :: {String.t(), String.t()}

Unpacks an archive using tar (for .tgz and .tar.gz) or 7z (for all other archive formats).

Parameters

  • input_file - Input file map containing "path" and "display_name".
  • output_folder - OpenRelik output folder path.
  • log_file - Path to write command stdout/stderr logs.
  • opts - Optional keyword list (or positional arguments via extract_archive/4..7):
    • :file_filter - List of file patterns to extract (default []).
    • :archive_password - Password of the input archive (default nil).
    • :ignore_prompts - Whether to ignore prompts during extraction (default true).
    • :file_exclusion_filter - List of file patterns to exclude (default []).
    • :which_fn - Optional (String.t() -> String.t() | boolean() | nil) override for System.find_executable/1.

    • :cmd_runner - Optional (command_list, log_file -> integer()) override for command execution.
    • :mkdir_fn - Optional (String.t() -> :ok) override for directory creation.

Returns

{command_string, export_folder} where command_string is the executed command string and export_folder is the root folder path to the unpacked archive.