mirror of https://github.com/MISP/MISP
fix: Fixed an issue where adding an attribute to an existing object isn't handled correctly via the API / sync, fixes #2760
parent
b9ec38ca71
commit
8ed3883f0b
|
@ -641,6 +641,9 @@ class Attribute extends AppModel {
|
|||
if (!isset($this->data['Attribute']['type'])) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($this->data['Attribute']['value'])) {
|
||||
return false;
|
||||
}
|
||||
// remove leading and trailing blanks
|
||||
$this->data['Attribute']['value'] = trim($this->data['Attribute']['value']);
|
||||
|
||||
|
@ -3049,7 +3052,11 @@ class Attribute extends AppModel {
|
|||
'deleted',
|
||||
'disable_correlation'
|
||||
);
|
||||
if (!$this->save($attribute, array('fieldList' => $fieldList))) {
|
||||
if ($objectId) {
|
||||
$fieldList[] = 'object_id';
|
||||
$fieldList[] = 'object_relation';
|
||||
}
|
||||
if (!$this->save(array('Attribute' => $attribute), array('fieldList' => $fieldList))) {
|
||||
$attribute_short = (isset($attribute['category']) ? $attribute['category'] : 'N/A') . '/' . (isset($attribute['type']) ? $attribute['type'] : 'N/A') . ' ' . (isset($attribute['value']) ? $attribute['value'] : 'N/A');
|
||||
$this->Log = ClassRegistry::init('Log');
|
||||
$this->Log->create();
|
||||
|
|
|
@ -524,7 +524,8 @@ class MispObject extends AppModel {
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
$object['timestamp'] = $dateObj->getTimestamp();
|
||||
$date = new DateTime();
|
||||
$object['timestamp'] = $date->getTimestamp();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -558,7 +559,7 @@ class MispObject extends AppModel {
|
|||
'email' => $user['email'],
|
||||
'action' => 'edit',
|
||||
'user_id' => $user['id'],
|
||||
'title' => 'Attribute dropped due to validation for Event ' . $eventId . ' failed: ' . $object['Object']['name'],
|
||||
'title' => 'Attribute dropped due to validation for Event ' . $eventId . ' failed: ' . $object['name'],
|
||||
'change' => 'Validation errors: ' . json_encode($this->validationErrors) . ' Full Object: ' . json_encode($attribute),
|
||||
));
|
||||
return $this->validationErrors;
|
||||
|
@ -567,9 +568,10 @@ class MispObject extends AppModel {
|
|||
}
|
||||
if (!empty($object['Attribute'])) {
|
||||
foreach ($object['Attribute'] as $attribute) {
|
||||
$result = $this->Attribute->editAttribute($attribute, $eventId, $user, $this->id, $log);
|
||||
$result = $this->Attribute->editAttribute($attribute, $eventId, $user, $object['id'], $log);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateTimestamp($id) {
|
||||
|
|
Loading…
Reference in New Issue