mirror of https://github.com/MISP/MISP
chg: Rename two fields in the object references
- source_uuid => object_uuid - destination_uuid => referenced_uuidpull/2489/head
parent
b442a273fc
commit
03881e40c1
|
@ -465,7 +465,7 @@ CREATE TABLE IF NOT EXISTS object_references (
|
|||
`object_id` int(11) NOT NULL,
|
||||
`event_id` int(11) NOT NULL,
|
||||
`source_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`destination_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`referenced_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`referenced_id` int(11) NOT NULL,
|
||||
`referenced_type` int(11) NOT NULL DEFAULT 0,
|
||||
`relationship_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
|
||||
|
@ -473,7 +473,7 @@ CREATE TABLE IF NOT EXISTS object_references (
|
|||
`deleted` TINYINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
INDEX `source_uuid` (`source_uuid`),
|
||||
INDEX `destination_uuid` (`destination_uuid`),
|
||||
INDEX `referenced_uuid` (`referenced_uuid`),
|
||||
INDEX `timestamp` (`timestamp`),
|
||||
INDEX `object_id` (`object_id`),
|
||||
INDEX `referenced_id` (`referenced_id`),
|
||||
|
|
|
@ -54,7 +54,7 @@ class ObjectReferencesController extends AppController {
|
|||
));
|
||||
if (!empty($target_object)) {
|
||||
$referenced_id = $target_object['Object']['id'];
|
||||
$destination_uuid = $target_object['Object']['uuid'];
|
||||
$referenced_uuid = $target_object['Object']['uuid'];
|
||||
if ($target_object['Object']['event_id'] != $object['Event']['id']) {
|
||||
throw new NotFoundException('Invalid target. Target has to be within the same event.');
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class ObjectReferencesController extends AppController {
|
|||
throw new NotFoundException('Invalid target. Target has to be within the same event.');
|
||||
}
|
||||
$referenced_id = $target_attribute['Attribute']['id'];
|
||||
$destination_uuid = $target_attribute['Attribute']['uuid'];
|
||||
$referenced_uuid = $target_attribute['Attribute']['uuid'];
|
||||
$referenced_type = 0;
|
||||
}
|
||||
$relationship_type = empty($this->request->data['ObjectReference']['relationship_type']) ? '' : $this->request->data['ObjectReference']['relationship_type'];
|
||||
|
@ -81,11 +81,11 @@ class ObjectReferencesController extends AppController {
|
|||
$data = array(
|
||||
'referenced_type' => $referenced_type,
|
||||
'referenced_id' => $referenced_id,
|
||||
'destination_uuid' => $destination_uuid,
|
||||
'referenced_uuid' => $referenced_uuid,
|
||||
'relationship_type' => $relationship_type,
|
||||
'comment' => !empty($this->request->data['ObjectReference']['comment']) ? $this->request->data['ObjectReference']['comment'] : '',
|
||||
'event_id' => $object['Event']['id'],
|
||||
'source_uuid' => $object['Object']['uuid'],
|
||||
'object_uuid' => $object['Object']['uuid'],
|
||||
'object_id' => $objectId,
|
||||
'referenced_type' => $referenced_type,
|
||||
'uuid' => CakeText::uuid()
|
||||
|
|
|
@ -741,16 +741,16 @@ class AppModel extends Model {
|
|||
`timestamp` int(11) NOT NULL DEFAULT 0,
|
||||
`object_id` int(11) NOT NULL,
|
||||
`event_id` int(11) NOT NULL,
|
||||
`source_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`destination_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`object_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`referenced_uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL,
|
||||
`referenced_id` int(11) NOT NULL,
|
||||
`referenced_type` int(11) NOT NULL DEFAULT 0,
|
||||
`relationship_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
|
||||
`comment` text COLLATE utf8_bin NOT NULL,
|
||||
`deleted` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
INDEX `source_uuid` (`source_uuid`),
|
||||
INDEX `destination_uuid` (`destination_uuid`),
|
||||
INDEX `object_uuid` (`object_uuid`),
|
||||
INDEX `referenced_uuid` (`referenced_uuid`),
|
||||
INDEX `timestamp` (`timestamp`),
|
||||
INDEX `object_id` (`object_id`),
|
||||
INDEX `referenced_id` (`referenced_id`),
|
||||
|
|
|
@ -158,8 +158,8 @@ class ObjectReference extends AppModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (isset($reference['source_uuid'])) {
|
||||
$conditions = array('Object.uuid' => $reference['source_uuid']);
|
||||
if (isset($reference['object_uuid'])) {
|
||||
$conditions = array('Object.uuid' => $reference['object_uuid']);
|
||||
} else if (isset($reference['object_id'])) {
|
||||
$conditions = array('Object.id' => $reference['object_id']);
|
||||
} else {
|
||||
|
@ -169,9 +169,9 @@ class ObjectReference extends AppModel {
|
|||
'recursive' => -1,
|
||||
'conditions' => $conditions
|
||||
));
|
||||
if (isset($reference['destination_uuid'])) {
|
||||
$conditions[0] = array('Attribute.uuid' => $reference['destination_uuid']);
|
||||
$conditions[1] = array('Object.uuid' => $reference['destination_uuid']);
|
||||
if (isset($reference['referenced_uuid'])) {
|
||||
$conditions[0] = array('Attribute.uuid' => $reference['referenced_uuid']);
|
||||
$conditions[1] = array('Object.uuid' => $reference['referenced_uuid']);
|
||||
} else if (isset($reference['object_id'])) {
|
||||
if ($reference['referenced_type'] == 1) {
|
||||
$conditions[0] = array('Attribute.id' => $reference['referenced_id']);
|
||||
|
@ -206,8 +206,8 @@ class ObjectReference extends AppModel {
|
|||
$reference['referenced_type'] = $referenced_type;
|
||||
$reference['object_id'] = $sourceObject['Object']['id'];
|
||||
$reference['referenced_id'] = $destinationObject[$objectTypes[$referenced_type]]['id'];
|
||||
$reference['destination_uuid'] = $destinationObject[$objectTypes[$referenced_type]]['uuid'];
|
||||
$reference['source_uuid'] = $sourceObject['Object']['uuid'];
|
||||
$reference['referenced_uuid'] = $destinationObject[$objectTypes[$referenced_type]]['uuid'];
|
||||
$reference['object_uuid'] = $sourceObject['Object']['uuid'];
|
||||
$reference['event_id'] = $eventId;
|
||||
$this->save(array('ObjectReference' => $reference));
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue