Documentation
¶
Overview ¶
Package task provides task management and execution logic for the CipherSwarm agent. It handles the full task lifecycle: retrieval, acceptance, execution, status reporting, and error handling.
Index ¶
- Variables
- func CleanupTaskFiles(attackID int64)
- func DownloadFiles(ctx context.Context, attack *api.Attack) error
- type Manager
- func (m *Manager) AbandonTask(ctx context.Context, task *api.Task)
- func (m *Manager) AcceptTask(ctx context.Context, task *api.Task) error
- func (m *Manager) GetAttackParameters(ctx context.Context, attackID int64) (*api.Attack, error)
- func (m *Manager) GetNewTask(ctx context.Context) (*api.Task, error)
- func (m *Manager) RunTask(ctx context.Context, task *api.Task, attack *api.Attack) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTaskBadResponse is returned when the server returns a bad response. ErrTaskBadResponse = errors.New("bad response") // ErrTaskIsNil is returned when a task parameter is nil. ErrTaskIsNil = errors.New("task is nil") // ErrNoTaskAvailable is returned when no task is available from the server. ErrNoTaskAvailable = errors.New("no task available") )
Functions ¶
func CleanupTaskFiles ¶
func CleanupTaskFiles(attackID int64)
CleanupTaskFiles removes task-related files (hash list and restore file) for the given attack ID. It is used to clean up files when a task fails before a hashcat session is created, since Session.Cleanup() is not available in those code paths. Resource files (word lists, rule lists, mask lists) are intentionally NOT cleaned here because they are shared across attacks and may be reused via checksum-based caching. It is idempotent — files already removed (e.g., by Session.Cleanup) are silently skipped. Errors during removal are logged but do not halt the cleanup process.
func DownloadFiles ¶
DownloadFiles downloads the necessary files for the provided attack. It performs the following steps: 1. Logs the start of the download process. 2. Downloads the hash list associated with the attack. 3. Iterates over resource files (word list, rule list, and mask list) and downloads each one. If any step encounters an error, the function returns that error.
Types ¶
type Manager ¶
type Manager struct {
BackendDevices string
OpenCLDevices string
// contains filtered or unexported fields
}
Manager orchestrates task lifecycle operations using injected API clients.
func NewManager ¶
func NewManager(tc api.TasksClient, ac api.AttacksClient) *Manager
NewManager creates a new task Manager with the given API clients.
func (*Manager) AbandonTask ¶
AbandonTask sets the given task to an abandoned state and logs any errors that occur. If the task is nil, it logs an error and returns immediately.
func (*Manager) AcceptTask ¶
AcceptTask attempts to accept the given task identified by its ID. It logs an error and returns if the task is nil.
func (*Manager) GetAttackParameters ¶
GetAttackParameters retrieves the attack parameters for a given attackID via the API client interface. Returns an Attack object if the API call is successful and the response status is OK.
func (*Manager) GetNewTask ¶
GetNewTask retrieves a new task from the server. If the server responds with HTTP 204 (no content), it returns (nil, ErrNoTaskAvailable). For any other unexpected response status, an error is returned.