diff --git a/app/Controller/AttributesController.php b/app/Controller/AttributesController.php index 10b5acb89..e5627bead 100644 --- a/app/Controller/AttributesController.php +++ b/app/Controller/AttributesController.php @@ -295,7 +295,7 @@ class AttributesController extends AppController { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $this->loadModel('Server'); - $attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $this->Server->getDefaultAttachments_dir(); } $path = $attachments_dir . DS . $attribute['event_id'] . DS; $file = $attribute['id']; @@ -2820,7 +2820,7 @@ class AttributesController extends AppController { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $this->loadModel('Server'); - $attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $this->Server->getDefaultAttachments_dir(); } foreach ($attributes as $attribute) { $path = $attachments_dir . DS . $attribute['Attribute']['event_id'] . DS; diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index a26287d40..523fa7106 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -2175,7 +2175,7 @@ class EventsController extends AppController { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $this->loadModel('Server'); - $attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $this->Server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . "GFI" . DS . $id . DS; App::uses('Folder', 'Utility'); @@ -2220,7 +2220,7 @@ class EventsController extends AppController { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $this->loadModel('Server'); - $attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $this->Server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . $id . DS; App::uses('Folder', 'Utility'); @@ -2390,7 +2390,7 @@ class EventsController extends AppController { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $this->loadModel('Server'); - $attachments_dir = $this->Server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $this->Server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . $id . DS; $malware = $rootDir . DS . 'sample'; diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index c3530b72a..3960b4f46 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -576,7 +576,7 @@ class Attribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . $this->data['Attribute']['event_id'] . DS . $this->data['Attribute']['id']; $file = new File($filepath); @@ -1256,7 +1256,7 @@ class Attribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . $attribute['event_id'] . DS . $attribute['id']; $file = new File($filepath); @@ -1271,7 +1271,7 @@ class Attribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . $attribute['event_id']; $dir = new Folder($rootDir, true); // create directory structure @@ -1321,7 +1321,7 @@ class Attribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . $eventId; $dir = new Folder($rootDir, true); @@ -2309,7 +2309,7 @@ class Attribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } if ($proposal) { $dir = new Folder($attachments_dir . DS . $event_id . DS . 'shadow', true); diff --git a/app/Model/Event.php b/app/Model/Event.php index ad831c88c..25e69f615 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -337,7 +337,7 @@ class Event extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . $this->id; App::uses('Folder', 'Utility'); diff --git a/app/Model/Server.php b/app/Model/Server.php index ddf4f54af..e2f367376 100644 --- a/app/Model/Server.php +++ b/app/Model/Server.php @@ -351,7 +351,7 @@ class Server extends AppModel { 'attachments_dir' => array( 'level' => 2, 'description' => 'Directory where attachments are stored. MISP will NOT migrate the existing data if you change this setting. The only safe way to change this setting is in config.php, when MISP is not running, and after having moved/copied the existing data to the new location. This directory must already exist and be writable and readable by the MISP application.', - 'value' => APP . 'files', + 'value' => 'app/files', # GUI display purpose only. Default value defined in func getDefaultAttachments_dir() 'errorMessage' => '', 'null' => false, 'test' => 'testForWritableDir', @@ -3538,4 +3538,8 @@ class Server extends AppModel { $final .= implode("\n", $output); return $final; } + + public function getDefaultAttachments_dir() { + return APP . 'files'; + } } diff --git a/app/Model/ShadowAttribute.php b/app/Model/ShadowAttribute.php index b3928f533..9e88edbc4 100644 --- a/app/Model/ShadowAttribute.php +++ b/app/Model/ShadowAttribute.php @@ -232,7 +232,7 @@ class ShadowAttribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . 'shadow' . DS . $sa['ShadowAttribute']['event_id'] . DS . $sa['ShadowAttribute']['id']; $file = new File($filepath); @@ -264,7 +264,7 @@ class ShadowAttribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . 'shadow' . DS . $this->data['ShadowAttribute']['event_id'] . DS . $this->data['ShadowAttribute']['id']; $file = new File($filepath); @@ -362,7 +362,7 @@ class ShadowAttribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $filepath = $attachments_dir . DS . 'shadow' . DS . $attribute['event_id'] . DS. $attribute['id']; $file = new File($filepath); @@ -377,7 +377,7 @@ class ShadowAttribute extends AppModel { $attachments_dir = Configure::read('MISP.attachments_dir'); if (empty($attachments_dir)) { $my_server = ClassRegistry::init('Server'); - $attachments_dir = $my_server->serverSettings['MISP']['attachments_dir']['value']; + $attachments_dir = $my_server->getDefaultAttachments_dir(); } $rootDir = $attachments_dir . DS . 'shadow' . DS . $attribute['event_id']; $dir = new Folder($rootDir, true); // create directory structure