Skip to content

Commit e6dd9a4

Browse files
author
jessevz
committed
Fixed copilot suggestions
1 parent 2f4d295 commit e6dd9a4

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/inc/apiv2/common/AbstractBaseAPI.class.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,15 @@ protected function getUpdateHandlers($id, $current_user): array {
150150
}
151151

152152
/**
153-
* Overridable function to aggregate data in the object. Currently only used for Tasks
154-
* returns the aggregated data in key value pairs
153+
* Overridable function to aggregate data in the object. Used for Tasks and Agents.
154+
*
155+
* @param object $object The object to aggregate data from.
156+
* @param array &$includedData Array passed by reference; implementations can add related resources
157+
* for inclusion in the response by appending to this array.
158+
* @return array Aggregated data as key-value pairs.
159+
*
160+
* Implementations should use $includedData to collect related resources that should be included
161+
* in the API response, such as related entities or additional data.
155162
*/
156163
public static function aggregateData(object $object, array &$includedData=[]): array
157164
{
@@ -1183,7 +1190,7 @@ protected function processExpands(
11831190
// Add missing expands to expands in case they have been added in aggregateData()
11841191
$expandKeys = array_keys($expandResult);
11851192
$diffs = array_diff($expandKeys, $expands);
1186-
$expands = array_merge($expandKeys, $diffs);
1193+
$expands = array_merge($expands, $diffs);
11871194

11881195
foreach ($expands as $expand) {
11891196
if (!array_key_exists($object->getId(), $expandResult[$expand])) {
@@ -1197,16 +1204,16 @@ protected function processExpands(
11971204
$includedResources = self::addToRelatedResources($includedResources, $apiClass->obj2Resource($expandObject));
11981205
}
11991206
} else {
1200-
if ($expandResultObject === null) {
1207+
if ($expandResultObject === null) {
12011208
// to-only relation which is nullable
12021209
continue;
1203-
}
1210+
}
12041211
$includedResources = self::addToRelatedResources($includedResources, $apiClass->obj2Resource($expandResultObject));
12051212
}
12061213
}
12071214

12081215
return $includedResources;
1209-
}
1216+
}
12101217

12111218
/**
12121219
* Validate if user is allowed to access hashlist

src/inc/apiv2/model/agents.routes.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,19 @@ protected function getUpdateHandlers($id, $current_user): array {
3838
];
3939
}
4040

41+
/**
42+
* Overridable function to aggregate data in the object. active chunk of agent is appended to
43+
* $included_data.
44+
*
45+
* @param object $object the agent object were data is aggregated from
46+
* @param array &$includedData
47+
* @return array not used here
48+
*/
4149
static function aggregateData(object $object, array &$included_data = []): array {
4250
$agentId = $object->getId();
4351
$qFs = [];
4452
$qFs[] = new QueryFilter(Chunk::AGENT_ID, $agentId, "=");
45-
$qFs[] = new QueryFilter(Chunk::STATE, 2, "=");
53+
$qFs[] = new QueryFilter(Chunk::STATE, DHashcatStatus::RUNNING, "=");
4654

4755
$active_chunk = Factory::getChunkFactory()->filter([Factory::FILTER => $qFs], true);
4856
if ($active_chunk !== NULL) {

0 commit comments

Comments
 (0)