From cf21025cd7630510ce2072b174c9ee0db8b0a0a7 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Wed, 3 Aug 2022 09:59:06 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03390=20-=20Cleanup=20"debug"=20param=20r?= =?UTF-8?q?emains=20by=20moving=20logs=20to=20debug=20level=20/=20portal?= =?UTF-8?q?=20channel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...AggregatePageBrickController.class.inc.php | 10 +++--- .../portal/src/Helper/SecurityHelper.php | 33 ++++--------------- .../portal/templates/layout.html.twig | 2 +- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/AggregatePageBrickController.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/AggregatePageBrickController.class.inc.php index 4fde47639a..77d46afb3d 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Controller/AggregatePageBrickController.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/AggregatePageBrickController.class.inc.php @@ -22,9 +22,11 @@ namespace Combodo\iTop\Portal\Controller; use Combodo\iTop\Portal\Brick\BrickNotFoundException; use IssueLog; +use LogChannels; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpException; +use UserRights; /** @@ -91,10 +93,10 @@ class AggregatePageBrickController extends BrickController } catch (BrickNotFoundException $oException) { - if ($this->get('kernel')->isDebug()) - { - IssueLog::Warning('AggregatePageBrick: Could not display "'.$sBrickId.'", either wrong id or user profile not allowed'); - } + IssueLog::Debug('AggregatePageBrick: Could not display brick, either wrong id or user profile not allowed', LogChannels::PORTAL, [ + 'brick_id' => $sBrickId, + 'user_profiles' => UserRights::ListProfiles(), + ]); continue; } diff --git a/datamodels/2.x/itop-portal-base/portal/src/Helper/SecurityHelper.php b/datamodels/2.x/itop-portal-base/portal/src/Helper/SecurityHelper.php index 49dadd89ae..5b8122df1e 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Helper/SecurityHelper.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Helper/SecurityHelper.php @@ -20,6 +20,7 @@ namespace Combodo\iTop\Portal\Helper; +use LogChannels; use UserRights; use IssueLog; use MetaModel; @@ -95,11 +96,7 @@ class SecurityHelper // Checking action type if (!in_array($sAction, array(UR_ACTION_READ, UR_ACTION_MODIFY, UR_ACTION_CREATE))) { - if ($this->bDebug) - { - IssueLog::Info($sDebugTracePrefix.' as the action value could not be understood ('.UR_ACTION_READ.'/'.UR_ACTION_MODIFY.'/'.UR_ACTION_CREATE.' expected'); - } - + IssueLog::Debug($sDebugTracePrefix.' as the action value could not be understood ('.UR_ACTION_READ.'/'.UR_ACTION_MODIFY.'/'.UR_ACTION_CREATE.' expected', LogChannels::PORTAL); return false; } @@ -116,11 +113,7 @@ class SecurityHelper $oScopeQuery = $this->oScopeValidator->GetScopeFilterForProfiles(UserRights::ListProfiles(), $sObjectClass, $sScopeAction); if ($oScopeQuery === null) { - if ($this->bDebug) - { - IssueLog::Info($sDebugTracePrefix.' as there was no scope defined for action '.$sScopeAction.' and profiles '.implode('/', UserRights::ListProfiles())); - } - + IssueLog::Debug($sDebugTracePrefix.' as there was no scope defined for action '.$sScopeAction.' and profiles '.implode('/', UserRights::ListProfiles()), LogChannels::PORTAL); return false; } // - If action != create we do some additionnal checks @@ -134,11 +127,7 @@ class SecurityHelper { if (static::$aAllowedScopeObjectsCache[$sScopeAction][$sObjectClass][$sObjectId] === false) { - if ($this->bDebug) - { - IssueLog::Info($sDebugTracePrefix.' as it was denied in the scope objects cache'); - } - + IssueLog::Debug($sDebugTracePrefix.' as it was denied in the scope objects cache', LogChannels::PORTAL); return false; } } @@ -163,11 +152,7 @@ class SecurityHelper // Updating cache static::$aAllowedScopeObjectsCache[$sScopeAction][$sObjectClass][$sObjectId] = false; - if ($this->bDebug) - { - IssueLog::Info($sDebugTracePrefix.' as there was no result for the following scope query : '.$oScopeQuery->ToOQL(true)); - } - + IssueLog::Debug($sDebugTracePrefix.' as there was no result for the following scope query : '.$oScopeQuery->ToOQL(true), LogChannels::PORTAL); return false; } @@ -180,13 +165,9 @@ class SecurityHelper // Checking reading security layer. The object could be listed, check if it is actually allowed to view it if (UserRights::IsActionAllowed($sObjectClass, $sAction) == UR_ALLOWED_NO) { - // For security reasons, we don't want to give the user too many informations on why he cannot access the object. + // For security reasons, we don't want to give the user too many information on why he cannot access the object. //throw new SecurityException('User not allowed to view this object', array('class' => $sObjectClass, 'id' => $sObjectId)); - if ($this->bDebug) - { - IssueLog::Info($sDebugTracePrefix.' as the user is not allowed to access this object according to the datamodel security (cf. Console settings)'); - } - + IssueLog::Debug($sDebugTracePrefix.' as the user is not allowed to access this object according to the datamodel security (cf. Console settings)', LogChannels::PORTAL); return false; } diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig index 56b0aa4044..b6b269688b 100644 --- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig @@ -312,7 +312,7 @@ {% block pNavigationSideMenuLogo %} {# This is a debug helper to know in which screen size we are #} {% if app['kernel'].debug == true %} -
Debug : Taille
+
Debug: Screen size
{% endif %} {{ app['combodo.portal.instance.conf'].properties.name|dict_s }}