new: [analyst data] missing views added

feature/event-view-collapsible-objects
iglocska 2024-05-02 11:30:12 +02:00
parent 304581e2b6
commit 523fd1e121
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
5 changed files with 183 additions and 0 deletions

View File

@ -0,0 +1,87 @@
<?php
$seed = mt_rand();
$notes = $analyst_data['notes'] ?? [];
$opinions = $analyst_data['opinions'] ?? [];
$relationships_outbound = $analyst_data['relationships_outbound'] ?? [];
$relationships_inbound = $analyst_data['relationships_inbound'] ?? [];
$notesOpinions = array_merge($notes, $opinions);
$notesOpinionsRelationships = array_merge($notesOpinions, $relationships_outbound);
if(!function_exists("countNotes")) {
function countNotes($notesOpinions) {
$notesTotalCount = count($notesOpinions);
$notesCount = 0;
$relationsCount = 0;
foreach ($notesOpinions as $notesOpinion) {
if ($notesOpinion['note_type'] == 2) { // relationship
$relationsCount += 1;
} else {
$notesCount += 1;
}
if (!empty($notesOpinion['Note'])) {
$nestedCounts = countNotes($notesOpinion['Note']);
$notesTotalCount += $nestedCounts['total'];
$notesCount += $nestedCounts['notesOpinions'];
$relationsCount += $nestedCounts['relations'];
}
if (!empty($notesOpinion['Opinion'])) {
$nestedCounts = countNotes($notesOpinion['Opinion']);
$notesTotalCount += $nestedCounts['total'];
$notesCount += $nestedCounts['notesOpinions'];
$relationsCount += $nestedCounts['relations'];
}
}
return ['total' => $notesTotalCount, 'notesOpinions' => $notesCount, 'relations' => $relationsCount];
}
}
$counts = countNotes($notesOpinions);
$notesOpinionCount = $counts['notesOpinions'];
$relationshipsOutboundCount = count($relationships_outbound);
$relationshipsInboundCount = count($relationships_inbound);
$allCounts = [
'notesOpinions' => $counts['notesOpinions'],
'relationships_outbound' => $relationshipsOutboundCount,
'relationships_inbound' => $relationshipsInboundCount,
];
?>
<?php
if (empty($notesOpinions) && empty($relationshipsOutboundCount) && empty($relationshipsInboundCount)) {
echo sprintf(
'<i class="%s useCursorPointer analyst-data-fetcher" data-seed="%s" data-object-uuid="%s" data-object-type="%s" title="%s"></i>',
$this->FontAwesome->getClass('sticky-note'),
h($seed),
h($object_uuid),
h($object_type),
__('Notes and opinions for this UUID')
);
} else {
echo sprintf(
'<span class="label label-info useCursorPointer analyst-data-fetcher highlight-on-hover" data-seed="%s" data-object-uuid="%s" data-object-type="%s">%s %s %s</span>',
h($seed),
h($object_uuid),
Inflector::tableize(h($object_type)),
sprintf(
'<i class="%s useCursorPointer" title="%s"></i> %s',
$this->FontAwesome->getClass('sticky-note'),
__('Notes and opinions for this UUID'),
$notesOpinionCount
),
sprintf(
'<i class="%s useCursorPointer" title="%s"></i> %s',
$this->FontAwesome->getClass('arrow-up'),
__('Outbound Relationships from this UUID'),
$relationshipsOutboundCount
),
sprintf(
'<i class="%s useCursorPointer" title="%s"></i> %s',
$this->FontAwesome->getClass('arrow-down'),
__('Inbound Relationships to this UUID'),
$relationshipsInboundCount
),
);
}
?>

View File

