From b9b08ae17e188c7558380ac447c795a495f218a9 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Wed, 15 Jul 2020 15:35:27 +0200 Subject: [PATCH] chg: [clusterRelations:add] Force no galaxy matrix when picking clusters --- app/Controller/GalaxiesController.php | 10 +++++----- app/View/GalaxyClusterRelations/add.ctp | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php index b97e65a68..b0f3ab9f5 100644 --- a/app/Controller/GalaxiesController.php +++ b/app/Controller/GalaxiesController.php @@ -266,7 +266,7 @@ class GalaxiesController extends AppController } } - public function selectGalaxy($target_id, $target_type='event', $namespace='misp') + public function selectGalaxy($target_id, $target_type='event', $namespace='misp', $noGalaxyMatrix = false) { $mitreAttackGalaxyId = $this->Galaxy->getMitreAttackGalaxyId(); $local = !empty($this->params['named']['local']) ? $this->params['named']['local'] : '0'; @@ -285,7 +285,7 @@ class GalaxiesController extends AppController ) ); foreach ($galaxies as $galaxy) { - if (!isset($galaxy['Galaxy']['kill_chain_order'])) { + if (!isset($galaxy['Galaxy']['kill_chain_order']) || $noGalaxyMatrix) { $items[] = array( 'name' => h($galaxy['Galaxy']['name']), 'value' => "/galaxies/selectCluster/" . $target_id . '/' . $target_type . '/' . $galaxy['Galaxy']['id'] . '/local:' . $local, @@ -319,7 +319,7 @@ class GalaxiesController extends AppController $this->render('/Elements/generic_picker'); } - public function selectGalaxyNamespace($target_id, $target_type='event') + public function selectGalaxyNamespace($target_id, $target_type='event', $noGalaxyMatrix = false) { $namespaces = $this->Galaxy->find('list', array( 'recursive' => -1, @@ -331,12 +331,12 @@ class GalaxiesController extends AppController $items = array(); $items[] = array( 'name' => __('All namespaces'), - 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/0' . '/local:' . $local + 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/0' . '/' . $noGalaxyMatrix . '/local:' . $local ); foreach ($namespaces as $namespace) { $items[] = array( 'name' => $namespace, - 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/' . $namespace . '/local:' . $local + 'value' => "/galaxies/selectGalaxy/" . $target_id . '/' . $target_type . '/' . $namespace . '/' . $noGalaxyMatrix . '/local:' . $local ); } diff --git a/app/View/GalaxyClusterRelations/add.ctp b/app/View/GalaxyClusterRelations/add.ctp index 9887a4a66..b723742b0 100644 --- a/app/View/GalaxyClusterRelations/add.ctp +++ b/app/View/GalaxyClusterRelations/add.ctp @@ -74,14 +74,16 @@ $(this).data('popover-callback-function', setSourceUUIDAfterSelect); var target_id = 0; var target_type = 'galaxyClusterRelation'; - popoverPopup(this, target_id + '/' + target_type, 'galaxies', 'selectGalaxyNamespace'); + var noGalaxyMatrix = 1; + popoverPopup(this, target_id + '/' + target_type + '/' + noGalaxyMatrix, 'galaxies', 'selectGalaxyNamespace'); } function pickerTarget() { $(this).data('popover-no-submit', true); $(this).data('popover-callback-function', setTargetUUIDAfterSelect); var target_id = 0; var target_type = 'galaxyClusterRelation'; - popoverPopup(this, target_id + '/' + target_type, 'galaxies', 'selectGalaxyNamespace'); + var noGalaxyMatrix = 1; + popoverPopup(this, target_id + '/' + target_type + '/' + noGalaxyMatrix, 'galaxies', 'selectGalaxyNamespace'); } function pickerTags() { $(this).data('popover-no-submit', true); @@ -90,15 +92,15 @@ var target_type = 'galaxyClusterRelation'; popoverPopup(this, target_id + '/' + target_type, 'tags', 'selectTaxonomy') } - function setSourceUUIDAfterSelect(selected, additionalData){ + function setSourceUUIDAfterSelect(selected, additionalData) { selectedUUID = additionalData.itemOptions[selected].uuid; $('#GalaxyClusterRelationGalaxyClusterUuid').val(selectedUUID); } - function setTargetUUIDAfterSelect(selected, additionalData){ + function setTargetUUIDAfterSelect(selected, additionalData) { selectedUUID = additionalData.itemOptions[selected].uuid; $('#GalaxyClusterRelationReferencedGalaxyClusterUuid').val(selectedUUID); } - function setTagsAfterSelect(selected, additionalData){ + function setTagsAfterSelect(selected, additionalData) { selectedTags = []; selected.forEach(function(selection) { selectedTags.push(additionalData.itemOptions[selection].tag_name);