From 0ee45af90235c2a4ac4b34d8f35639ff1bd24932 Mon Sep 17 00:00:00 2001 From: iglocska Date: Tue, 6 Aug 2013 11:53:12 +0200 Subject: [PATCH] Default distribution level flags in bootstrap.php - Each instance can now have its own default event and attribute distribution level set --- app/Config/bootstrap.default.php | 2 ++ app/Controller/AttributesController.php | 3 +++ app/Controller/EventsController.php | 5 ++++- app/View/Attributes/add.ctp | 6 +++++- app/View/Attributes/add_attachment.ctp | 6 +++++- app/View/Events/add.ctp | 6 +++++- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/Config/bootstrap.default.php b/app/Config/bootstrap.default.php index 167ce9a8b..2dc616321 100755 --- a/app/Config/bootstrap.default.php +++ b/app/Config/bootstrap.default.php @@ -142,6 +142,8 @@ Configure::write('CyDefSIG.dns', 'false'); // there is a nameserver available //Configure::write('MISP.welcome_text_bottom', 'instance'); // used in Events::login after the MISP logo //Configure::write('MISP.welcome_logo', 'organisation'); // used in Events::login to the left of the MISP logo, place a .png file in app/webroot/img with the name specified here. In this case it would be organisation.png Configure::write('MISP.disablerestalert', 'false'); +Configure::write('MISP.default_event_distribution', 3); +Configure::write('MISP.default_attribute_distribution', 3); /** * The settings below can be used to set additional paths to models, views and controllers. diff --git a/app/Controller/AttributesController.php b/app/Controller/AttributesController.php index be93adb47..f909a5b12 100755 --- a/app/Controller/AttributesController.php +++ b/app/Controller/AttributesController.php @@ -495,6 +495,9 @@ class AttributesController extends AppController { $attribute['value'] = $entry['Value']; $attribute['to_ids'] = ($entry['Confidence'] > 51) ? 1 : 0; // To IDS if high confidence $attribute['distribution'] = 3; // 'All communities' + if (Configure::read('MISP.default_attribute_distribution') != null) { + $attribute['distribution'] = Configure::read('MISP.default_attribute_distribution'); + } switch($entry['Type']) { case 'Address': $attribute['category'] = 'Network activity'; diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index c72b07a16..f6d4907d2 100755 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -1835,7 +1835,10 @@ class EventsController extends AppController { $this->Event->read(null, $id); $saveEvent['Event'] = $this->Event->data['Event']; $saveEvent['Event']['published'] = false; - $dist = $this->Event->data['Event']['distribution']; + $dist = 3; + if (Configure::read('MISP.default_attribute_distribution') != null) { + $dist = Configure::read('MISP.default_attribute_distribution'); + } // read XML $event = $this->IOCImport->readXML($fileData, $id, $dist); diff --git a/app/View/Attributes/add.ctp b/app/View/Attributes/add.ctp index 41a5883b8..48b060484 100755 --- a/app/View/Attributes/add.ctp +++ b/app/View/Attributes/add.ctp @@ -11,10 +11,14 @@ 'empty' => '(first choose category)' )); if ('true' == Configure::read('CyDefSIG.sync')) { + $initialDistribution = 3; + if (Configure::read('MISP.default_attribute_distribution') != null) { + $initialDistribution = Configure::read('MISP.default_attribute_distribution'); + } echo $this->Form->input('distribution', array( 'options' => array($distributionLevels), 'label' => 'Distribution', - 'selected' => $currentDist, + 'selected' => $initialDistribution, )); } echo $this->Form->input('value', array( diff --git a/app/View/Attributes/add_attachment.ctp b/app/View/Attributes/add_attachment.ctp index e16f41275..7fd88c6f9 100755 --- a/app/View/Attributes/add_attachment.ctp +++ b/app/View/Attributes/add_attachment.ctp @@ -8,10 +8,14 @@ 'after' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv')), )); if ('true' == Configure::read('CyDefSIG.sync')) { + $initialDistribution = 3; + if (Configure::read('MISP.default_attribute_distribution') != null) { + $initialDistribution = Configure::read('MISP.default_attribute_distribution'); + } echo $this->Form->input('distribution', array( 'options' => $distributionLevels, 'label' => 'Distribution', - 'selected' => $currentDist, + 'selected' => $initialDistribution, 'after' => $this->Html->div('forminfo', '', array('id' => 'AttributeDistributionDiv')), )); //'before' => $this->Html->div('forminfo', isset($attrDescriptions['distribution']['formdesc']) ? $attrDescriptions['distribution']['formdesc'] : $attrDescriptions['distribution']['desc']),)); diff --git a/app/View/Events/add.ctp b/app/View/Events/add.ctp index 6666b9121..4ed824535 100755 --- a/app/View/Events/add.ctp +++ b/app/View/Events/add.ctp @@ -7,11 +7,15 @@ 'type' => 'text', 'class' => 'datepicker' )); + $initialDistribution = 3; + if (Configure::read('MISP.default_event_distribution') != null) { + $initialDistribution = Configure::read('MISP.default_event_distribution'); + } if ('true' == Configure::read('CyDefSIG.sync')) { echo $this->Form->input('distribution', array( 'options' => array($distributionLevels), 'label' => 'Distribution', - 'selected' => '3', + 'selected' => $initialDistribution, )); } echo $this->Form->input('risk', array(