chg: [clusterRelations:add] Force no galaxy matrix when picking clusters

pull/6120/head
mokaddem 2020-07-15 15:35:27 +02:00
parent 64c8ccfeec
commit b9b08ae17e
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 12 additions and 10 deletions

View File

@ -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
);
}

View File

@ -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);