diff --git a/app/Controller/AttributesController.php b/app/Controller/AttributesController.php index 2297ef7af..bd4124fb7 100644 --- a/app/Controller/AttributesController.php +++ b/app/Controller/AttributesController.php @@ -790,7 +790,7 @@ class AttributesController extends AppController } } if ($existingAttribute['Attribute']['object_id']) { - $result = $this->Attribute->save($this->request->data, array('fieldList' => $this->Attribute->editableFields)); + $result = $this->Attribute->save($this->request->data, array('fieldList' => Attribute::EDITABLE_FIELDS)); if ($result) { $this->Attribute->AttributeTag->handleAttributeTags($this->Auth->user(), $this->request->data['Attribute'], $attribute['Event']['id'], $capture=true); } diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index ff98aa37f..8e6a8ca68 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -46,7 +46,21 @@ class Attribute extends AppModel 'distribution' => array('desc' => 'Describes who will have access to the attribute.') ); - public $editableFields = array('timestamp', 'category', 'value', 'value1', 'value2', 'to_ids', 'comment', 'distribution', 'sharing_group_id', 'deleted', 'disable_correlation', 'first_seen', 'last_seen'); + const EDITABLE_FIELDS = [ + 'timestamp', + 'category', + 'value', + 'value1', + 'value2', + 'to_ids', + 'comment', + 'distribution', + 'sharing_group_id', + 'deleted', + 'disable_correlation', + 'first_seen', + 'last_seen', + ]; public $distributionDescriptions = array( 0 => array('desc' => 'This field determines the current distribution of the event', 'formdesc' => "This setting will only allow members of your organisation on this server to see it."), @@ -3786,7 +3800,7 @@ class Attribute extends AppModel $attribute['distribution'] = 5; } } - $fieldList = $this->editableFields; + $fieldList = self::EDITABLE_FIELDS; if (empty($existingAttribute)) { $addableFieldList = array('event_id', 'type', 'uuid'); $fieldList = array_merge($fieldList, $addableFieldList); diff --git a/app/Model/MispObject.php b/app/Model/MispObject.php index 6f0dd3be7..78346455f 100644 --- a/app/Model/MispObject.php +++ b/app/Model/MispObject.php @@ -884,7 +884,7 @@ class MispObject extends AppModel $newAttribute['event_id'] = $object['Object']['event_id']; $newAttribute['object_id'] = $object['Object']['id']; $newAttribute['timestamp'] = $date->getTimestamp(); - $result = $this->Event->Attribute->save(array('Attribute' => $newAttribute), array('fieldList' => $this->Attribute->editableFields)); + $result = $this->Event->Attribute->save(array('Attribute' => $newAttribute), array('fieldList' => Attribute::EDITABLE_FIELDS)); if ($result) { $this->Event->Attribute->AttributeTag->handleAttributeTags($user, $newAttribute, $newAttribute['event_id'], $capture=true); } @@ -926,7 +926,7 @@ class MispObject extends AppModel } foreach ($object['Attribute'] as $origKey => $originalAttribute) { $originalAttribute['deleted'] = 1; - $this->Event->Attribute->save($originalAttribute, array('fieldList' => $this->Attribute->editableFields)); + $this->Event->Attribute->save($originalAttribute, array('fieldList' => Attribute::EDITABLE_FIELDS)); } } } else { // we only add the new attribute