Helper functions for tasks (openrelik_worker_common.task_utils).
Provides Base64/JSON serialization of task results, input file resolution from upstream
piped results (get_input_files/3), and glob-based file compatibility filtering
(filter_compatible_files/2).
Summary
Functions
Creates a task result dictionary and encodes it to a Base64 string.
Decodes a Base64-encoded JSON string into an Elixir map.
Encodes a map (dictionary) to a Base64-encoded JSON string.
Filters a list of file dictionaries based on compatibility with filter_dict,
supporting glob (fnmatch) matching on "data_types", "mime_types", and "filenames".
Matches a string against a Unix shell-style wildcard pattern (fnmatch.fnmatch).
Fetches a field from a map by string key or atom key.
Prepares the input files for a task.
Functions
Creates a task result dictionary and encodes it to a Base64 string.
Can be called with a keyword list or map:
create_task_result(
output_files: output_files,
workflow_id: workflow_id,
task_files: [],
command: command,
meta: meta,
file_reports: [],
task_report: nil
)or with positional arguments matching Python's signature:
create_task_result(
output_files,
workflow_id,
task_files \\ [],
command \\ nil,
meta \\ nil,
file_reports \\ [],
task_report \\ nil
)
Decodes a Base64-encoded JSON string into an Elixir map.
Encodes a map (dictionary) to a Base64-encoded JSON string.
Filters a list of file dictionaries based on compatibility with filter_dict,
supporting glob (fnmatch) matching on "data_types", "mime_types", and "filenames".
Matches a string against a Unix shell-style wildcard pattern (fnmatch.fnmatch).
Fetches a field from a map by string key or atom key.
@spec get_input_files(String.t() | [String.t()] | nil, list() | nil, map() | nil) :: list() | term()
Prepares the input files for a task.
Determines the appropriate input files by checking for results from a previous task
(pipe_result as a single Base64-encoded string or a list of Base64-encoded strings)
and then applies any specified file filtering (filter).