diff --git a/ci/apiv2/test_taskwrapperdisplay.py b/ci/apiv2/test_taskwrapperdisplay.py new file mode 100644 index 000000000..c98cdaa08 --- /dev/null +++ b/ci/apiv2/test_taskwrapperdisplay.py @@ -0,0 +1,18 @@ +from hashtopolis import TaskWrapperDisplay +from utils import BaseTest +class TaskWrapperDisplayTest(BaseTest): + model_class = TaskWrapperDisplay + + def create_test_object(self, *nargs, delete=True, **kwargs): + # Always cleanup hashlist when done, this is potentially confusing, + # since it will also remove the related task + hashlist = self.create_hashlist() + task = self.create_task(hashlist, delete=delete) + return TaskWrapperDisplay.objects.get(pk=task.taskWrapperId) + + def test_task_wrapper_display_should_return_color_field(self): + task_wrapper_display_object = self.create_test_object() + expected_color_value = str(task_wrapper_display_object.color) + self.assertIsNotNone(task_wrapper_display_object.color) + self.assertEqual(task_wrapper_display_object.color, expected_color_value) + self.assertNotEqual("FFFFFF", task_wrapper_display_object.color) \ No newline at end of file diff --git a/src/dba/models/TaskWrapperDisplay.php b/src/dba/models/TaskWrapperDisplay.php index 18ebdee3e..98e8b17f1 100644 --- a/src/dba/models/TaskWrapperDisplay.php +++ b/src/dba/models/TaskWrapperDisplay.php @@ -17,6 +17,7 @@ class TaskWrapperDisplay extends AbstractModel { private ?int $cracked; private ?int $taskId; private ?string $taskName; + private ?string $color; private ?string $attackCmd; private ?int $chunkTime; private ?int $statusTimer; @@ -35,7 +36,7 @@ class TaskWrapperDisplay extends AbstractModel { private ?string $hashTypeDescription; private ?string $groupName; - function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskWrapperMaxAgents, ?int $taskType, ?int $hashlistId, ?int $accessGroupId, ?string $taskWrapperName, ?string $displayName, ?int $taskWrapperIsArchived, ?int $cracked, ?int $taskId, ?string $taskName, ?string $attackCmd, ?int $chunkTime, ?int $statusTimer, ?int $keyspace, ?int $keyspaceProgress, ?int $taskPriority, ?int $taskMaxAgents, ?int $isSmall, ?int $isCpuTask, ?int $taskIsArchived, ?int $taskUsePreprocessor, ?string $hashlistName, ?int $hashCount, ?int $hashlistCracked, ?int $hashTypeId, ?string $hashTypeDescription, ?string $groupName) { + function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskWrapperMaxAgents, ?int $taskType, ?int $hashlistId, ?int $accessGroupId, ?string $taskWrapperName, ?string $displayName, ?int $taskWrapperIsArchived, ?int $cracked, ?int $taskId, ?string $taskName, ?string $color, ?string $attackCmd, ?int $chunkTime, ?int $statusTimer, ?int $keyspace, ?int $keyspaceProgress, ?int $taskPriority, ?int $taskMaxAgents, ?int $isSmall, ?int $isCpuTask, ?int $taskIsArchived, ?int $taskUsePreprocessor, ?string $hashlistName, ?int $hashCount, ?int $hashlistCracked, ?int $hashTypeId, ?string $hashTypeDescription, ?string $groupName) { $this->taskWrapperId = $taskWrapperId; $this->taskWrapperPriority = $taskWrapperPriority; $this->taskWrapperMaxAgents = $taskWrapperMaxAgents; @@ -48,6 +49,7 @@ function __construct(?int $taskWrapperId, ?int $taskWrapperPriority, ?int $taskW $this->cracked = $cracked; $this->taskId = $taskId; $this->taskName = $taskName; + $this->color = $color; $this->attackCmd = $attackCmd; $this->chunkTime = $chunkTime; $this->statusTimer = $statusTimer; @@ -81,6 +83,7 @@ function getKeyValueDict(): array { $dict['cracked'] = $this->cracked; $dict['taskId'] = $this->taskId; $dict['taskName'] = $this->taskName; + $dict['color'] = $this->color; $dict['attackCmd'] = $this->attackCmd; $dict['chunkTime'] = $this->chunkTime; $dict['statusTimer'] = $this->statusTimer; @@ -116,6 +119,7 @@ static function getFeatures(): array { $dict['cracked'] = ['read_only' => True, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => True, "private" => False, "alias" => "cracked", "public" => False, "dba_mapping" => False]; $dict['taskId'] = ['read_only' => True, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => True, "private" => False, "alias" => "taskId", "public" => False, "dba_mapping" => False]; $dict['taskName'] = ['read_only' => False, "type" => "str(256)", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "taskName", "public" => False, "dba_mapping" => False]; + $dict['color'] = ['read_only' => False, "type" => "str(50)", "subtype" => "unset", "choices" => "unset", "null" => True, "pk" => False, "protected" => False, "private" => False, "alias" => "color", "public" => False, "dba_mapping" => False]; $dict['attackCmd'] = ['read_only' => False, "type" => "str(65535)", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "attackCmd", "public" => False, "dba_mapping" => False]; $dict['chunkTime'] = ['read_only' => False, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "chunkTime", "public" => False, "dba_mapping" => False]; $dict['statusTimer'] = ['read_only' => False, "type" => "int", "subtype" => "unset", "choices" => "unset", "null" => False, "pk" => False, "protected" => False, "private" => False, "alias" => "statusTimer", "public" => False, "dba_mapping" => False]; @@ -249,6 +253,14 @@ function setTaskName(?string $taskName): void { $this->taskName = $taskName; } + function getColor(): ?string { + return $this->color; + } + + function setColor(?string $color): void { + $this->color = $color; + } + function getAttackCmd(): ?string { return $this->attackCmd; } @@ -397,6 +409,7 @@ function setGroupName(?string $groupName): void { const CRACKED = "cracked"; const TASK_ID = "taskId"; const TASK_NAME = "taskName"; + const COLOR = "color"; const ATTACK_CMD = "attackCmd"; const CHUNK_TIME = "chunkTime"; const STATUS_TIMER = "statusTimer"; diff --git a/src/dba/models/TaskWrapperDisplayFactory.php b/src/dba/models/TaskWrapperDisplayFactory.php index 50552a138..b32d0250f 100644 --- a/src/dba/models/TaskWrapperDisplayFactory.php +++ b/src/dba/models/TaskWrapperDisplayFactory.php @@ -30,7 +30,7 @@ function getCacheValidTime(): int { * @return TaskWrapperDisplay */ function getNullObject(): TaskWrapperDisplay { - return new TaskWrapperDisplay(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); + return new TaskWrapperDisplay(-1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); } /** @@ -44,7 +44,7 @@ function createObjectFromDict($pk, $dict): TaskWrapperDisplay { $conv[strtolower($key)] = $val; } $dict = $conv; - return new TaskWrapperDisplay($dict['taskwrapperid'], $dict['taskwrapperpriority'], $dict['taskwrappermaxagents'], $dict['tasktype'], $dict['hashlistid'], $dict['accessgroupid'], $dict['taskwrappername'], $dict['displayname'], $dict['taskwrapperisarchived'], $dict['cracked'], $dict['taskid'], $dict['taskname'], $dict['attackcmd'], $dict['chunktime'], $dict['statustimer'], $dict['keyspace'], $dict['keyspaceprogress'], $dict['taskpriority'], $dict['taskmaxagents'], $dict['issmall'], $dict['iscputask'], $dict['taskisarchived'], $dict['taskusepreprocessor'], $dict['hashlistname'], $dict['hashcount'], $dict['hashlistcracked'], $dict['hashtypeid'], $dict['hashtypedescription'], $dict['groupname']); + return new TaskWrapperDisplay($dict['taskwrapperid'], $dict['taskwrapperpriority'], $dict['taskwrappermaxagents'], $dict['tasktype'], $dict['hashlistid'], $dict['accessgroupid'], $dict['taskwrappername'], $dict['displayname'], $dict['taskwrapperisarchived'], $dict['cracked'], $dict['taskid'], $dict['taskname'], $dict['color'], $dict['attackcmd'], $dict['chunktime'], $dict['statustimer'], $dict['keyspace'], $dict['keyspaceprogress'], $dict['taskpriority'], $dict['taskmaxagents'], $dict['issmall'], $dict['iscputask'], $dict['taskisarchived'], $dict['taskusepreprocessor'], $dict['hashlistname'], $dict['hashcount'], $dict['hashlistcracked'], $dict['hashtypeid'], $dict['hashtypedescription'], $dict['groupname']); } /** diff --git a/src/dba/models/generator.php b/src/dba/models/generator.php index f92957560..b8a032941 100644 --- a/src/dba/models/generator.php +++ b/src/dba/models/generator.php @@ -453,6 +453,7 @@ ['name' => 'cracked', 'read_only' => True, 'type' => 'int', 'protected' => True], ['name' => 'taskId', 'read_only' => True, 'type' => 'int', 'protected' => True], ['name' => 'taskName', 'read_only' => False, 'type' => 'str(256)'], + ['name' => 'color', 'read_only' => False, 'type' => 'str(50)', 'null' => True], ['name' => 'attackCmd', 'read_only' => False, 'type' => 'str(65535)'], ['name' => 'chunkTime', 'read_only' => False, 'type' => 'int'], ['name' => 'statusTimer', 'read_only' => False, 'type' => 'int'], diff --git a/src/migrations/mysql/20260413140000_task-view.sql b/src/migrations/mysql/20260413140000_task-view.sql index 6d0422f7d..e67efd677 100644 --- a/src/migrations/mysql/20260413140000_task-view.sql +++ b/src/migrations/mysql/20260413140000_task-view.sql @@ -2,7 +2,7 @@ CREATE VIEW TaskWrapperDisplay AS SELECT tw.taskWrapperId AS taskWrapperId, tw.priority AS taskWrapperPriority, tw.maxAgents AS taskWrapperMaxAgents, tw.taskType AS taskType, tw.hashlistId AS hashlistId, tw.accessGroupId AS accessGroupId, tw.taskWrapperName AS taskWrapperName, tw.isArchived AS taskWrapperIsArchived, tw.cracked AS cracked, - t.taskId AS taskId, t.taskName AS taskName, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, + t.taskId AS taskId, t.taskName AS taskName, t.color AS color, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, t.statusTimer AS statusTimer, t.keyspace AS keyspace, t.keyspaceProgress AS keyspaceProgress, t.priority AS taskPriority, t.maxAgents AS taskMaxAgents, t.isArchived AS taskIsArchived, t.isSmall AS isSmall, t.isCpuTask AS isCpuTask, t.usePreprocessor AS taskUsePreprocessor, diff --git a/src/migrations/postgres/20260413140000_task-view.sql b/src/migrations/postgres/20260413140000_task-view.sql index 6d0422f7d..e67efd677 100644 --- a/src/migrations/postgres/20260413140000_task-view.sql +++ b/src/migrations/postgres/20260413140000_task-view.sql @@ -2,7 +2,7 @@ CREATE VIEW TaskWrapperDisplay AS SELECT tw.taskWrapperId AS taskWrapperId, tw.priority AS taskWrapperPriority, tw.maxAgents AS taskWrapperMaxAgents, tw.taskType AS taskType, tw.hashlistId AS hashlistId, tw.accessGroupId AS accessGroupId, tw.taskWrapperName AS taskWrapperName, tw.isArchived AS taskWrapperIsArchived, tw.cracked AS cracked, - t.taskId AS taskId, t.taskName AS taskName, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, + t.taskId AS taskId, t.taskName AS taskName, t.color AS color, t.attackCmd AS attackCmd, t.chunkTime AS chunkTime, t.statusTimer AS statusTimer, t.keyspace AS keyspace, t.keyspaceProgress AS keyspaceProgress, t.priority AS taskPriority, t.maxAgents AS taskMaxAgents, t.isArchived AS taskIsArchived, t.isSmall AS isSmall, t.isCpuTask AS isCpuTask, t.usePreprocessor AS taskUsePreprocessor,