From b133f52d83664398da488ea2305eca2f614fb8ed Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 8 Apr 2026 20:27:03 +0200 Subject: [PATCH] fix merge fix merge --- .../src/Controller/HubController.php | 19 +++++++++-- lib/autoload.php | 5 ++- lib/composer/autoload_psr4.php | 2 +- lib/composer/autoload_static.php | 4 +-- lib/composer/platform_check.php | 5 +-- .../InstallationChoicesToModuleConverter.php | 2 +- setup/sequencers/StepSequencer.php | 5 +-- .../src/BaseTestCase/ItopDataTestCase.php | 33 +++++++++---------- .../setup/ApplicationInstallSequencerFake.php | 0 9 files changed, 47 insertions(+), 28 deletions(-) delete mode 100644 tests/php-unit-tests/unitary-tests/setup/ApplicationInstallSequencerFake.php diff --git a/datamodels/2.x/itop-hub-connector/src/Controller/HubController.php b/datamodels/2.x/itop-hub-connector/src/Controller/HubController.php index 09a3c4b26..fdbe2fbc8 100644 --- a/datamodels/2.x/itop-hub-connector/src/Controller/HubController.php +++ b/datamodels/2.x/itop-hub-connector/src/Controller/HubController.php @@ -123,8 +123,7 @@ class HubController throw new SecurityException(Dict::S('iTopHub:FailAuthent')); } // First step: prepare the datamodel, if it fails, roll-back - $aSelectedExtensionCodes = utils::ReadParam('extension_codes', []); - $aSelectedExtensionDirs = utils::ReadParam('extension_dirs', []); + $aSelectedExtensionDirs = utils::ReadParam('extension_dirs', [], false, utils::ENUM_SANITIZATION_FILTER_MODULE_CODE); $oRuntimeEnv = new HubRunTimeEnvironment('production', false); // use a temp environment: production-build $oRuntimeEnv->MoveSelectedExtensions(APPROOT.'/data/downloaded-extensions/', $aSelectedExtensionDirs); @@ -161,6 +160,22 @@ class HubController // Everything happening below is based on env-production $oRuntimeEnv = new RunTimeEnvironment('production', true); + try { + $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); + if (!file_exists(utils::GetDataPath().'hub/compile_authent') || $sAuthent !== file_get_contents(utils::GetDataPath().'hub/compile_authent')) { + throw new SecurityException(Dict::S('iTopHub:FailAuthent')); + } + } catch (Exception $e) { + if (file_exists(utils::GetDataPath().'hub/compile_authent')) { + unlink(utils::GetDataPath().'hub/compile_authent'); + } + // Note: at this point, the dictionnary is not necessarily loaded + SetupLog::Error(get_class($e).': '.Dict::S('iTopHub:ConfigurationSafelyReverted')."\n".$e->getMessage()); + SetupLog::Error('Debug trace: '.$e->getTraceAsString()); + $this->ReportError($e->getMessage(), $e->getCode()); + return; + } + try { SetupLog::Info('Move to production starts...'); $sAuthent = utils::ReadParam('authent', '', false, 'raw_data'); diff --git a/lib/autoload.php b/lib/autoload.php index 9861c4c24..1b6f5ac12 100644 --- a/lib/autoload.php +++ b/lib/autoload.php @@ -14,7 +14,10 @@ if (PHP_VERSION_ID < 50600) { echo $err; } } - throw new RuntimeException($err); + trigger_error( + $err, + E_USER_ERROR + ); } require_once __DIR__ . '/composer/autoload_real.php'; diff --git a/lib/composer/autoload_psr4.php b/lib/composer/autoload_psr4.php index d71f96f11..15036b1a5 100644 --- a/lib/composer/autoload_psr4.php +++ b/lib/composer/autoload_psr4.php @@ -62,7 +62,7 @@ return array( 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), 'Pelago\\Emogrifier\\' => array($vendorDir . '/pelago/emogrifier/src'), - 'League\\OAuth2\\Client\\' => array($vendorDir . '/league/oauth2-google/src', $vendorDir . '/league/oauth2-client/src'), + 'League\\OAuth2\\Client\\' => array($vendorDir . '/league/oauth2-client/src', $vendorDir . '/league/oauth2-google/src'), 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 8007c561c..88185ee1a 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -345,8 +345,8 @@ class ComposerStaticInitfc0e9e9dea11dcbb6272414776c30685 ), 'League\\OAuth2\\Client\\' => array ( - 0 => __DIR__ . '/..' . '/league/oauth2-google/src', - 1 => __DIR__ . '/..' . '/league/oauth2-client/src', + 0 => __DIR__ . '/..' . '/league/oauth2-client/src', + 1 => __DIR__ . '/..' . '/league/oauth2-google/src', ), 'GuzzleHttp\\Psr7\\' => array ( diff --git a/lib/composer/platform_check.php b/lib/composer/platform_check.php index 72145773d..dee74e173 100644 --- a/lib/composer/platform_check.php +++ b/lib/composer/platform_check.php @@ -36,7 +36,8 @@ if ($issues) { echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; } } - throw new \RuntimeException( - 'Composer detected issues in your platform: ' . implode(' ', $issues) + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR ); } diff --git a/setup/moduleinstallation/InstallationChoicesToModuleConverter.php b/setup/moduleinstallation/InstallationChoicesToModuleConverter.php index ac283375f..9a1ace949 100644 --- a/setup/moduleinstallation/InstallationChoicesToModuleConverter.php +++ b/setup/moduleinstallation/InstallationChoicesToModuleConverter.php @@ -82,7 +82,7 @@ class InstallationChoicesToModuleConverter return ModuleDiscovery::GetAllModules($aSearchDirs); } - private function FindInstalledPackageModules(array $aPackageModules, array $aInstallationChoices, array $aInstallationDescription = null): array + private function FindInstalledPackageModules(array $aPackageModules, array $aInstallationChoices, ?array $aInstallationDescription = null): array { $aInstalledModules = []; diff --git a/setup/sequencers/StepSequencer.php b/setup/sequencers/StepSequencer.php index 11bd4757e..07474d5fa 100644 --- a/setup/sequencers/StepSequencer.php +++ b/setup/sequencers/StepSequencer.php @@ -38,9 +38,10 @@ abstract class StepSequencer { if (is_null($oRunTimeEnvironment)) { $sEnvironment = $oParams->Get('target_env', 'production'); - $oRunTimeEnvironment = new RunTimeEnvironment($sEnvironment, false); + $this->oRunTimeEnvironment = new RunTimeEnvironment($sEnvironment, false); + } else { + $this->oRunTimeEnvironment = $oRunTimeEnvironment; } - $this->oRunTimeEnvironment = $oRunTimeEnvironment; $this->oParams = $oParams; diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index 9845dd929..e5f9501c5 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -1556,23 +1556,6 @@ abstract class ItopDataTestCase extends ItopTestCase @unlink($this->sConfigTmpBackupFile); } - protected function AddLoginModeAndSaveConfiguration(string $sLoginMode): void - { - $aAllowedLoginTypes = $this->oiTopConfig->GetAllowedLoginTypes(); - if (!in_array($sLoginMode, $aAllowedLoginTypes)) { - $aAllowedLoginTypes[] = $sLoginMode; - $this->oiTopConfig->SetAllowedLoginTypes($aAllowedLoginTypes); - $this->SaveItopConfFile(); - } - } - - protected function SaveItopConfFile(): void - { - @chmod($this->oiTopConfig->GetLoadedFile(), 0770); - $this->oiTopConfig->WriteToFile(); - @chmod($this->oiTopConfig->GetLoadedFile(), 0440); - } - public function AssertPreviousAndCurrentInstallationAreEquivalent() { $aPreviousInstallations = ModuleInstallationRepository::GetInstance()->GetPreviousModuleInstallationsByOffset(1); @@ -1599,4 +1582,20 @@ abstract class ItopDataTestCase extends ItopTestCase asort($aRes); return $aRes; } + + protected function AddLoginModeAndSaveConfiguration(string $sLoginMode): void + { + $aAllowedLoginTypes = $this->oiTopConfig->GetAllowedLoginTypes(); + if (!in_array($sLoginMode, $aAllowedLoginTypes)) { + $aAllowedLoginTypes[] = $sLoginMode; + $this->oiTopConfig->SetAllowedLoginTypes($aAllowedLoginTypes); + $this->SaveItopConfFile(); + } + } + protected function SaveItopConfFile(): void + { + @chmod($this->oiTopConfig->GetLoadedFile(), 0770); + $this->oiTopConfig->WriteToFile(); + @chmod($this->oiTopConfig->GetLoadedFile(), 0440); + } } diff --git a/tests/php-unit-tests/unitary-tests/setup/ApplicationInstallSequencerFake.php b/tests/php-unit-tests/unitary-tests/setup/ApplicationInstallSequencerFake.php deleted file mode 100644 index e69de29bb..000000000