From 1bed11ea7d4685acf45e8dd317ff4a8f564593ce Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 2 Jan 2024 16:55:22 +0100 Subject: [PATCH 1/4] fix: [internal] OIDC log --- app/Plugin/OidcAuth/Lib/Oidc.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Plugin/OidcAuth/Lib/Oidc.php b/app/Plugin/OidcAuth/Lib/Oidc.php index 9e6dd85f9..11718a46b 100644 --- a/app/Plugin/OidcAuth/Lib/Oidc.php +++ b/app/Plugin/OidcAuth/Lib/Oidc.php @@ -521,15 +521,16 @@ class Oidc */ private function log($username, $message) { - $sessionId = substr(session_id(), 0, 6); - $ip = $this->User->_remoteIp(); + $log = $username ? "OIDC user `$username`" : "OIDC"; - if ($username) { - $message = "OIDC user `$username` [$ip;$sessionId] – $message"; + if (PHP_SAPI !== 'cli') { + $sessionId = substr(session_id(), 0, 6); + $ip = $this->User->_remoteIp(); + $log .= " [$ip;$sessionId] - $message"; } else { - $message = "OIDC [$ip;$sessionId] – $message"; + $log .= " - $message"; } - CakeLog::info($message); + CakeLog::info($log); } } From b047fe2f74b42f3e413ad7f97cf92ec49b4c805f Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 2 Jan 2024 17:49:29 +0100 Subject: [PATCH 2/4] chg: [UI] Show choosen when importing STIX --- app/View/Events/upload_stix.ctp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/View/Events/upload_stix.ctp b/app/View/Events/upload_stix.ctp index ef49d101e..84ee2c1de 100644 --- a/app/View/Events/upload_stix.ctp +++ b/app/View/Events/upload_stix.ctp @@ -27,9 +27,6 @@ 'label' => __('Distribution ') . $distributionFormInfo, 'selected' => $initialDistribution, )); -?> -
Form->input('publish', array( @@ -52,7 +48,7 @@ 'label' => __('Include the original imported file as attachment') )); if ($me['Role']['perm_site_admin'] || $me['Role']['perm_galaxy_editor']) { - $galaxiesFormInfo = $this-> element( + $galaxiesFormInfo = $this->element( 'genericElements/Form/formInfo', [ 'field' => [ @@ -101,11 +97,8 @@ \ No newline at end of file From d6c0514644b9ad6e94d99d45cc9b38cb3ceec2c5 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 2 Jan 2024 17:54:17 +0100 Subject: [PATCH 3/4] fix: [internal] Undefined index sharing_group_id when uploading stix file --- app/Controller/EventsController.php | 2 +- app/Model/Event.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 47c266691..3bb9024b7 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -2469,7 +2469,7 @@ class EventsController extends AppController $original_file, $this->data['Event']['publish'], $this->data['Event']['distribution'], - $this->data['Event']['sharing_group_id'], + $this->data['Event']['sharing_group_id'] ?? null, $this->data['Event']['galaxies_handling'], $debug ); diff --git a/app/Model/Event.php b/app/Model/Event.php index 481186951..169cea3f3 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -5926,7 +5926,7 @@ class Event extends AppModel * @param string $originalFile * @param bool $publish * @param int $distribution - * @param int $sharingGroupId + * @param int|null $sharingGroupId * @param bool $galaxiesAsTags * @param bool $debug * @return int|string|array @@ -5996,7 +5996,7 @@ class Event extends AppModel * @param string $stixVersion * @param string $file * @param int $distribution - * @param int $sharingGroupId + * @param int|null $sharingGroupId * @param bool $galaxiesAsTags * @param bool $debug * @return array From 67b393ea7b417d25af69f84376deeafd1ccc475e Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Wed, 3 Jan 2024 08:55:29 +0100 Subject: [PATCH 4/4] chg: [internal] Move field description to controller --- app/Controller/EventsController.php | 24 ++++++++++++++++++++---- app/Model/Event.php | 20 -------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index 3bb9024b7..573ae6612 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -2501,15 +2501,31 @@ class EventsController extends AppController foreach ($distributionLevels as $key => $value) { $fieldDesc['distribution'][$key] = $this->Event->distributionDescriptions[$key]['formdesc']; } - $debugOptions = $this->Event->debugOptions; + + $debugOptions = [ + 0 => __('Standard debugging'), + 1 => __('Advanced debugging'), + ]; + $debugDescriptions = [ + 0 => __('The critical errors are logged in the usual log file.'), + 1 => __('All the errors and warnings are logged in the usual log file.'), + ]; + $galaxiesOptions = [ + 0 => __('As MISP standard format'), + 1 => __('As tag names'), + ]; + $galaxiesOptionsDescriptions = [ + 0 => __('Galaxies and Clusters are passed as MISP standard format. New generic Galaxies and Clusters are created when there is no match with existing ones.'), + 1 => __('Galaxies are passed as tags and there is only a simple search with existing galaxy tag names.'), + ]; + $this->set('debugOptions', $debugOptions); foreach ($debugOptions as $key => $value) { - $fieldDesc['debug'][$key] = $this->Event->debugDescriptions[$key]; + $fieldDesc['debug'][$key] = $debugDescriptions[$key]; } - $galaxiesOptions = $this->Event->galaxiesOptions; $this->set('galaxiesOptions', $galaxiesOptions); foreach ($galaxiesOptions as $key => $value) { - $fieldDesc['galaxies_handling'][$key] = $this->Event->galaxiesOptionsDescriptions[$key]; + $fieldDesc['galaxies_handling'][$key] = $galaxiesOptionsDescriptions[$key]; } $this->set('sharingGroups', $sgs); $this->set('fieldDesc', $fieldDesc); diff --git a/app/Model/Event.php b/app/Model/Event.php index 169cea3f3..d6b9ba4c7 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -63,11 +63,6 @@ class Event extends AppModel 2 => array('desc' => '*Complete* means that the event\'s creation is complete', 'formdesc' => 'The event creator considers the analysis complete') ); - public $debugDescriptions = array( - 0 => 'The critical errors are logged in the usual log file.', - 1 => 'All the errors and warnings are logged in the usual log file.' - ); - public $distributionDescriptions = [ self::DISTRIBUTION_ORGANISATION => [ 'desc' => 'This field determines the current distribution of the event', @@ -91,16 +86,6 @@ class Event extends AppModel ], ]; - public $galaxiesOptionsDescriptions = array( - 0 => 'Galaxies and Clusters are passed as MISP standard format. New generic Galaxies and Clusters are created when there is no match with existing ones.', - 1 => 'Galaxies are passed as tags and there is only a simple search with existing galaxy tag names.' - ); - - public $debugOptions = array( - 0 => 'Standard debugging', - 1 => 'Advanced debugging' - ); - public $distributionLevels = [ self::DISTRIBUTION_ORGANISATION => 'Your organisation only', self::DISTRIBUTION_COMMUNITY => 'This community only', @@ -109,11 +94,6 @@ class Event extends AppModel self::DISTRIBUTION_SHARING_GROUP => 'Sharing group', ]; - public $galaxiesOptions = array( - 0 => 'As MISP standard format', - 1 => 'As tag names' - ); - public $analysisLevels = array( 0 => 'Initial', 1 => 'Ongoing', 2 => 'Completed' );