mirror of https://github.com/MISP/MISP
chg: [internal] Move UUID generation to beforeSave method
parent
f99f82fa34
commit
8a0532d902
|
@ -362,6 +362,9 @@ class Attribute extends AppModel
|
|||
|
||||
public function beforeSave($options = array())
|
||||
{
|
||||
if (empty($this->data['Attribute']['uuid'])) {
|
||||
$this->data['Attribute']['uuid'] = CakeText::uuid();
|
||||
}
|
||||
if (!empty($this->data['Attribute']['id'])) {
|
||||
$this->old = $this->find('first', array(
|
||||
'recursive' => -1,
|
||||
|
@ -603,10 +606,7 @@ class Attribute extends AppModel
|
|||
if (empty($attribute['comment'])) {
|
||||
$attribute['comment'] = "";
|
||||
}
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($attribute['uuid'])) {
|
||||
$attribute['uuid'] = CakeText::uuid();
|
||||
} else {
|
||||
if (!empty($attribute['uuid'])) {
|
||||
$attribute['uuid'] = strtolower($attribute['uuid']);
|
||||
}
|
||||
// generate timestamp if it doesn't exist
|
||||
|
@ -628,6 +628,9 @@ class Attribute extends AppModel
|
|||
if (!isset($attribute['distribution'])) {
|
||||
$attribute['distribution'] = $this->defaultDistribution();
|
||||
}
|
||||
if ($attribute['distribution'] != 4) {
|
||||
$attribute['sharing_group_id'] = 0;
|
||||
}
|
||||
// If category is not provided, assign default category by type
|
||||
if (empty($attribute['category'])) {
|
||||
$attribute['category'] = $this->typeDefinitions[$type]['default_category'];
|
||||
|
@ -636,10 +639,6 @@ class Attribute extends AppModel
|
|||
if (!isset($attribute['to_ids'])) {
|
||||
$attribute['to_ids'] = $this->typeDefinitions[$type]['to_ids'];
|
||||
}
|
||||
|
||||
if ($attribute['distribution'] != 4) {
|
||||
$attribute['sharing_group_id'] = 0;
|
||||
}
|
||||
// return true, otherwise the object cannot be saved
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,6 @@ class Event extends AppModel
|
|||
//'required' => true,
|
||||
//'allowEmpty' => true
|
||||
),
|
||||
|
||||
'analysis' => array(
|
||||
'rule' => array('inList', array('0', '1', '2')),
|
||||
'message' => 'Options : 0, 1, 2 (for Initial, Ongoing, Completed)',
|
||||
|
@ -465,9 +464,7 @@ class Event extends AppModel
|
|||
}
|
||||
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($event['uuid'])) {
|
||||
$event['uuid'] = CakeText::uuid();
|
||||
} else {
|
||||
if (!empty($event['uuid'])) {
|
||||
$event['uuid'] = strtolower($event['uuid']);
|
||||
}
|
||||
|
||||
|
@ -508,6 +505,15 @@ class Event extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
public function beforeSave($options = [])
|
||||
{
|
||||
// generate UUID if not provided
|
||||
if (empty($this->data['Event']['uuid'])) {
|
||||
$this->data['Event']['uuid'] = CakeText::uuid();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function afterSave($created, $options = array())
|
||||
{
|
||||
if (!Configure::read('MISP.completely_disable_correlation') && !$created) {
|
||||
|
|
|
@ -69,7 +69,6 @@ class MispObject extends AppModel
|
|||
'unique' => array(
|
||||
'rule' => 'isUnique',
|
||||
'message' => 'The UUID provided is not unique',
|
||||
'required' => true,
|
||||
'on' => 'create'
|
||||
),
|
||||
),
|
||||
|
@ -249,7 +248,12 @@ class MispObject extends AppModel
|
|||
return $results;
|
||||
}
|
||||
|
||||
public function beforeSave($options = array()) {
|
||||
public function beforeSave($options = array())
|
||||
{
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($this->data['Object']['uuid'])) {
|
||||
$this->data['Object']['uuid'] = CakeText::uuid();
|
||||
}
|
||||
$this->data = $this->Attribute->ISODatetimeToUTC($this->data, $this->alias);
|
||||
}
|
||||
|
||||
|
@ -259,10 +263,6 @@ class MispObject extends AppModel
|
|||
if (empty($object['comment'])) {
|
||||
$object['comment'] = "";
|
||||
}
|
||||
// generate UUID if it doesn't exist
|
||||
if (empty($object['uuid'])) {
|
||||
$object['uuid'] = CakeText::uuid();
|
||||
}
|
||||
// generate timestamp if it doesn't exist
|
||||
if (empty($object['timestamp'])) {
|
||||
$object['timestamp'] = time();
|
||||
|
|
Loading…
Reference in New Issue