mirror of https://github.com/MISP/MISP
fix: [workflow:formatConvert] Make sure to include the __allTags when in converting from event scope
parent
ebb967ca77
commit
6710d1179c
|
@ -44,6 +44,13 @@ class WorkflowFormatConverterTool
|
|||
{
|
||||
$converted = [];
|
||||
$converted = JSONConverterTool::convert($event, false, true);
|
||||
$eventTags = $converted['Event']['Tag'];
|
||||
foreach ($converted['Event']['Attribute'] as $i => $attribute) {
|
||||
$converted['Event']['Attribute'][$i] = self::__propagateTagToAttributes($attribute, $eventTags);
|
||||
}
|
||||
foreach ($converted['Event']['Object'] as $i => $object) {
|
||||
$converted['Event']['Object'][$i] = self::__propagateTagToObjectAttributes($object, $eventTags);
|
||||
}
|
||||
return $converted;
|
||||
}
|
||||
|
||||
|
@ -101,6 +108,33 @@ class WorkflowFormatConverterTool
|
|||
return $converted;
|
||||
}
|
||||
|
||||
private static function __propagateTagToAttributes(array $attribute, array $eventTags): array
|
||||
{
|
||||
$allTags = [];
|
||||
if (!empty($eventTags)) {
|
||||
foreach ($eventTags as $eventTag) {
|
||||
$eventTag['inherited'] = true;
|
||||
$allTags[] = $eventTag;
|
||||
}
|
||||
}
|
||||
if (!empty($attribute['Tag'])) {
|
||||
foreach ($attribute['Tag'] as $tag) {
|
||||
$tag['inherited'] = false;
|
||||
$allTags[] = $tag;
|
||||
}
|
||||
}
|
||||
$attribute['_allTags'] = $allTags;
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
private static function __propagateTagToObjectAttributes(array $object, array $eventTags): array
|
||||
{
|
||||
foreach ($object['Attribute'] as $i => $attribute) {
|
||||
$object['Attribute'][$i] = self::__propagateTagToAttributes($attribute, $eventTags);
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
private static function __encapsulateEntityWithEvent(array $data): array
|
||||
{
|
||||
$eventModel = ClassRegistry::init('Event');
|
||||
|
|
Loading…
Reference in New Issue