mirror of https://github.com/MISP/MISP
fix: [API] tag capture fixed on newly created objects via the API, fixes MISP/PyMISP#236
parent
d860566017
commit
35cd81251d
|
@ -3153,12 +3153,23 @@ class Attribute extends AppModel {
|
|||
'change' => 'Validation errors: ' . json_encode($this->validationErrors) . ' Full Attribute: ' . json_encode($attribute),
|
||||
));
|
||||
} else {
|
||||
$tags = array();
|
||||
if (isset($attribute['Tag'])) {
|
||||
$tags = $attribute['Tag'];
|
||||
}
|
||||
if (isset($attribute['AttributeTag'])) {
|
||||
foreach ($attribute['AttributeTag'] as $at) {
|
||||
unset($at['id']);
|
||||
$tags[] = $at['Tag'];
|
||||
}
|
||||
}
|
||||
foreach ($tags as $tag) {
|
||||
$tag_id = $this->AttributeTag->Tag->captureTag($tag, $user);
|
||||
if ($tag_id) {
|
||||
$this->AttributeTag->create();
|
||||
$at = array();
|
||||
$at['attribute_id'] = $this->id;
|
||||
$at['event_id'] = $eventId;
|
||||
$at['tag_id'] = $tag_id;
|
||||
$this->AttributeTag->save($at);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue