From 3d8a3919d0325bee93e06804d2bf319673b33ecd Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Wed, 31 Jan 2024 16:26:59 +0100 Subject: [PATCH] fix: [internal] Raise size for access_logs action column --- app/Model/AppModel.php | 20 ++++++++++++++++---- db_schema.json | 6 +++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/Model/AppModel.php b/app/Model/AppModel.php index 4f0ea66e2..0d6b4f53f 100644 --- a/app/Model/AppModel.php +++ b/app/Model/AppModel.php @@ -86,7 +86,7 @@ class AppModel extends Model 99 => false, 100 => false, 101 => false, 102 => false, 103 => false, 104 => false, 105 => false, 106 => false, 107 => false, 108 => false, 109 => false, 110 => false, 111 => false, 112 => false, 113 => true, 114 => false, 115 => false, 116 => false, - 117 => false, 118 => false + 117 => false, 118 => false, 119 => false, ); const ADVANCED_UPDATES_DESCRIPTION = array( @@ -2006,6 +2006,9 @@ class AppModel extends Model case 118: $sqlArray[] = "ALTER TABLE `event_reports` MODIFY `content` mediumtext;"; break; + case 119: + $sqlArray[] = "ALTER TABLE `access_logs` MODIFY `action` varchar(191) NOT NULL"; + break; case 'fixNonEmptySharingGroupID': $sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; $sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; @@ -4018,6 +4021,12 @@ class AppModel extends Model */ public function _remoteIp() { + static $remoteIp; + + if ($remoteIp) { + return $remoteIp; + } + $clientIpHeader = Configure::read('MISP.log_client_ip_header'); if ($clientIpHeader && isset($_SERVER[$clientIpHeader])) { $headerValue = $_SERVER[$clientIpHeader]; @@ -4025,9 +4034,12 @@ class AppModel extends Model if (($commaPos = strpos($headerValue, ',')) !== false) { $headerValue = substr($headerValue, 0, $commaPos); } - return trim($headerValue); + $remoteIp = trim($headerValue); + } else { + $remoteIp = $_SERVER['REMOTE_ADDR'] ?? null; } - return $_SERVER['REMOTE_ADDR'] ?? null; + + return $remoteIp; } public function find($type = 'first', $query = array()) @@ -4060,7 +4072,7 @@ class AppModel extends Model return false; } - public function checkParam($param) + private function checkParam($param) { return preg_match('/^[\w\_\-\. ]+$/', $param); } diff --git a/db_schema.json b/db_schema.json index 7a19047c6..b32833fed 100644 --- a/db_schema.json +++ b/db_schema.json @@ -115,10 +115,10 @@ "column_name": "action", "is_nullable": "NO", "data_type": "varchar", - "character_maximum_length": "20", + "character_maximum_length": "191", "numeric_precision": null, "collation_name": "utf8mb4_unicode_ci", - "column_type": "varchar(20)", + "column_type": "varchar(191)", "column_default": null, "extra": "" }, @@ -9702,5 +9702,5 @@ "uuid": false } }, - "db_version": "118" + "db_version": "119" } \ No newline at end of file