Merge remote-tracking branch 'origin/support/3.0' into support/3.1

# Conflicts:
#	core/kpi.class.inc.php
This commit is contained in:
Eric Espie
2023-07-19 10:53:09 +02:00
3 changed files with 24 additions and 21 deletions

View File

@@ -918,6 +918,11 @@ class RuntimeDashboard extends Dashboard
{ {
$bCustomized = false; $bCustomized = false;
$sDashboardFileSanitized = utils::RealPath($sDashboardFile, APPROOT);
if (false === $sDashboardFileSanitized) {
throw new SecurityException('Invalid dashboard file !');
}
// Search for an eventual user defined dashboard // Search for an eventual user defined dashboard
$oUDSearch = new DBObjectSearch('UserDashboard'); $oUDSearch = new DBObjectSearch('UserDashboard');
$oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '='); $oUDSearch->AddCondition('user_id', UserRights::GetUserId(), '=');
@@ -929,7 +934,7 @@ class RuntimeDashboard extends Dashboard
$sDashboardDefinition = $oUserDashboard->Get('contents'); $sDashboardDefinition = $oUserDashboard->Get('contents');
$bCustomized = true; $bCustomized = true;
} else { } else {
$sDashboardDefinition = @file_get_contents($sDashboardFile); $sDashboardDefinition = @file_get_contents($sDashboardFileSanitized);
} }
@@ -937,7 +942,7 @@ class RuntimeDashboard extends Dashboard
$oDashboard = new RuntimeDashboard($sDashBoardId); $oDashboard = new RuntimeDashboard($sDashBoardId);
$oDashboard->FromXml($sDashboardDefinition); $oDashboard->FromXml($sDashboardDefinition);
$oDashboard->SetCustomFlag($bCustomized); $oDashboard->SetCustomFlag($bCustomized);
$oDashboard->SetDefinitionFile($sDashboardFile); $oDashboard->SetDefinitionFile($sDashboardFileSanitized);
} else { } else {
$oDashboard = null; $oDashboard = null;
} }

View File

@@ -1,29 +1,14 @@
<?php <?php
// Copyright (C) 2010-2023 Combodo SARL /**
// * @copyright Copyright (C) 2010-2023 Combodo SARL
// This file is part of iTop. * @license http://opensource.org/licenses/AGPL-3.0
// */
// iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Core\Kpi\KpiLogData; use Combodo\iTop\Core\Kpi\KpiLogData;
use Combodo\iTop\Service\Module\ModuleService; use Combodo\iTop\Service\Module\ModuleService;
/** /**
* Measures operations duration, memory usage, etc. (and some other KPIs) * Measures operations duration, memory usage, etc. (and some other KPIs)
*
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/ */
class ExecutionKPI class ExecutionKPI
@@ -355,6 +340,10 @@ class ExecutionKPI
{ {
global $fItopStarted; global $fItopStarted;
if (!self::IsEnabled()) {
return;
}
$aNewEntry = null; $aNewEntry = null;
$fStarted = $this->m_fStarted; $fStarted = $this->m_fStarted;
@@ -417,6 +406,10 @@ class ExecutionKPI
public function ComputeStatsForExtension($object, $sMethod) public function ComputeStatsForExtension($object, $sMethod)
{ {
if (!self::IsEnabled()) {
return;
}
$sSignature = ModuleService::GetInstance()->GetModuleMethodSignature($object, $sMethod); $sSignature = ModuleService::GetInstance()->GetModuleMethodSignature($object, $sMethod);
if (utils::StartsWith($sSignature, '[')) { if (utils::StartsWith($sSignature, '[')) {
$this->ComputeStats('Extension', $sSignature); $this->ComputeStats('Extension', $sSignature);
@@ -425,6 +418,10 @@ class ExecutionKPI
public function ComputeStats($sOperation, $sArguments) public function ComputeStats($sOperation, $sArguments)
{ {
if (!self::IsEnabled()) {
return;
}
$fDuration = 0; $fDuration = 0;
if (self::$m_bEnabled_Duration) { if (self::$m_bEnabled_Duration) {
$fStopped = MyHelpers::getmicrotime(); $fStopped = MyHelpers::getmicrotime();

View File

@@ -7635,6 +7635,7 @@ abstract class MetaModel
'ModuleHandlerApiInterface', 'ModuleHandlerApiInterface',
'iNewsroomProvider', 'iNewsroomProvider',
'iModuleExtension', 'iModuleExtension',
'iKPILoggerExtension',
]; ];
foreach ($aInterfaces as $sInterface) { foreach ($aInterfaces as $sInterface) {
self::$m_aExtensionClassNames[$sInterface] = array(); self::$m_aExtensionClassNames[$sInterface] = array();