mirror of https://github.com/MISP/MISP
parent
a28909d366
commit
aa15896839
|
@ -194,6 +194,7 @@ class ObjectsController extends AppController
|
|||
$error = 'Could not save the object as no attributes were set.';
|
||||
} else {
|
||||
foreach ($object['Attribute'] as $k => $attribute) {
|
||||
unset($object['Attribute'][$k]['id']);
|
||||
$object['Attribute'][$k]['event_id'] = $eventId;
|
||||
$this->MispObject->Event->Attribute->set($attribute);
|
||||
if (!$this->MispObject->Event->Attribute->validates()) {
|
||||
|
@ -220,6 +221,7 @@ class ObjectsController extends AppController
|
|||
$error = $this->MispObject->ObjectTemplate->checkTemplateConformity($template, $object);
|
||||
}
|
||||
if ($error === true) {
|
||||
unset($object['Object']['id']);
|
||||
$result = $this->MispObject->saveObject($object, $eventId, $template, $this->Auth->user(), $errorBehaviour = 'halt');
|
||||
if (is_numeric($result)) {
|
||||
$this->MispObject->Event->unpublishEvent($eventId);
|
||||
|
|
|
@ -47,6 +47,17 @@ class MispObject extends AppModel
|
|||
);
|
||||
|
||||
public $validate = array(
|
||||
'uuid' => array(
|
||||
'uuid' => array(
|
||||
'rule' => array('custom', '/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/'),
|
||||
'message' => 'Please provide a valid UUID'
|
||||
),
|
||||
'unique' => array(
|
||||
'rule' => 'isUnique',
|
||||
'message' => 'The UUID provided is not unique',
|
||||
'required' => 'create'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
|
|
Loading…
Reference in New Issue