Task Utilities
This module provides utility functions for working with Karton tasks in Artemis.
- artemis.task_utils.get_analysis_num_finished_tasks(redis: Redis, root_uid: str) int
- artemis.task_utils.get_analysis_num_in_progress_tasks(redis: Redis, root_uid: str) int
- artemis.task_utils.get_target_host(task: Task) str
Extract the target host (domain, ip) from a Karton task based on its type.
- Parameters:
task (Task) – A Karton task object
- Returns:
A string representing the target host (domain name, or IP address)
- Return type:
str
- Raises:
ValueError – If the task type is unknown
AssertionError – If the extracted payload is not of the supported type
- artemis.task_utils.get_target_url(task: Task) str
Build or extract a complete URL from a Karton task.
If the task already contains an URL, it is returned directly, otherwise it’s constructed.
- Parameters:
task (Task) – A Karton task object
- Returns:
A complete URL string
- Return type:
str
- Raises:
NotImplementedError – If the service is not HTTP
AssertionError – If the extracted URL is not a string
- artemis.task_utils.increase_analysis_num_finished_tasks(redis: Redis, root_uid: str, by: int = 1) None
- artemis.task_utils.increase_analysis_num_in_progress_tasks(redis: Redis, root_uid: str, by: int = 1) None