From f20478587f9142eeab676eec071c2ff9919c3f04 Mon Sep 17 00:00:00 2001 From: aksha Date: Thu, 26 Jul 2018 19:19:42 +0100 Subject: [PATCH 001/907] Merge: First mactime commit --- app/Controller/EventsController.php | 31 + app/Controller/PagesController.php | 1 + app/Model/AppModel.php | 834 ++++++++++++----------- app/View/Events/upload_analysis_file.ctp | 106 +++ app/composer.json | 2 +- 5 files changed, 559 insertions(+), 415 deletions(-) create mode 100644 app/View/Events/upload_analysis_file.ctp diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index f29780b73..4d5a86a32 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -3979,6 +3979,11 @@ class EventsController extends AppController { 'url' => '/events/upload_stix/2', 'text' => 'STIX 2.0 format (lossy)', 'ajax' => false, + ), + 'Forensic analysis' => array( + 'url' => '/events/upload_analysis_file', + 'text' => 'Forensic analysis upload', + 'ajax' => false, ) ); } @@ -4938,4 +4943,30 @@ class EventsController extends AppController { } return $this->RestResponse->viewData($response, $this->response->type()); } + public function upload_analysis_file() + { + $this->set('file_uploaded',"0"); + if (!$this->userRole['perm_modify']) { + throw new UnauthorizedException('You do not have permission to do that.'); + } + if ($this->request->is('post')) + { + $this->set('file_uploaded',"1"); + // if ($this->_isRest()) { + //print_r($_FILES); + $this->set('file_content',file_get_contents($this->request['data']['Event']['analysis_file']['tmp_name'])); + if(isset($_FILES['data']['name']['event']['analysis_file'])) + { + echo 2; + + } + // $randomFileName = $this->Event->generateRandomFileName(); + // $tmpDir = APP . "files" . DS . "scripts" . DS . "tmp"; + // $tempFile = new File($tmpDir . DS . $randomFileName, true, 0644); + // $tempFile->write($this->request->input()); + // $tempFile->close(); + // $result = $this->Event->upload_stix($this->Auth->user(), $randomFileName, $stix_version); + // } + } + } } diff --git a/app/Controller/PagesController.php b/app/Controller/PagesController.php index 3d44e32ef..e17bd55ea 100644 --- a/app/Controller/PagesController.php +++ b/app/Controller/PagesController.php @@ -28,6 +28,7 @@ class PagesController extends AppController { // displays a view based on the page to display passed as parameters public function display() { + $path = func_get_args(); $count = count($path); diff --git a/app/Model/AppModel.php b/app/Model/AppModel.php index 9ba0d5f57..59446e7fe 100644 --- a/app/Model/AppModel.php +++ b/app/Model/AppModel.php @@ -224,37 +224,37 @@ class AppModel extends Model { INDEX event_id (event_id), INDEX org_id (org_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - break; - case 'makeAttributeUUIDsUnique': - $this->__dropIndex('attributes', 'uuid'); - $sqlArray[] = 'ALTER TABLE `attributes` ADD UNIQUE (uuid);'; - break; - case 'makeEventUUIDsUnique': - $this->__dropIndex('events', 'uuid'); - $sqlArray[] = 'ALTER TABLE `events` ADD UNIQUE (uuid);'; - break; - case 'cleanSessionTable': - $sqlArray[] = 'DELETE FROM cake_sessions WHERE expires < ' . time() . ';'; - $clean = false; - break; - case 'destroyAllSessions': - $sqlArray[] = 'DELETE FROM cake_sessions;'; - $clean = false; - break; - case 'addIPLogging': - $sqlArray[] = 'ALTER TABLE `logs` ADD `ip` varchar(45) COLLATE utf8_bin DEFAULT NULL;'; - break; - case 'addCustomAuth': - $sqlArray[] = "ALTER TABLE `users` ADD `external_auth_required` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'ALTER TABLE `users` ADD `external_auth_key` text COLLATE utf8_bin;'; - break; - case '24betaupdates': - $sqlArray = array(); - $sqlArray[] = "ALTER TABLE `shadow_attributes` ADD `proposal_to_delete` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case 'makeAttributeUUIDsUnique': + $this->__dropIndex('attributes', 'uuid'); + $sqlArray[] = 'ALTER TABLE `attributes` ADD UNIQUE (uuid);'; + break; + case 'makeEventUUIDsUnique': + $this->__dropIndex('events', 'uuid'); + $sqlArray[] = 'ALTER TABLE `events` ADD UNIQUE (uuid);'; + break; + case 'cleanSessionTable': + $sqlArray[] = 'DELETE FROM cake_sessions WHERE expires < ' . time() . ';'; + $clean = false; + break; + case 'destroyAllSessions': + $sqlArray[] = 'DELETE FROM cake_sessions;'; + $clean = false; + break; + case 'addIPLogging': + $sqlArray[] = 'ALTER TABLE `logs` ADD `ip` varchar(45) COLLATE utf8_bin DEFAULT NULL;'; + break; + case 'addCustomAuth': + $sqlArray[] = "ALTER TABLE `users` ADD `external_auth_required` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'ALTER TABLE `users` ADD `external_auth_key` text COLLATE utf8_bin;'; + break; + case '24betaupdates': + $sqlArray = array(); + $sqlArray[] = "ALTER TABLE `shadow_attributes` ADD `proposal_to_delete` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'ALTER TABLE `logs` MODIFY `change` text COLLATE utf8_bin NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `logs` MODIFY `change` text COLLATE utf8_bin NOT NULL;'; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomies` ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomies` ( `id` int(11) NOT NULL AUTO_INCREMENT, `namespace` varchar(255) COLLATE utf8_bin NOT NULL, `description` text COLLATE utf8_bin NOT NULL, @@ -263,7 +263,7 @@ class AppModel extends Model { PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomy_entries` ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomy_entries` ( `id` int(11) NOT NULL AUTO_INCREMENT, `taxonomy_predicate_id` int(11) NOT NULL, `value` text COLLATE utf8_bin NOT NULL, @@ -272,7 +272,7 @@ class AppModel extends Model { KEY `taxonomy_predicate_id` (`taxonomy_predicate_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomy_predicates` ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `taxonomy_predicates` ( `id` int(11) NOT NULL AUTO_INCREMENT, `taxonomy_id` int(11) NOT NULL, `value` text COLLATE utf8_bin NOT NULL, @@ -281,73 +281,79 @@ class AppModel extends Model { KEY `taxonomy_id` (`taxonomy_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $sqlArray[] = 'ALTER TABLE `jobs` ADD `org` text COLLATE utf8_bin NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `jobs` ADD `org` text COLLATE utf8_bin NOT NULL;'; - $sqlArray[] = 'ALTER TABLE `servers` ADD `name` varchar(255) NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `servers` ADD `name` varchar(255) NOT NULL;'; - $sqlArray[] = 'ALTER TABLE `sharing_groups` ADD `sync_user_id` INT( 11 ) NOT NULL DEFAULT \'0\' AFTER `org_id`;'; + $sqlArray[] = 'ALTER TABLE `sharing_groups` ADD `sync_user_id` INT( 11 ) NOT NULL DEFAULT \'0\' AFTER `org_id`;'; - $sqlArray[] = 'ALTER TABLE `users` ADD `disabled` BOOLEAN NOT NULL;'; - $sqlArray[] = 'ALTER TABLE `users` ADD `expiration` datetime DEFAULT NULL;'; + $sqlArray[] = 'ALTER TABLE `users` ADD `disabled` BOOLEAN NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `users` ADD `expiration` datetime DEFAULT NULL;'; - $sqlArray[] = 'UPDATE `roles` SET `perm_template` = 1 WHERE `perm_site_admin` = 1 OR `perm_admin` = 1;'; - $sqlArray[] = 'UPDATE `roles` SET `perm_sharing_group` = 1 WHERE `perm_site_admin` = 1 OR `perm_sync` = 1;'; + $sqlArray[] = 'UPDATE `roles` SET `perm_template` = 1 WHERE `perm_site_admin` = 1 OR `perm_admin` = 1;'; + $sqlArray[] = 'UPDATE `roles` SET `perm_sharing_group` = 1 WHERE `perm_site_admin` = 1 OR `perm_sync` = 1;'; - //create indexes - break; - case 'indexTables': - $fieldsToIndex = array( - 'attributes' => array(array('value1', 'INDEX', '255'), array('value2', 'INDEX', '255'), array('event_id', 'INDEX'), array('sharing_group_id', 'INDEX'), array('uuid', 'INDEX')), - 'correlations' => array(array('org_id', 'INDEX'), array('event_id', 'INDEX'), array('attribute_id', 'INDEX'), array('sharing_group_id', 'INDEX'), array('1_event_id', 'INDEX'), array('1_attribute_id', 'INDEX'), array('a_sharing_group_id', 'INDEX'), array('value', 'FULLTEXT')), - 'events' => array(array('info', 'FULLTEXT'), array('sharing_group_id', 'INDEX'), array('org_id', 'INDEX'), array('orgc_id', 'INDEX'), array('uuid', 'INDEX')), - 'event_tags' => array(array('event_id', 'INDEX'), array('tag_id', 'INDEX')), - 'organisations' => array(array('uuid', 'INDEX'), array('name', 'FULLTEXT')), - 'posts' => array(array('post_id', 'INDEX'), array('thread_id', 'INDEX')), - 'shadow_attributes' => array(array('value1', 'INDEX', '255'), array('value2', 'INDEX', '255'), array('old_id', 'INDEX'), array('event_id', 'INDEX'), array('uuid', 'INDEX'), array('event_org_id', 'INDEX'), array('event_uuid', 'INDEX')), - 'sharing_groups' => array(array('org_id', 'INDEX'), array('sync_user_id', 'INDEX'), array('uuid', 'INDEX'), array('organisation_uuid', 'INDEX')), - 'sharing_group_orgs' => array(array('sharing_group_id', 'INDEX'), array('org_id', 'INDEX')), - 'sharing_group_servers' => array(array('sharing_group_id', 'INDEX'), array('server_id', 'INDEX')), - 'servers' => array(array('org_id', 'INDEX'), array('remote_org_id', 'INDEX')), - 'tags' => array(array('name', 'FULLTEXT')), - 'threads' => array(array('user_id', 'INDEX'), array('event_id', 'INDEX'), array('org_id', 'INDEX'), array('sharing_group_id', 'INDEX')), - 'users' => array(array('org_id', 'INDEX'), array('server_id', 'INDEX'), array('email', 'INDEX')), - ); + //create indexes + break; + case 'indexTables': + $fieldsToIndex = array( + 'attributes' => array(array('value1', 'INDEX', '255'), array('value2', 'INDEX', '255'), array('event_id', 'INDEX'), array('sharing_group_id', 'INDEX'), array('uuid', 'INDEX')), + 'correlations' => array(array('org_id', 'INDEX'), array('event_id', 'INDEX'), array('attribute_id', 'INDEX'), array('sharing_group_id', 'INDEX'), array('1_event_id', 'INDEX'), array('1_attribute_id', 'INDEX'), array('a_sharing_group_id', 'INDEX'), array('value', 'FULLTEXT')), + 'events' => array(array('info', 'FULLTEXT'), array('sharing_group_id', 'INDEX'), array('org_id', 'INDEX'), array('orgc_id', 'INDEX'), array('uuid', 'INDEX')), + 'event_tags' => array(array('event_id', 'INDEX'), array('tag_id', 'INDEX')), + 'organisations' => array(array('uuid', 'INDEX'), array('name', 'FULLTEXT')), + 'posts' => array(array('post_id', 'INDEX'), array('thread_id', 'INDEX')), + 'shadow_attributes' => array(array('value1', 'INDEX', '255'), array('value2', 'INDEX', '255'), array('old_id', 'INDEX'), array('event_id', 'INDEX'), array('uuid', 'INDEX'), array('event_org_id', 'INDEX'), array('event_uuid', 'INDEX')), + 'sharing_groups' => array(array('org_id', 'INDEX'), array('sync_user_id', 'INDEX'), array('uuid', 'INDEX'), array('organisation_uuid', 'INDEX')), + 'sharing_group_orgs' => array(array('sharing_group_id', 'INDEX'), array('org_id', 'INDEX')), + 'sharing_group_servers' => array(array('sharing_group_id', 'INDEX'), array('server_id', 'INDEX')), + 'servers' => array(array('org_id', 'INDEX'), array('remote_org_id', 'INDEX')), + 'tags' => array(array('name', 'FULLTEXT')), + 'threads' => array(array('user_id', 'INDEX'), array('event_id', 'INDEX'), array('org_id', 'INDEX'), array('sharing_group_id', 'INDEX')), + 'users' => array(array('org_id', 'INDEX'), array('server_id', 'INDEX'), array('email', 'INDEX')), + ); - $version = $this->query('select version();'); - $version = $version[0][0]['version()']; - $version = explode('.', $version); - $version[0] = intval($version[0]); - $version[1] = intval($version[1]); - $downgrade = true; - if ($version[0] > 5 || ($version[0] == 5 && $version[1] > 5)) $downgrade = false; + $version = $this->query('select version();'); + $version = $version[0][0]['version()']; + $version = explode('.', $version); + $version[0] = intval($version[0]); + $version[1] = intval($version[1]); + $downgrade = true; + if ($version[0] > 5 || ($version[0] == 5 && $version[1] > 5)) { + $downgrade = false; + } - // keep the fulltext for now, we can change it later to actually use it once we require MySQL 5.6 / or if we decide to move some tables to MyISAM + // keep the fulltext for now, we can change it later to actually use it once we require MySQL 5.6 / or if we decide to move some tables to MyISAM - foreach ($fieldsToIndex as $table => $fields) { - $downgradeThis = false; - $table_data = $this->query("SHOW TABLE STATUS WHERE Name = '" . $table . "'"); - if ($downgrade && $table_data[0]['TABLES']['Engine'] !== 'MyISAM') $downgradeThis = true; - foreach ($fields as $field) { - $extra = ''; - $this->__dropIndex($table, $field[0]); - if (isset($field[2])) $extra = ' (' . $field[2] . ')'; - $sqlArray[] = 'ALTER TABLE `' . $table . '` ADD ' . ($downgradeThis ? 'INDEX' : $field[1]) . ' `' . $field[0] . '` (`' . $field[0] . '`' . $extra . ');'; - } - } - break; - case 'adminTable': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `admin_settings` ( + foreach ($fieldsToIndex as $table => $fields) { + $downgradeThis = false; + $table_data = $this->query("SHOW TABLE STATUS WHERE Name = '" . $table . "'"); + if ($downgrade && $table_data[0]['TABLES']['Engine'] !== 'MyISAM') { + $downgradeThis = true; + } + foreach ($fields as $field) { + $extra = ''; + $this->__dropIndex($table, $field[0]); + if (isset($field[2])) { + $extra = ' (' . $field[2] . ')'; + } + $sqlArray[] = 'ALTER TABLE `' . $table . '` ADD ' . ($downgradeThis ? 'INDEX' : $field[1]) . ' `' . $field[0] . '` (`' . $field[0] . '`' . $extra . ');'; + } + } + break; + case 'adminTable': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `admin_settings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `setting` varchar(255) COLLATE utf8_bin NOT NULL, `value` text COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "INSERT INTO `admin_settings` (`setting`, `value`) VALUES ('db_version', '2.4.0');"; - break; - case '2.4.18': - $sqlArray[] = "ALTER TABLE `users` ADD `current_login` INT(11) DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ADD `last_login` INT(11) DEFAULT 0;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `event_delegations` ( + $sqlArray[] = "INSERT INTO `admin_settings` (`setting`, `value`) VALUES ('db_version', '2.4.0');"; + break; + case '2.4.18': + $sqlArray[] = "ALTER TABLE `users` ADD `current_login` INT(11) DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ADD `last_login` INT(11) DEFAULT 0;"; + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `event_delegations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `org_id` int(11) NOT NULL, `requester_org_id` int(11) NOT NULL, @@ -359,12 +365,12 @@ class AppModel extends Model { KEY `org_id` (`org_id`), KEY `event_id` (`event_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.19': - $sqlArray[] = "DELETE FROM `shadow_attributes` WHERE `event_uuid` = '';"; - break; - case '2.4.20': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `shadow_attribute_correlations` ( + break; + case '2.4.19': + $sqlArray[] = "DELETE FROM `shadow_attributes` WHERE `event_uuid` = '';"; + break; + case '2.4.20': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `shadow_attribute_correlations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `org_id` int(11) NOT NULL, `value` text NOT NULL, @@ -386,9 +392,9 @@ class AppModel extends Model { KEY `sharing_group_id` (`sharing_group_id`), KEY `1_shadow_attribute_id` (`1_shadow_attribute_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.25': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `feeds` ( + break; + case '2.4.25': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `feeds` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_bin NOT NULL, `provider` varchar(255) COLLATE utf8_bin NOT NULL, @@ -401,16 +407,16 @@ class AppModel extends Model { `default` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.32': - $sqlArray[] = "ALTER TABLE `roles` ADD `perm_tag_editor` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'UPDATE `roles` SET `perm_tag_editor` = 1 WHERE `perm_tagger` = 1;'; - break; - case '2.4.33': - $sqlArray[] = "ALTER TABLE `users` ADD `force_logout` tinyint(1) NOT NULL DEFAULT 0;"; - break; - case '2.4.38': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglists` ( + break; + case '2.4.32': + $sqlArray[] = "ALTER TABLE `roles` ADD `perm_tag_editor` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'UPDATE `roles` SET `perm_tag_editor` = 1 WHERE `perm_tagger` = 1;'; + break; + case '2.4.33': + $sqlArray[] = "ALTER TABLE `users` ADD `force_logout` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case '2.4.38': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_bin NOT NULL, `type` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT 'string', @@ -420,25 +426,25 @@ class AppModel extends Model { `warninglist_entry_count` int(11) unsigned DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglist_entries` ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglist_entries` ( `id` int(11) NOT NULL AUTO_INCREMENT, `value` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `warninglist_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglist_types` ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `warninglist_types` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` varchar(255) COLLATE utf8_bin NOT NULL, `warninglist_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.39': - $sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin AFTER `gpgkey`;"; - $sqlArray[] = 'ALTER TABLE `logs` MODIFY COLUMN `title` text, MODIFY COLUMN `change` text;'; - break; - case '2.4.40': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `favourite_tags` ( + break; + case '2.4.39': + $sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin AFTER `gpgkey`;"; + $sqlArray[] = 'ALTER TABLE `logs` MODIFY COLUMN `title` text, MODIFY COLUMN `change` text;'; + break; + case '2.4.40': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `favourite_tags` ( `id` int(11) NOT NULL AUTO_INCREMENT, `tag_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, @@ -446,17 +452,17 @@ class AppModel extends Model { INDEX `user_id` (`user_id`), INDEX `tag_id` (`tag_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.42': - $sqlArray[] = "ALTER TABLE `attributes` ADD `deleted` tinyint(1) NOT NULL DEFAULT 0;"; - break; - case '2.4.44': - $sqlArray[] = "UPDATE `servers` SET `url` = TRIM(TRAILING '/' FROM `url`);"; - break; - case '2.4.45': - $sqlArray[] = 'ALTER TABLE `users` CHANGE `newsread` `newsread` int(11) unsigned;'; - $sqlArray[] = 'UPDATE `users` SET `newsread` = 0;'; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `news` ( + break; + case '2.4.42': + $sqlArray[] = "ALTER TABLE `attributes` ADD `deleted` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case '2.4.44': + $sqlArray[] = "UPDATE `servers` SET `url` = TRIM(TRAILING '/' FROM `url`);"; + break; + case '2.4.45': + $sqlArray[] = 'ALTER TABLE `users` CHANGE `newsread` `newsread` int(11) unsigned;'; + $sqlArray[] = 'UPDATE `users` SET `newsread` = 0;'; + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL AUTO_INCREMENT, `message` text COLLATE utf8_bin NOT NULL, `title` text COLLATE utf8_bin NOT NULL, @@ -464,78 +470,78 @@ class AppModel extends Model { `date_created` int(11) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - break; - case '2.4.49': - // table: users - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `server_id` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `autoalert` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `invited_by` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `nids_sid` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `termsaccepted` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `role_id` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `change_pw` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `contactalert` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `disabled` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `users` MODIFY `authkey` varchar(40) COLLATE utf8_bin DEFAULT NULL;"; - $sqlArray[] = "ALTER TABLE `users` MODIFY `gpgkey` longtext COLLATE utf8_bin;"; - // table: events - $sqlArray[] = "ALTER TABLE `events` ALTER COLUMN `publish_timestamp` SET DEFAULT 0;"; - // table: jobs - $sqlArray[] = "ALTER TABLE `jobs` ALTER COLUMN `org_id` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `jobs` MODIFY `process_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; - // table: organisations - $sqlArray[] = "ALTER TABLE `organisations` ALTER COLUMN `created_by` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `organisations` MODIFY `uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL;"; // https://github.com/MISP/MISP/pull/1260 - // table: logs - $sqlArray[] = "ALTER TABLE `logs` MODIFY `title` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; - $sqlArray[] = "ALTER TABLE `logs` MODIFY `change` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; - $sqlArray[] = "ALTER TABLE `logs` MODIFY `description` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; - // table: servers - $sqlArray[] = "ALTER TABLE `servers` DROP `lastfetchedid`;"; // git commit hash d4c393897e8666fbbf04443a97d60c508700f5b4 - $sqlArray[] = "ALTER TABLE `servers` MODIFY `cert_file` varchar(255) COLLATE utf8_bin DEFAULT NULL;"; - // table: feeds - $sqlArray[] = "ALTER TABLE `feeds` ALTER COLUMN `sharing_group_id` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `feeds` ALTER COLUMN `tag_id` SET DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `feeds` MODIFY `rules` text COLLATE utf8_bin DEFAULT NULL;"; - // DB changes to support https://github.com/MISP/MISP/pull/1334 - $sqlArray[] = "ALTER TABLE `roles` ADD `perm_delegate` tinyint(1) NOT NULL DEFAULT 0 AFTER `perm_publish`;"; - $sqlArray[] = "UPDATE `roles` SET `perm_delegate` = 1 WHERE `perm_publish` = 1;"; - // DB changes to solve https://github.com/MISP/MISP/issues/1354 - $sqlArray[] = "ALTER TABLE `taxonomy_entries` MODIFY `expanded` text COLLATE utf8_bin;"; - $sqlArray[] = "ALTER TABLE `taxonomy_predicates` MODIFY `expanded` text COLLATE utf8_bin;"; - // Sharing group propagate to instances freely setting - $sqlArray[] = "ALTER TABLE `sharing_groups` ADD `roaming` tinyint(1) NOT NULL DEFAULT 0;"; - // table: shadow_attributes - $sqlArray[] = "ALTER TABLE `shadow_attributes` MODIFY `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL;"; - // table: tasks - $sqlArray[] = "ALTER TABLE `tasks` CHANGE `job_id` `process_id` varchar(32) DEFAULT NULL;"; - // Adding tag org restrictions - $sqlArray[] = "ALTER TABLE `tags` ADD `org_id` int(11) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `org_id` (`org_id`);'; - $this->__dropIndex('tags', 'org_id'); - break; - case '2.4.50': - $sqlArray[] = 'ALTER TABLE `cake_sessions` ADD INDEX `expires` (`expires`);'; - $sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin AFTER `gpgkey`;"; - $sqlArray[] = "ALTER TABLE `servers` ADD `client_cert_file` varchar(255) COLLATE utf8_bin DEFAULT NULL;"; - $this->__dropIndex('cake_sessions', 'expires'); - break; - case '2.4.51': - $sqlArray[] = 'ALTER TABLE `servers` ADD `internal` tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE `roles` ADD `default_role` tinyint(1) NOT NULL DEFAULT 0;'; - break; - case '2.4.52': - $sqlArray[] = "ALTER TABLE feeds ADD source_format varchar(255) COLLATE utf8_bin DEFAULT 'misp';"; - $sqlArray[] = 'ALTER TABLE feeds ADD fixed_event tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds ADD delta_merge tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds ADD event_id int(11) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds ADD publish tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds ADD override_ids tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = "ALTER TABLE feeds ADD settings text NOT NULL DEFAULT '';"; - break; - case '2.4.56': - $sqlArray[] = - "CREATE TABLE IF NOT EXISTS galaxies ( + break; + case '2.4.49': + // table: users + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `server_id` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `autoalert` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `invited_by` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `nids_sid` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `termsaccepted` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `role_id` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `change_pw` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `contactalert` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` ALTER COLUMN `disabled` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `users` MODIFY `authkey` varchar(40) COLLATE utf8_bin DEFAULT NULL;"; + $sqlArray[] = "ALTER TABLE `users` MODIFY `gpgkey` longtext COLLATE utf8_bin;"; + // table: events + $sqlArray[] = "ALTER TABLE `events` ALTER COLUMN `publish_timestamp` SET DEFAULT 0;"; + // table: jobs + $sqlArray[] = "ALTER TABLE `jobs` ALTER COLUMN `org_id` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `jobs` MODIFY `process_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; + // table: organisations + $sqlArray[] = "ALTER TABLE `organisations` ALTER COLUMN `created_by` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `organisations` MODIFY `uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL;"; // https://github.com/MISP/MISP/pull/1260 + // table: logs + $sqlArray[] = "ALTER TABLE `logs` MODIFY `title` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; + $sqlArray[] = "ALTER TABLE `logs` MODIFY `change` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; + $sqlArray[] = "ALTER TABLE `logs` MODIFY `description` text CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;"; + // table: servers + $sqlArray[] = "ALTER TABLE `servers` DROP `lastfetchedid`;"; // git commit hash d4c393897e8666fbbf04443a97d60c508700f5b4 + $sqlArray[] = "ALTER TABLE `servers` MODIFY `cert_file` varchar(255) COLLATE utf8_bin DEFAULT NULL;"; + // table: feeds + $sqlArray[] = "ALTER TABLE `feeds` ALTER COLUMN `sharing_group_id` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `feeds` ALTER COLUMN `tag_id` SET DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `feeds` MODIFY `rules` text COLLATE utf8_bin DEFAULT NULL;"; + // DB changes to support https://github.com/MISP/MISP/pull/1334 + $sqlArray[] = "ALTER TABLE `roles` ADD `perm_delegate` tinyint(1) NOT NULL DEFAULT 0 AFTER `perm_publish`;"; + $sqlArray[] = "UPDATE `roles` SET `perm_delegate` = 1 WHERE `perm_publish` = 1;"; + // DB changes to solve https://github.com/MISP/MISP/issues/1354 + $sqlArray[] = "ALTER TABLE `taxonomy_entries` MODIFY `expanded` text COLLATE utf8_bin;"; + $sqlArray[] = "ALTER TABLE `taxonomy_predicates` MODIFY `expanded` text COLLATE utf8_bin;"; + // Sharing group propagate to instances freely setting + $sqlArray[] = "ALTER TABLE `sharing_groups` ADD `roaming` tinyint(1) NOT NULL DEFAULT 0;"; + // table: shadow_attributes + $sqlArray[] = "ALTER TABLE `shadow_attributes` MODIFY `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL;"; + // table: tasks + $sqlArray[] = "ALTER TABLE `tasks` CHANGE `job_id` `process_id` varchar(32) DEFAULT NULL;"; + // Adding tag org restrictions + $sqlArray[] = "ALTER TABLE `tags` ADD `org_id` int(11) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `org_id` (`org_id`);'; + $this->__dropIndex('tags', 'org_id'); + break; + case '2.4.50': + $sqlArray[] = 'ALTER TABLE `cake_sessions` ADD INDEX `expires` (`expires`);'; + $sqlArray[] = "ALTER TABLE `users` ADD `certif_public` longtext COLLATE utf8_bin AFTER `gpgkey`;"; + $sqlArray[] = "ALTER TABLE `servers` ADD `client_cert_file` varchar(255) COLLATE utf8_bin DEFAULT NULL;"; + $this->__dropIndex('cake_sessions', 'expires'); + break; + case '2.4.51': + $sqlArray[] = 'ALTER TABLE `servers` ADD `internal` tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE `roles` ADD `default_role` tinyint(1) NOT NULL DEFAULT 0;'; + break; + case '2.4.52': + $sqlArray[] = "ALTER TABLE feeds ADD source_format varchar(255) COLLATE utf8_bin DEFAULT 'misp';"; + $sqlArray[] = 'ALTER TABLE feeds ADD fixed_event tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds ADD delta_merge tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds ADD event_id int(11) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds ADD publish tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds ADD override_ids tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = "ALTER TABLE feeds ADD settings text NOT NULL DEFAULT '';"; + break; + case '2.4.56': + $sqlArray[] = + "CREATE TABLE IF NOT EXISTS galaxies ( `id` int(11) NOT NULL AUTO_INCREMENT, `uuid` varchar(255) COLLATE utf8_bin NOT NULL, `name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', @@ -545,12 +551,12 @@ class AppModel extends Model { PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $this->__addIndex('galaxies', 'name'); - $this->__addIndex('galaxies', 'uuid'); - $this->__addIndex('galaxies', 'type'); + $this->__addIndex('galaxies', 'name'); + $this->__addIndex('galaxies', 'uuid'); + $this->__addIndex('galaxies', 'type'); - $sqlArray[] = - "CREATE TABLE IF NOT EXISTS galaxy_clusters ( + $sqlArray[] = + "CREATE TABLE IF NOT EXISTS galaxy_clusters ( `id` int(11) NOT NULL AUTO_INCREMENT, `uuid` varchar(255) COLLATE utf8_bin NOT NULL, `type` varchar(255) COLLATE utf8_bin NOT NULL, @@ -563,13 +569,13 @@ class AppModel extends Model { PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $this->__addIndex('galaxy_clusters', 'value', 255); - $this->__addIndex('galaxy_clusters', 'tag_name'); - $this->__addIndex('galaxy_clusters', 'uuid'); - $this->__addIndex('galaxy_clusters', 'type'); + $this->__addIndex('galaxy_clusters', 'value', 255); + $this->__addIndex('galaxy_clusters', 'tag_name'); + $this->__addIndex('galaxy_clusters', 'uuid'); + $this->__addIndex('galaxy_clusters', 'type'); - $sqlArray[] = - "CREATE TABLE IF NOT EXISTS galaxy_elements ( + $sqlArray[] = + "CREATE TABLE IF NOT EXISTS galaxy_elements ( `id` int(11) NOT NULL AUTO_INCREMENT, `galaxy_cluster_id` int(11) NOT NULL, `key` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', @@ -577,11 +583,11 @@ class AppModel extends Model { PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $this->__addIndex('galaxy_elements', 'key'); - $this->__addIndex('galaxy_elements', 'value', 255); + $this->__addIndex('galaxy_elements', 'key'); + $this->__addIndex('galaxy_elements', 'value', 255); - $sqlArray[] = - "CREATE TABLE IF NOT EXISTS galaxy_reference ( + $sqlArray[] = + "CREATE TABLE IF NOT EXISTS galaxy_reference ( `id` int(11) NOT NULL AUTO_INCREMENT, `galaxy_cluster_id` int(11) NOT NULL, `referenced_galaxy_cluster_id` int(11) NOT NULL, @@ -591,112 +597,112 @@ class AppModel extends Model { PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;"; - $this->__addIndex('galaxy_reference', 'galaxy_cluster_id'); - $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_id'); - $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_value', 255); - $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_type', 255); + $this->__addIndex('galaxy_reference', 'galaxy_cluster_id'); + $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_id'); + $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_value', 255); + $this->__addIndex('galaxy_reference', 'referenced_galaxy_cluster_type', 255); - break; - case '2.4.57': - $sqlArray[] = 'ALTER TABLE tags ADD hide_tag tinyint(1) NOT NULL DEFAULT 0;'; - // new indeces to match the changes in #1766 - $this->__dropIndex('correlations', '1_event_id'); - $this->__addIndex('correlations', '1_event_id'); - $this->__addIndex('warninglist_entries', 'warninglist_id'); - break; - case '2.4.58': - $sqlArray[] = "ALTER TABLE `events` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE `attributes` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; - break; - case '2.4.59': - $sqlArray[] = "ALTER TABLE taxonomy_entries ADD colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"; - $sqlArray[] = "ALTER TABLE taxonomy_predicates ADD colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"; - break; - case '2.4.60': - if ($dataSource == 'Database/Mysql') { - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `attribute_tags` ( + break; + case '2.4.57': + $sqlArray[] = 'ALTER TABLE tags ADD hide_tag tinyint(1) NOT NULL DEFAULT 0;'; + // new indeces to match the changes in #1766 + $this->__dropIndex('correlations', '1_event_id'); + $this->__addIndex('correlations', '1_event_id'); + $this->__addIndex('warninglist_entries', 'warninglist_id'); + break; + case '2.4.58': + $sqlArray[] = "ALTER TABLE `events` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE `attributes` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case '2.4.59': + $sqlArray[] = "ALTER TABLE taxonomy_entries ADD colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"; + $sqlArray[] = "ALTER TABLE taxonomy_predicates ADD colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '';"; + break; + case '2.4.60': + if ($dataSource == 'Database/Mysql') { + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `attribute_tags` ( `id` int(11) NOT NULL AUTO_INCREMENT, `attribute_id` int(11) NOT NULL, `event_id` int(11) NOT NULL, `tag_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; - $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `attribute_id` (`attribute_id`);'; - $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `event_id` (`event_id`);'; - $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `tag_id` (`tag_id`);'; - } else if ($dataSource == 'Database/Postgres') { - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS attribute_tags ( + $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `attribute_id` (`attribute_id`);'; + $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `event_id` (`event_id`);'; + $sqlArray[] = 'ALTER TABLE `attribute_tags` ADD INDEX `tag_id` (`tag_id`);'; + } elseif ($dataSource == 'Database/Postgres') { + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS attribute_tags ( id bigserial NOT NULL, attribute_id bigint NOT NULL, event_id bigint NOT NULL, tag_id bigint NOT NULL, PRIMARY KEY (id) );'; - $sqlArray[] = 'CREATE INDEX idx_attribute_tags_attribute_id ON attribute_tags (attribute_id);'; - $sqlArray[] = 'CREATE INDEX idx_attribute_tags_event_id ON attribute_tags (event_id);'; - $sqlArray[] = 'CREATE INDEX idx_attribute_tags_tag_id ON attribute_tags (tag_id);'; - } - break; - case '2.4.61': - $sqlArray[] = 'ALTER TABLE feeds ADD input_source varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "network";'; - $sqlArray[] = 'ALTER TABLE feeds ADD delete_local_file tinyint(1) DEFAULT 0;'; - $indexArray[] = array('feeds', 'input_source'); - break; - case '2.4.62': - $sqlArray[] = 'ALTER TABLE logs CHANGE `org` `org` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "";'; - $sqlArray[] = 'ALTER TABLE logs CHANGE `email` `email` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "";'; - $sqlArray[] = 'ALTER TABLE logs CHANGE `change` `change` text COLLATE utf8_bin NOT NULL DEFAULT "";'; - break; - case '2.4.63': - $sqlArray[] = 'ALTER TABLE events DROP COLUMN org;'; - $sqlArray[] = 'ALTER TABLE events DROP COLUMN orgc;'; - $sqlArray[] = 'ALTER TABLE event_blacklists CHANGE comment comment TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci;'; - break; - case '2.4.64': - $indexArray[] = array('feeds', 'input_source'); - $indexArray[] = array('attributes', 'value1', 255); - $indexArray[] = array('attributes', 'value2', 255); - $indexArray[] = array('attributes', 'type'); - $indexArray[] = array('galaxy_reference', 'galaxy_cluster_id'); - $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_id'); - $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_value', 255); - $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_type', 255); - $indexArray[] = array('correlations', '1_event_id'); - $indexArray[] = array('warninglist_entries', 'warninglist_id'); - $indexArray[] = array('galaxy_clusters', 'value', 255); - $indexArray[] = array('galaxy_clusters', 'tag_name'); - $indexArray[] = array('galaxy_clusters', 'uuid'); - $indexArray[] = array('galaxy_clusters', 'type'); - $indexArray[] = array('galaxies', 'name'); - $indexArray[] = array('galaxies', 'uuid'); - $indexArray[] = array('galaxies', 'type'); - break; - case '2.4.65': - $sqlArray[] = 'ALTER TABLE feeds CHANGE `enabled` `enabled` tinyint(1) DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds CHANGE `default` `default` tinyint(1) DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds CHANGE `distribution` `distribution` tinyint(4) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE feeds CHANGE `sharing_group_id` `sharing_group_id` int(11) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE attributes CHANGE `comment` `comment` text COLLATE utf8_bin;'; - break; - case '2.4.66': - $sqlArray[] = 'ALTER TABLE shadow_attributes CHANGE old_id old_id int(11) DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN uuid varchar(255) COLLATE utf8_bin DEFAULT "";'; - $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN source varchar(255) COLLATE utf8_bin DEFAULT "";'; - $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN type int(11) DEFAULT 0;'; - $indexArray[] = array('sightings', 'uuid'); - $indexArray[] = array('sightings', 'source'); - $indexArray[] = array('sightings', 'type'); - $indexArray[] = array('attributes', 'category'); - $indexArray[] = array('shadow_attributes', 'category'); - $indexArray[] = array('shadow_attributes', 'type'); - break; - case '2.4.67': - $sqlArray[] = "ALTER TABLE `roles` ADD `perm_sighting` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'UPDATE `roles` SET `perm_sighting` = 1 WHERE `perm_add` = 1;'; - break; - case '2.4.68': - $sqlArray[] = 'ALTER TABLE events CHANGE attribute_count attribute_count int(11) unsigned DEFAULT 0;'; - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `event_blacklists` ( + $sqlArray[] = 'CREATE INDEX idx_attribute_tags_attribute_id ON attribute_tags (attribute_id);'; + $sqlArray[] = 'CREATE INDEX idx_attribute_tags_event_id ON attribute_tags (event_id);'; + $sqlArray[] = 'CREATE INDEX idx_attribute_tags_tag_id ON attribute_tags (tag_id);'; + } + break; + case '2.4.61': + $sqlArray[] = 'ALTER TABLE feeds ADD input_source varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "network";'; + $sqlArray[] = 'ALTER TABLE feeds ADD delete_local_file tinyint(1) DEFAULT 0;'; + $indexArray[] = array('feeds', 'input_source'); + break; + case '2.4.62': + $sqlArray[] = 'ALTER TABLE logs CHANGE `org` `org` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "";'; + $sqlArray[] = 'ALTER TABLE logs CHANGE `email` `email` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT "";'; + $sqlArray[] = 'ALTER TABLE logs CHANGE `change` `change` text COLLATE utf8_bin NOT NULL DEFAULT "";'; + break; + case '2.4.63': + $sqlArray[] = 'ALTER TABLE events DROP COLUMN org;'; + $sqlArray[] = 'ALTER TABLE events DROP COLUMN orgc;'; + $sqlArray[] = 'ALTER TABLE event_blacklists CHANGE comment comment TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci;'; + break; + case '2.4.64': + $indexArray[] = array('feeds', 'input_source'); + $indexArray[] = array('attributes', 'value1', 255); + $indexArray[] = array('attributes', 'value2', 255); + $indexArray[] = array('attributes', 'type'); + $indexArray[] = array('galaxy_reference', 'galaxy_cluster_id'); + $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_id'); + $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_value', 255); + $indexArray[] = array('galaxy_reference', 'referenced_galaxy_cluster_type', 255); + $indexArray[] = array('correlations', '1_event_id'); + $indexArray[] = array('warninglist_entries', 'warninglist_id'); + $indexArray[] = array('galaxy_clusters', 'value', 255); + $indexArray[] = array('galaxy_clusters', 'tag_name'); + $indexArray[] = array('galaxy_clusters', 'uuid'); + $indexArray[] = array('galaxy_clusters', 'type'); + $indexArray[] = array('galaxies', 'name'); + $indexArray[] = array('galaxies', 'uuid'); + $indexArray[] = array('galaxies', 'type'); + break; + case '2.4.65': + $sqlArray[] = 'ALTER TABLE feeds CHANGE `enabled` `enabled` tinyint(1) DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds CHANGE `default` `default` tinyint(1) DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds CHANGE `distribution` `distribution` tinyint(4) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE feeds CHANGE `sharing_group_id` `sharing_group_id` int(11) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE attributes CHANGE `comment` `comment` text COLLATE utf8_bin;'; + break; + case '2.4.66': + $sqlArray[] = 'ALTER TABLE shadow_attributes CHANGE old_id old_id int(11) DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN uuid varchar(255) COLLATE utf8_bin DEFAULT "";'; + $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN source varchar(255) COLLATE utf8_bin DEFAULT "";'; + $sqlArray[] = 'ALTER TABLE sightings ADD COLUMN type int(11) DEFAULT 0;'; + $indexArray[] = array('sightings', 'uuid'); + $indexArray[] = array('sightings', 'source'); + $indexArray[] = array('sightings', 'type'); + $indexArray[] = array('attributes', 'category'); + $indexArray[] = array('shadow_attributes', 'category'); + $indexArray[] = array('shadow_attributes', 'type'); + break; + case '2.4.67': + $sqlArray[] = "ALTER TABLE `roles` ADD `perm_sighting` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'UPDATE `roles` SET `perm_sighting` = 1 WHERE `perm_add` = 1;'; + break; + case '2.4.68': + $sqlArray[] = 'ALTER TABLE events CHANGE attribute_count attribute_count int(11) unsigned DEFAULT 0;'; + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `event_blacklists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `event_uuid` varchar(40) COLLATE utf8_bin NOT NULL, `created` datetime NOT NULL, @@ -705,9 +711,9 @@ class AppModel extends Model { `event_orgc` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;'; - $indexArray[] = array('event_blacklists', 'event_uuid'); - $indexArray[] = array('event_blacklists', 'event_orgc'); - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `org_blacklists` ( + $indexArray[] = array('event_blacklists', 'event_uuid'); + $indexArray[] = array('event_blacklists', 'event_orgc'); + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `org_blacklists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `org_uuid` varchar(40) COLLATE utf8_bin NOT NULL, `created` datetime NOT NULL, @@ -717,45 +723,45 @@ class AppModel extends Model { INDEX `org_uuid` (`org_uuid`), INDEX `org_name` (`org_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;'; - $indexArray[] = array('org_blacklists', 'org_uuid'); - $indexArray[] = array('org_blacklists', 'org_name'); - $sqlArray[] = "ALTER TABLE shadow_attributes CHANGE proposal_to_delete proposal_to_delete BOOLEAN DEFAULT 0"; - $sqlArray[] = "ALTER TABLE taxonomy_predicates CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; - $sqlArray[] = "ALTER TABLE taxonomy_entries CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; - break; - case '2.4.69': - $sqlArray[] = "ALTER TABLE taxonomy_entries CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; - $sqlArray[] = "ALTER TABLE users ADD COLUMN date_created bigint(20);"; - $sqlArray[] = "ALTER TABLE users ADD COLUMN date_modified bigint(20);"; - break; - case '2.4.71': - $sqlArray[] = "UPDATE attributes SET comment = '' WHERE comment is NULL;"; - $sqlArray[] = "ALTER TABLE attributes CHANGE comment comment text COLLATE utf8_bin NOT NULL;"; - break; - case '2.4.72': - $sqlArray[] = 'ALTER TABLE feeds ADD lookup_visible tinyint(1) DEFAULT 0;'; - break; - case '2.4.73': - $sqlArray[] = 'ALTER TABLE `servers` ADD `unpublish_event` tinyint(1) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE `servers` ADD `publish_without_email` tinyint(1) NOT NULL DEFAULT 0;'; - break; - case '2.4.75': - $this->__dropIndex('attributes', 'value1'); - $this->__dropIndex('attributes', 'value2'); - $this->__addIndex('attributes', 'value1', 255); - $this->__addIndex('attributes', 'value2', 255); - break; - case '2.4.77': - $sqlArray[] = 'ALTER TABLE `users` CHANGE `password` `password` VARCHAR(255) COLLATE utf8_bin NOT NULL;'; - break; - case '2.4.78': - $sqlArray[] = "ALTER TABLE galaxy_clusters ADD COLUMN version int(11) DEFAULT 0;"; - $this->__addIndex('galaxy_clusters', 'version'); - $this->__addIndex('galaxy_clusters', 'galaxy_id'); - $this->__addIndex('galaxy_elements', 'galaxy_cluster_id'); - break; - case '2.4.80': - $sqlArray[] = "CREATE TABLE IF NOT EXISTS objects ( + $indexArray[] = array('org_blacklists', 'org_uuid'); + $indexArray[] = array('org_blacklists', 'org_name'); + $sqlArray[] = "ALTER TABLE shadow_attributes CHANGE proposal_to_delete proposal_to_delete BOOLEAN DEFAULT 0"; + $sqlArray[] = "ALTER TABLE taxonomy_predicates CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; + $sqlArray[] = "ALTER TABLE taxonomy_entries CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; + break; + case '2.4.69': + $sqlArray[] = "ALTER TABLE taxonomy_entries CHANGE colour colour varchar(7) CHARACTER SET utf8 COLLATE utf8_bin;"; + $sqlArray[] = "ALTER TABLE users ADD COLUMN date_created bigint(20);"; + $sqlArray[] = "ALTER TABLE users ADD COLUMN date_modified bigint(20);"; + break; + case '2.4.71': + $sqlArray[] = "UPDATE attributes SET comment = '' WHERE comment is NULL;"; + $sqlArray[] = "ALTER TABLE attributes CHANGE comment comment text COLLATE utf8_bin NOT NULL;"; + break; + case '2.4.72': + $sqlArray[] = 'ALTER TABLE feeds ADD lookup_visible tinyint(1) DEFAULT 0;'; + break; + case '2.4.73': + $sqlArray[] = 'ALTER TABLE `servers` ADD `unpublish_event` tinyint(1) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE `servers` ADD `publish_without_email` tinyint(1) NOT NULL DEFAULT 0;'; + break; + case '2.4.75': + $this->__dropIndex('attributes', 'value1'); + $this->__dropIndex('attributes', 'value2'); + $this->__addIndex('attributes', 'value1', 255); + $this->__addIndex('attributes', 'value2', 255); + break; + case '2.4.77': + $sqlArray[] = 'ALTER TABLE `users` CHANGE `password` `password` VARCHAR(255) COLLATE utf8_bin NOT NULL;'; + break; + case '2.4.78': + $sqlArray[] = "ALTER TABLE galaxy_clusters ADD COLUMN version int(11) DEFAULT 0;"; + $this->__addIndex('galaxy_clusters', 'version'); + $this->__addIndex('galaxy_clusters', 'galaxy_id'); + $this->__addIndex('galaxy_elements', 'galaxy_cluster_id'); + break; + case '2.4.80': + $sqlArray[] = "CREATE TABLE IF NOT EXISTS objects ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, `meta-category` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, @@ -781,7 +787,7 @@ class AppModel extends Model { INDEX `sharing_group_id` (`sharing_group_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_references ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_references ( `id` int(11) NOT NULL AUTO_INCREMENT, `uuid` varchar(40) COLLATE utf8_bin DEFAULT NULL, `timestamp` int(11) NOT NULL DEFAULT 0, @@ -803,7 +809,7 @@ class AppModel extends Model { INDEX `relationship_type` (`relationship_type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_relationships ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_relationships ( `id` int(11) NOT NULL AUTO_INCREMENT, `version` int(11) NOT NULL, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, @@ -814,7 +820,7 @@ class AppModel extends Model { ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_templates ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_templates ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `org_id` int(11) NOT NULL, @@ -834,7 +840,7 @@ class AppModel extends Model { INDEX `meta-category` (`meta-category`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_template_elements ( + $sqlArray[] = "CREATE TABLE IF NOT EXISTS object_template_elements ( `id` int(11) NOT NULL AUTO_INCREMENT, `object_template_id` int(11) NOT NULL, `object_relation` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci, @@ -851,77 +857,77 @@ class AppModel extends Model { INDEX `type` (`type`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $sqlArray[] = 'ALTER TABLE `logs` CHANGE `model` `model` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;'; - $sqlArray[] = 'ALTER TABLE `logs` CHANGE `action` `action` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `logs` CHANGE `model` `model` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;'; + $sqlArray[] = 'ALTER TABLE `logs` CHANGE `action` `action` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL;'; - $sqlArray[] = 'ALTER TABLE attributes ADD object_id int(11) NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE attributes ADD object_relation varchar(255) COLLATE utf8_bin;'; + $sqlArray[] = 'ALTER TABLE attributes ADD object_id int(11) NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE attributes ADD object_relation varchar(255) COLLATE utf8_bin;'; - $sqlArray[] = "ALTER TABLE `roles` ADD `perm_object_template` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'UPDATE `roles` SET `perm_object_template` = 1 WHERE `perm_site_admin` = 1;'; + $sqlArray[] = "ALTER TABLE `roles` ADD `perm_object_template` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'UPDATE `roles` SET `perm_object_template` = 1 WHERE `perm_site_admin` = 1;'; - $indexArray[] = array('attributes', 'object_id'); - $indexArray[] = array('attributes', 'object_relation'); - break; - case '2.4.81': - $sqlArray[] = 'ALTER TABLE `galaxy_clusters` ADD `version` INT NOT NULL DEFAULT 0;'; - $sqlArray[] = 'ALTER TABLE `galaxies` ADD `icon` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; - break; - case '2.4.82': - $sqlArray[] = "ALTER TABLE organisations ADD restricted_to_domain text COLLATE utf8_bin;"; - break; - case '2.4.83': - $sqlArray[] = "ALTER TABLE object_template_elements CHANGE `disable_correlation` `disable_correlation` text COLLATE utf8_bin;"; - break; - case '2.4.84': - $sqlArray[] = "ALTER TABLE `tags` ADD `user_id` int(11) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `user_id` (`user_id`);'; - break; - case '2.4.85': - $sqlArray[] = "ALTER TABLE `shadow_attributes` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; - $sqlArray[] = "ALTER TABLE object_template_elements CHANGE `disable_correlation` `disable_correlation` text COLLATE utf8_bin;"; - // yes, this may look stupid as hell to index a boolean flag - but thanks to the stupidity of MySQL/MariaDB this will - // stop blocking other indexes to be used in queries where we also tests for the deleted flag. - $indexArray[] = array('attributes', 'deleted'); - break; - case '2.4.86': - break; - case '2.4.87': - $sqlArray[] = "ALTER TABLE `feeds` ADD `headers` TEXT COLLATE utf8_bin;"; - break; - case 1: - $sqlArray[] = "ALTER TABLE `tags` ADD `user_id` int(11) NOT NULL DEFAULT 0;"; - $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `user_id` (`user_id`);'; - break; - case 2: - // rerun missing db entries - $sqlArray[] = "ALTER TABLE users ADD COLUMN date_created bigint(20);"; - $sqlArray[] = "ALTER TABLE users ADD COLUMN date_modified bigint(20);"; - break; - case 3: - $sqlArray[] = "CREATE TABLE IF NOT EXISTS `fuzzy_correlate_ssdeep` ( + $indexArray[] = array('attributes', 'object_id'); + $indexArray[] = array('attributes', 'object_relation'); + break; + case '2.4.81': + $sqlArray[] = 'ALTER TABLE `galaxy_clusters` ADD `version` INT NOT NULL DEFAULT 0;'; + $sqlArray[] = 'ALTER TABLE `galaxies` ADD `icon` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; + break; + case '2.4.82': + $sqlArray[] = "ALTER TABLE organisations ADD restricted_to_domain text COLLATE utf8_bin;"; + break; + case '2.4.83': + $sqlArray[] = "ALTER TABLE object_template_elements CHANGE `disable_correlation` `disable_correlation` text COLLATE utf8_bin;"; + break; + case '2.4.84': + $sqlArray[] = "ALTER TABLE `tags` ADD `user_id` int(11) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `user_id` (`user_id`);'; + break; + case '2.4.85': + $sqlArray[] = "ALTER TABLE `shadow_attributes` ADD `disable_correlation` tinyint(1) NOT NULL DEFAULT 0;"; + $sqlArray[] = "ALTER TABLE object_template_elements CHANGE `disable_correlation` `disable_correlation` text COLLATE utf8_bin;"; + // yes, this may look stupid as hell to index a boolean flag - but thanks to the stupidity of MySQL/MariaDB this will + // stop blocking other indexes to be used in queries where we also tests for the deleted flag. + $indexArray[] = array('attributes', 'deleted'); + break; + case '2.4.86': + break; + case '2.4.87': + $sqlArray[] = "ALTER TABLE `feeds` ADD `headers` TEXT COLLATE utf8_bin;"; + break; + case 1: + $sqlArray[] = "ALTER TABLE `tags` ADD `user_id` int(11) NOT NULL DEFAULT 0;"; + $sqlArray[] = 'ALTER TABLE `tags` ADD INDEX `user_id` (`user_id`);'; + break; + case 2: + // rerun missing db entries + $sqlArray[] = "ALTER TABLE users ADD COLUMN date_created bigint(20);"; + $sqlArray[] = "ALTER TABLE users ADD COLUMN date_modified bigint(20);"; + break; + case 3: + $sqlArray[] = "CREATE TABLE IF NOT EXISTS `fuzzy_correlate_ssdeep` ( `id` int(11) NOT NULL AUTO_INCREMENT, `chunk` varchar(12) NOT NULL, `attribute_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - $this->__addIndex('fuzzy_correlate_ssdeep', 'chunk'); - $this->__addIndex('fuzzy_correlate_ssdeep', 'attribute_id'); - break; - case 4: - $sqlArray[] = 'ALTER TABLE `roles` ADD `memory_limit` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; - $sqlArray[] = 'ALTER TABLE `roles` ADD `max_execution_time` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; - $sqlArray[] = "ALTER TABLE `roles` ADD `restricted_to_site_admin` tinyint(1) NOT NULL DEFAULT 0;"; - break; - case 5: - $sqlArray[] = "ALTER TABLE `feeds` ADD `caching_enabled` tinyint(1) NOT NULL DEFAULT 0;"; - break; - case 6: - $sqlArray[] = "ALTER TABLE `events` ADD `extends_uuid` varchar(40) COLLATE utf8_bin DEFAULT '';"; - $indexArray[] = array('events', 'extends_uuid'); - break; - case 7: - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `noticelists` ( + $this->__addIndex('fuzzy_correlate_ssdeep', 'chunk'); + $this->__addIndex('fuzzy_correlate_ssdeep', 'attribute_id'); + break; + case 4: + $sqlArray[] = 'ALTER TABLE `roles` ADD `memory_limit` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; + $sqlArray[] = 'ALTER TABLE `roles` ADD `max_execution_time` VARCHAR(255) COLLATE utf8_bin DEFAULT "";'; + $sqlArray[] = "ALTER TABLE `roles` ADD `restricted_to_site_admin` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case 5: + $sqlArray[] = "ALTER TABLE `feeds` ADD `caching_enabled` tinyint(1) NOT NULL DEFAULT 0;"; + break; + case 6: + $sqlArray[] = "ALTER TABLE `events` ADD `extends_uuid` varchar(40) COLLATE utf8_bin DEFAULT '';"; + $indexArray[] = array('events', 'extends_uuid'); + break; + case 7: + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `noticelists` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `expanded_name` text COLLATE utf8_unicode_ci NOT NULL, @@ -933,7 +939,7 @@ class AppModel extends Model { INDEX `name` (`name`), INDEX `geographical_area` (`geographical_area`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; - $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `noticelist_entries` ( + $sqlArray[] = 'CREATE TABLE IF NOT EXISTS `noticelist_entries` ( `id` int(11) NOT NULL AUTO_INCREMENT, `noticelist_id` int(11) NOT NULL, `data` text COLLATE utf8_unicode_ci NOT NULL, diff --git a/app/View/Events/upload_analysis_file.ctp b/app/View/Events/upload_analysis_file.ctp new file mode 100644 index 000000000..732dfb56b --- /dev/null +++ b/app/View/Events/upload_analysis_file.ctp @@ -0,0 +1,106 @@ +
+Form->create('Event', array('type' => 'file')); +?> +
+ +Form->input('analysis_file', array( + 'label' => 'Analysis file', + 'type' => 'file', + )); + ?> +
+ Form->input('publish', array( + // 'checked' => false, + // 'label' => __('Publish imported events'), + // )); +?> +
+Form->button(__('Upload'), array('class' => 'btn btn-primary')); + echo $this->Form->end(); +?> + +
+ + +element('side_menu', array('menuList' => 'event-collection', 'menuItem' => 'addSTIX')); +?> + + \ No newline at end of file diff --git a/app/composer.json b/app/composer.json index 247ee1982..6d71704eb 100644 --- a/app/composer.json +++ b/app/composer.json @@ -2,7 +2,7 @@ "prefer-stable": true, "minimum-stability": "dev", "require": { - "kamisama/cake-resque": "@stable", + "kamisama/cake-resque": "4.1.2", "pear/crypt_gpg": "@stable", "pear/net_geoip": "@dev" }, From 070d94b8b933ad74f1e50a0f5cf979c502669ee3 Mon Sep 17 00:00:00 2001 From: aksha Date: Fri, 27 Jul 2018 10:24:09 +0100 Subject: [PATCH 002/907] Added Jquery UI and expansion pannels to the file analysis interface --- app/View/Events/upload_analysis_file.ctp | 49 +++++++++++++----------- app/View/Layouts/default.ctp | 2 + 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/app/View/Events/upload_analysis_file.ctp b/app/View/Events/upload_analysis_file.ctp index 732dfb56b..985b14c23 100644 --- a/app/View/Events/upload_analysis_file.ctp +++ b/app/View/Events/upload_analysis_file.ctp @@ -22,21 +22,28 @@ echo $this->Form->button(__('Upload'), array('class' => 'btn btn-primary')); echo $this->Form->end(); ?> + element('side_menu', array('menuList' => 'event', 'menuItem' => 'addAttribute', 'event' => $event)); ?>