mirror of https://github.com/MISP/MISP
chg: [tag:exclusive] Added support of local while checking for
exclusivitypull/5378/head
parent
1aaa590e30
commit
0222b8c090
|
@ -1160,7 +1160,13 @@ class EventsController extends AppController
|
|||
unset($event['Object'][$k]['Attribute'][$k2]['AttributeTag'][$k3]);
|
||||
}
|
||||
}
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies(Hash::extract($attribute['AttributeTag'], '{n}.Tag.name'));
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']);
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
$event['Object'][$k]['Attribute'][$k2]['tagConflicts'] = $tagConflicts;
|
||||
}
|
||||
}
|
||||
|
@ -1171,7 +1177,13 @@ class EventsController extends AppController
|
|||
unset($event['Attribute'][$k]['AttributeTag'][$k2]);
|
||||
}
|
||||
}
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies(Hash::extract($attribute['AttributeTag'], '{n}.Tag.name'));
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']);
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
$event['Attribute'][$k]['tagConflicts'] = $tagConflicts;
|
||||
}
|
||||
if (empty($this->passedArgs['sort'])) {
|
||||
|
@ -1372,8 +1384,11 @@ class EventsController extends AppController
|
|||
}
|
||||
}
|
||||
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies(Hash::extract($event['EventTag'], '{n}.Tag.name'));
|
||||
foreach ($tagConflicts as $tagConflict) {
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($event['EventTag']);
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
$this->set('tagConflicts', $tagConflicts);
|
||||
|
@ -1394,8 +1409,11 @@ class EventsController extends AppController
|
|||
unset($event['Attribute'][$k]['AttributeTag'][$k2]);
|
||||
}
|
||||
}
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies(Hash::extract($attribute['AttributeTag'], '{n}.Tag.name'));
|
||||
foreach ($tagConflicts as $tagConflict) {
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']);
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
$event['Attribute'][$k]['tagConflicts'] = $tagConflicts;
|
||||
|
@ -1424,8 +1442,11 @@ class EventsController extends AppController
|
|||
unset($event['Object'][$k]['Attribute'][$k2]['AttributeTag'][$k3]);
|
||||
}
|
||||
}
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies(Hash::extract($attribute['AttributeTag'], '{n}.Tag.name'));
|
||||
foreach ($tagConflicts as $tagConflict) {
|
||||
$tagConflicts = $this->Taxonomy->checkIfTagInconsistencies($attribute['AttributeTag']);
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$warningTagConflict[$tagConflict['taxonomy']['Taxonomy']['namespace']] = $tagConflict['taxonomy'];
|
||||
}
|
||||
$event['Object'][$k]['Attribute'][$k2]['tagConflicts'] = $tagConflicts;
|
||||
|
@ -3857,15 +3878,15 @@ class EventsController extends AppController
|
|||
}
|
||||
$tagsOnEvent = $this->Event->EventTag->find('all', array(
|
||||
'conditions' => array(
|
||||
'Tag.id' => $tag_id,
|
||||
'EventTag.event_id' => $id
|
||||
'EventTag.event_id' => $id,
|
||||
'EventTag.local' => $local
|
||||
),
|
||||
'contain' => 'Tag',
|
||||
'fields' => array('Tag.name'),
|
||||
'recursive' => -1
|
||||
));
|
||||
$exclusive_test_passed = $this->Taxonomy->checkIfNewTagIsAllowedByTaxonomy($tag['Tag']['name'], $tagsOnEvent);
|
||||
if (!empty($exclusive_test_passed)) {
|
||||
$exclusive_test_passed = $this->Taxonomy->checkIfNewTagIsAllowedByTaxonomy($tag['Tag']['name'], Hash::extract($tagsOnEvent, '{n}.Tag.name'));
|
||||
if (!$exclusive_test_passed) {
|
||||
$fail = __('Tag is not allowed due to taxonomy exclusivity settings');
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -573,7 +573,26 @@ class Taxonomy extends AppModel
|
|||
return true;
|
||||
}
|
||||
|
||||
public function checkIfTagInconsistencies($tagNameList)
|
||||
public function checkIfTagInconsistencies($tagList)
|
||||
{
|
||||
$eventTags = array();
|
||||
$localEventTags = array();
|
||||
foreach($tagList as $tag) {
|
||||
if ($tag['local'] == 0) {
|
||||
$eventTags[] = $tag['Tag']['name'];
|
||||
} else {
|
||||
$localEventTags[] = $tag['Tag']['name'];
|
||||
}
|
||||
}
|
||||
$tagConflicts = $this->getTagConflicts($eventTags);
|
||||
$localTagConflicts = $this->getTagConflicts($localEventTags);
|
||||
return array(
|
||||
'global' => $tagConflicts,
|
||||
'local' => $localTagConflicts
|
||||
);
|
||||
}
|
||||
|
||||
public function getTagConflicts($tagNameList)
|
||||
{
|
||||
$potentiallyConflictingTaxonomy = array();
|
||||
$conflictingTaxonomy = array();
|
||||
|
|
|
@ -163,9 +163,11 @@
|
|||
$tagData
|
||||
);
|
||||
$tagConflictData = '';
|
||||
if (!empty($tagConflicts)) {
|
||||
if (!empty($tagConflicts['global'])) {
|
||||
$tagConflictData .= '<div><div class="alert alert-error tag-conflict-notice">';
|
||||
foreach ($tagConflicts as $tagConflict) {
|
||||
$tagConflictData .= '<i class="fas fa-globe-americas icon"></i>';
|
||||
$tagConflictData .= '<div class="text-container">';
|
||||
foreach ($tagConflicts['global'] as $tagConflict) {
|
||||
$tagConflictData .= sprintf(
|
||||
'<strong>%s</strong></br>',
|
||||
h($tagConflict['conflict'])
|
||||
|
@ -174,7 +176,22 @@
|
|||
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span></br>', h($tag));
|
||||
}
|
||||
}
|
||||
$tagConflictData .= '</div></span>';
|
||||
$tagConflictData .= '</div></div></span>';
|
||||
}
|
||||
if (!empty($tagConflicts['local'])) {
|
||||
$tagConflictData .= '<div><div class="alert alert-error tag-conflict-notice">';
|
||||
$tagConflictData .= '<i class="fas fa-user icon"></i>';
|
||||
$tagConflictData .= '<div class="text-container">';
|
||||
foreach ($tagConflicts['local'] as $tagConflict) {
|
||||
$tagConflictData .= sprintf(
|
||||
'<strong>%s</strong></br>',
|
||||
h($tagConflict['conflict'])
|
||||
);
|
||||
foreach ($tagConflict['tags'] as $tag) {
|
||||
$tagConflictData .= sprintf('<span class="apply_css_arrow nowrap">%s</span></br>', h($tag));
|
||||
}
|
||||
}
|
||||
$tagConflictData .= '</div></div></span>';
|
||||
}
|
||||
echo $tagConflictData;
|
||||
?>
|
||||
|
|
|
@ -2397,6 +2397,12 @@ table tr:hover .down-expand-button {
|
|||
|
||||
.tag-conflict-notice {
|
||||
margin: 5px 0px;
|
||||
padding-right: 14px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tag-conflict-notice div.text-container {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.attributeTagContainer .tag-conflict-notice {
|
||||
|
@ -2407,4 +2413,14 @@ table tr:hover .down-expand-button {
|
|||
.tag-conflict-notice .apply_css_arrow {
|
||||
display: inline-block;
|
||||
padding: 0px 6px;
|
||||
}
|
||||
|
||||
.tag-conflict-notice i.icon {
|
||||
position: absolute;
|
||||
padding: 3px;
|
||||
right: 0px;
|
||||
top: 0px;
|
||||
background-color: #3b3b3b;
|
||||
color: white;
|
||||
border-radius: 3px;
|
||||
}
|
Loading…
Reference in New Issue