@ -0,0 +1,68 @@
<?php
echo $this->element('genericElements/assetLoader', [
'css' => ['query-builder.default', 'attack_matrix', 'analyst-data'],
'js' => ['doT', 'extendext', 'moment.min', 'query-builder', 'network-distribution-graph', 'd3', 'd3.custom', 'jquery-ui.min'],
]);
if (empty($seed)) {
$seed = mt_rand();
}
$notes = $analyst_data['notes'] ?? [];
$opinions = $analyst_data['opinions'] ?? [];
$relationships_outbound = $analyst_data['relationships_outbound'] ?? [];
$relationships_inbound = $analyst_data['relationships_inbound'] ?? [];
$notesOpinions = array_merge($notes, $opinions);
$notesOpinionsRelationships = array_merge($notesOpinions, $relationships_outbound);
if(!function_exists("countNotes")) {
function countNotes($notesOpinions) {
$notesTotalCount = count($notesOpinions);
$notesCount = 0;
$relationsCount = 0;
foreach ($notesOpinions as $notesOpinion) {
if ($notesOpinion['note_type'] == 2) { // relationship
$relationsCount += 1;
} else {
$notesCount += 1;
}
if (!empty($notesOpinion['Note'])) {
$nestedCounts = countNotes($notesOpinion['Note']);
$notesTotalCount += $nestedCounts['total'];
$notesCount += $nestedCounts['notesOpinions'];
$relationsCount += $nestedCounts['relations'];
}
if (!empty($notesOpinion['Opinion'])) {
$nestedCounts = countNotes($notesOpinion['Opinion']);
$notesTotalCount += $nestedCounts['total'];
$notesCount += $nestedCounts['notesOpinions'];
$relationsCount += $nestedCounts['relations'];
}
}
return ['total' => $notesTotalCount, 'notesOpinions' => $notesCount, 'relations' => $relationsCount];
}
}
$counts = countNotes($notesOpinions);
$notesOpinionCount = $counts['notesOpinions'];
$relationshipsOutboundCount = count($relationships_outbound);
$relationshipsInboundCount = count($relationships_inbound);
$allCounts = [
'notesOpinions' => $counts['notesOpinions'],
'relationships_outbound' => $relationshipsOutboundCount,
'relationships_inbound' => $relationshipsInboundCount,
];
?>
<?php
echo $this->element('genericElements/Analyst_data/thread', [
'seed' => $seed,
'notes' => $notes,
'opinions' => $opinions,
'relationships_outbound' => $relationships_outbound,
'relationships_inbound' => $relationships_inbound,
'object_type' => $object_type,
'object_uuid' => $object_uuid,
'shortDist' => $shortDist,
'allCounts' => $allCounts,
]);
?>

View File

@ -0,0 +1,7 @@
<?php
$uuid = Hash::get($row, $field['data_path']);
if (empty($uuid) || empty($field['object_type'])) {
throw new MethodNotAllowedException(__('No UUID or object_type provided'), 500);
}
echo $this->element('genericElements/shortUuid', ['uuid' => $uuid]);

View File

@ -0,0 +1,4 @@
<?php
$uuidHalfWidth = 3;
$shortUUID = sprintf('%s...%s', substr($uuid, 0, $uuidHalfWidth), substr($uuid, 36-$uuidHalfWidth, $uuidHalfWidth));
echo sprintf('<span title="%s">%s</span>', $uuid, $shortUUID);

View File

@ -0,0 +1,17 @@
<?php
echo $this->element('genericElements/shortUuid', [
'uuid' => $uuid
]);
if (!empty($object_type)) {
$notes = !empty($notes) ? $notes : [];
$opinions = !empty($opinions) ? $opinions : [];
$relationships = !empty($relationships) ? $relationships : [];
$relationshipsInbound = !empty($relationshipsInbound) ? $relationshipsInbound : [];
echo $this->element('genericElements/Analyst_data/generic_fetcher', [
'analyst_data' => ['notes' => $notes, 'opinions' => $opinions, 'relationships_outbound' => $relationships, 'relationships_inbound' => $relationshipsInbound,],
'object_uuid' => $uuid,
'object_type' => $object_type
]);
}