mirror of https://github.com/MISP/MISP
chg: [UI] Validate object when revising
parent
a8dcd9aec4
commit
46ea861576
|
@ -87,6 +87,15 @@ class ObjectsController extends AppController
|
|||
$similar_object_similarity_amount[$obj['Attribute']['object_id']] = $obj[0]['similarity_amount'];
|
||||
}
|
||||
|
||||
if (isset($this->request->data['Attribute'])) {
|
||||
foreach ($this->request->data['Attribute'] as &$attribute) {
|
||||
$validation = $this->MispObject->Attribute->validateAttribute($attribute);
|
||||
if ($validation !== true) {
|
||||
$attribute['validation'] = $validation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->set('distributionLevels', $this->MispObject->Attribute->distributionLevels);
|
||||
$this->set('action', $action);
|
||||
$this->set('template', $template);
|
||||
|
|
|
@ -7,6 +7,7 @@ App::uses('FinancialTool', 'Tools');
|
|||
App::uses('RandomTool', 'Tools');
|
||||
App::uses('AttachmentTool', 'Tools');
|
||||
App::uses('TmpFileTool', 'Tools');
|
||||
App::uses('ComplexTypeTool', 'Tools');
|
||||
|
||||
/**
|
||||
* @property Event $Event
|
||||
|
@ -3128,7 +3129,6 @@ class Attribute extends AppModel
|
|||
'value' => $value,
|
||||
);
|
||||
if ($element['complex']) {
|
||||
App::uses('ComplexTypeTool', 'Tools');
|
||||
$complexTypeTool = new ComplexTypeTool();
|
||||
$result = $complexTypeTool->checkComplexRouter($value, ucfirst($element['type']));
|
||||
if (isset($result['multi'])) {
|
||||
|
@ -3693,7 +3693,12 @@ class Attribute extends AppModel
|
|||
return $validTypes;
|
||||
}
|
||||
|
||||
public function validateAttribute($attribute, $context = true)
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param bool $context
|
||||
* @return array|true
|
||||
*/
|
||||
public function validateAttribute(array $attribute, $context = true)
|
||||
{
|
||||
$this->set($attribute);
|
||||
if (!$context) {
|
||||
|
|
|
@ -88,21 +88,26 @@
|
|||
$simple_flattened_attribute_noval[$cur_flat_noval] = $id;
|
||||
echo sprintf('<tr data-curflat="%s" data-curflatnoval="%s">', h($cur_flat), h($cur_flat_noval));
|
||||
echo '<td>' . h($attribute['object_relation']) . '</td>';
|
||||
foreach ($attributeFields as $field):
|
||||
if ($field == 'distribution') {
|
||||
if ($attribute['distribution'] != 4) {
|
||||
$attribute[$field] = $distributionLevels[$attribute['distribution']];
|
||||
} else {
|
||||
$attribute[$field] = $sharing_groups[$attribute['sharing_group_id']];
|
||||
foreach ($attributeFields as $field) {
|
||||
if ($field === 'distribution') {
|
||||
if ($attribute['distribution'] != 4) {
|
||||
$attribute[$field] = $distributionLevels[$attribute['distribution']];
|
||||
} else {
|
||||
$attribute[$field] = $sharing_groups[$attribute['sharing_group_id']];
|
||||
}
|
||||
} else if ($field === 'to_ids') {
|
||||
$attribute[$field] = $attribute[$field] ? __('Yes') : __('No');
|
||||
}
|
||||
}
|
||||
if ($field == 'to_ids') $attribute[$field] = $attribute[$field] ? __('Yes') : __('No');
|
||||
if (isset($attribute[$field])):
|
||||
echo '<td>'.h($attribute[$field]). '</td>';
|
||||
else:
|
||||
echo '<td></td>';
|
||||
endif;
|
||||
endforeach;
|
||||
if (isset($attribute[$field])) {
|
||||
if (isset($attribute['validation'][$field])) {
|
||||
echo '<td>' . h($attribute[$field]) . ' <i class="fas fa-times red" title="' . h(implode(', ', $attribute['validation'][$field])) . '"></i></td>';
|
||||
} else {
|
||||
echo '<td>' . h($attribute[$field]) . '</td>';
|
||||
}
|
||||
} else {
|
||||
echo '<td></td>';
|
||||
}
|
||||
}
|
||||
echo '</tr>';
|
||||
endforeach;
|
||||
endif;
|
||||
|
|
Loading…
Reference in New Issue