Compare commits

...

11 Commits

Author SHA1 Message Date
denis.flaven@combodo.com
affed69999 Version number bump. 2025-02-07 10:09:48 +01:00
denis.flaven@combodo.com
d5754fc568 N°8135 - Bump datamodel version. 2025-01-31 17:04:56 +01:00
jf-cbd
44290db312 N°8134 - Portal user profile is broken, regression from 7776 2025-01-28 10:23:44 +01:00
jf-cbd
c49ceae75e Fix HandleForm call 2025-01-21 16:46:15 +01:00
jf-cbd
8980f627e9 Fix format 2025-01-21 12:09:06 +01:00
jf-cbd
160bfd714b N°7776 remove twig from ajax calls 2025-01-20 15:41:22 +01:00
jf-cbd
8d58372074 Update unattended installation script documentation 2025-01-16 17:13:26 +01:00
Eric Espie
37fc1a5723 N°7810 - security hardening 2024-12-27 09:04:28 +01:00
jf-cbd
95aa444ee6 Security hardening 2024-12-13 16:48:13 +01:00
jf-cbd
f5de808c7c Security hardening (#685)
* security hardening
2024-12-13 15:09:18 +01:00
Benjamin Dalsass
e03033ce52 N°7219 - Fatal error following dashboard modification when dashboard title contains an é 2024-11-27 09:40:22 +01:00
48 changed files with 673 additions and 627 deletions

View File

@@ -1193,12 +1193,12 @@ EOF
$sOkButtonLabel = Dict::S('UI:Button:Save'); $sOkButtonLabel = Dict::S('UI:Button:Save');
$sCancelButtonLabel = Dict::S('UI:Button:Cancel'); $sCancelButtonLabel = Dict::S('UI:Button:Cancel');
$sId = utils::HtmlEntities($this->sId); $sId = json_encode($this->sId);
$sLayoutClass = utils::HtmlEntities($this->sLayoutClass); $sLayoutClass = json_encode($this->sLayoutClass);
$sAutoReload = $this->bAutoReload ? 'true' : 'false'; $sAutoReload = $this->bAutoReload ? 'true' : 'false';
$sAutoReloadSec = (string) $this->iAutoReloadSec; $sAutoReloadSec = (string) $this->iAutoReloadSec;
$sTitle = utils::HtmlEntities($this->sTitle); $sTitle = json_encode($this->sTitle);
$sFile = utils::HtmlEntities($this->GetDefinitionFile()); $sFile = json_encode($this->GetDefinitionFile());
$sUrl = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php'; $sUrl = utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php';
$sReloadURL = $this->GetReloadURL(); $sReloadURL = $this->GetReloadURL();
@@ -1250,15 +1250,15 @@ $('#dashboard_editor').dialog({
}); });
$('#dashboard_editor .ui-layout-center').runtimedashboard({ $('#dashboard_editor .ui-layout-center').runtimedashboard({
dashboard_id: '$sId', dashboard_id: $sId,
layout_class: '$sLayoutClass', layout_class: $sLayoutClass,
title: '$sTitle', title: $sTitle,
auto_reload: $sAutoReload, auto_reload: $sAutoReload,
auto_reload_sec: $sAutoReloadSec, auto_reload_sec: $sAutoReloadSec,
submit_to: '$sUrl', submit_to: '$sUrl',
submit_parameters: {operation: 'save_dashboard', file: '$sFile', extra_params: $sJSExtraParams, reload_url: '$sReloadURL'}, submit_parameters: {operation: 'save_dashboard', file: $sFile, extra_params: $sJSExtraParams, reload_url: '$sReloadURL'},
render_to: '$sUrl', render_to: '$sUrl',
render_parameters: {operation: 'render_dashboard', file: '$sFile', extra_params: $sJSExtraParams, reload_url: '$sReloadURL'}, render_parameters: {operation: 'render_dashboard', file: $sFile, extra_params: $sJSExtraParams, reload_url: '$sReloadURL'},
new_dashlet_parameters: {operation: 'new_dashlet'} new_dashlet_parameters: {operation: 'new_dashlet'}
}); });

View File

@@ -14,7 +14,7 @@ define('APPCONF', APPROOT.'conf/');
* @used-by utils::GetItopVersionWikiSyntax() * @used-by utils::GetItopVersionWikiSyntax()
* @used-by iTopModulesPhpVersionIntegrationTest * @used-by iTopModulesPhpVersionIntegrationTest
*/ */
define('ITOP_CORE_VERSION', '2.7.11'); define('ITOP_CORE_VERSION', '2.7.12');
require_once APPROOT.'bootstrap.inc.php'; require_once APPROOT.'bootstrap.inc.php';

View File

@@ -17,7 +17,7 @@
*/ */
// Beware the version number MUST be enclosed with quotes otherwise v2.3.0 becomes v2 0.3 .0 // Beware the version number MUST be enclosed with quotes otherwise v2.3.0 becomes v2 0.3 .0
$version: "v2.7.11"; $version: "v2.7.12";
$approot-relative: "../../../../../" !default; // relative to env-***/branding/themes/***/main.css $approot-relative: "../../../../../" !default; // relative to env-***/branding/themes/***/main.css
// Base colors // Base colors

View File

@@ -5,7 +5,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-cas/2.7.11', 'authent-cas/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -27,7 +27,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-external/2.7.11', 'authent-external/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -9,7 +9,7 @@ if (function_exists('ldap_connect'))
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-ldap/2.7.11', 'authent-ldap/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-local/2.7.11', 'authent-local/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -24,7 +24,7 @@
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'combodo-db-tools/2.7.11', 'combodo-db-tools/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -19,7 +19,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-attachments/2.7.11', 'itop-attachments/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-backup/2.7.11', 'itop-backup/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-bridge-virtualization-storage/2.7.11', 'itop-bridge-virtualization-storage/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-change-mgmt-itil/2.7.11', 'itop-change-mgmt-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-change-mgmt/2.7.11', 'itop-change-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-config-mgmt/2.7.11', 'itop-config-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-config/2.7.11', 'itop-config/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -24,7 +24,7 @@
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-core-update/2.7.11', 'itop-core-update/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -18,7 +18,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-datacenter-mgmt/2.7.11', 'itop-datacenter-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -25,7 +25,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-endusers-devices/2.7.11', 'itop-endusers-devices/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -24,7 +24,7 @@
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-files-information/2.7.11', 'itop-files-information/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -6,7 +6,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-full-itil/2.7.11', 'itop-full-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -5,7 +5,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-hub-connector/2.7.11', 'itop-hub-connector/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-incident-mgmt-itil/2.7.11', 'itop-incident-mgmt-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-knownerror-mgmt/2.7.11', 'itop-knownerror-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -5,7 +5,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-oauth-client/2.7.11', 'itop-oauth-client/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -20,7 +20,7 @@
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-portal-base/2.7.11', array( 'itop-portal-base/2.7.12', array(
// Identification // Identification
'label' => 'Portal Development Library', 'label' => 'Portal Development Library',
'category' => 'Portal', 'category' => 'Portal',

View File

@@ -15,6 +15,11 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with iTop. If not, see <http://www.gnu.org/licenses/> # along with iTop. If not, see <http://www.gnu.org/licenses/>
p_user_profile_brick_edit_person:
path: '/user/edit_person'
defaults:
_controller: 'Combodo\iTop\Portal\Controller\UserProfileBrickController::EditPerson'
p_user_profile_brick: p_user_profile_brick:
path: '/user/{sBrickId}' path: '/user/{sBrickId}'
defaults: defaults:

View File

@@ -1246,7 +1246,12 @@ class ObjectController extends BrickController
$bIgnoreSilos = $oScopeValidator->IsAllDataAllowedForScope(UserRights::ListProfiles(), $sObjectClass); $bIgnoreSilos = $oScopeValidator->IsAllDataAllowedForScope(UserRights::ListProfiles(), $sObjectClass);
$aParams = array('objects_id' => $aObjectIds); $aParams = array('objects_id' => $aObjectIds);
$oSearch = DBObjectSearch::FromOQL("SELECT $sObjectClass WHERE id IN (:objects_id)"); $oSearch = DBObjectSearch::FromOQL("SELECT $sObjectClass WHERE id IN (:objects_id)");
if ($bIgnoreSilos === true) if (!$oScopeValidator->AddScopeToQuery($oSearch, $sObjectClass)
) {
IssueLog::Warning(__METHOD__ . ' at line ' . __LINE__ . ' : User #' . UserRights::GetUserId() . ' not allowed to read ' . $sObjectClass . ' object.');
throw new HttpException(Response::HTTP_NOT_FOUND, Dict::S('UI:ObjectDoesNotExist'));
}
if ($bIgnoreSilos === true)
{ {
$oSearch->AllowAllData(); $oSearch->AllowAllData();
} }

View File

@@ -35,7 +35,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use UserRights; use UserRights;
use utils; use utils;
use Dict;
/** /**
* Class UserProfileBrickController * Class UserProfileBrickController
* *
@@ -66,34 +66,9 @@ class UserProfileBrickController extends BrickController
$oRequestManipulator = $this->get('request_manipulator'); $oRequestManipulator = $this->get('request_manipulator');
/** @var \Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper $ObjectFormHandler */ /** @var \Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper $ObjectFormHandler */
$ObjectFormHandler = $this->get('object_form_handler'); $ObjectFormHandler = $this->get('object_form_handler');
/** @var \Combodo\iTop\Portal\Brick\BrickCollection $oBrickCollection */ $oBrick = $this->GetBrick($sBrickId);
$oBrickCollection = $this->get('brick_collection');
// If the brick id was not specified, we get the first one registered that is an instance of UserProfileBrick as default $aData = array();
if ($sBrickId === null)
{
/** @var \Combodo\iTop\Portal\Brick\PortalBrick $oTmpBrick */
foreach ($oBrickCollection->GetBricks() as $oTmpBrick)
{
if ($oTmpBrick instanceof UserProfileBrick)
{
$oBrick = $oTmpBrick;
}
}
// We make sure a UserProfileBrick was found
if (!isset($oBrick) || $oBrick === null)
{
$oBrick = new UserProfileBrick();
//throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'UserProfileBrick : Brick could not be loaded as there was no UserProfileBrick loaded in the application.');
}
}
else
{
$oBrick = $oBrickCollection->GetBrickById($sBrickId);
}
$aData = array();
// Setting form mode regarding the demo mode parameter // Setting form mode regarding the demo mode parameter
$bDemoMode = MetaModel::GetConfig()->Get('demo_mode'); $bDemoMode = MetaModel::GetConfig()->Get('demo_mode');
@@ -130,11 +105,12 @@ class UserProfileBrickController extends BrickController
$oCurContact = UserRights::GetContactObject(); $oCurContact = UserRights::GetContactObject();
$sCurContactClass = get_class($oCurContact); $sCurContactClass = get_class($oCurContact);
$sCurContactId = $oCurContact->GetKey(); $sCurContactId = $oCurContact->GetKey();
$aForm = $oBrick->GetForm();
$aForm['submit_endpoint'] = $this->generateUrl('p_user_profile_brick_edit_person', ['sBrickId' => $sBrickId]);
// Preparing forms // Preparing forms
$aData['forms']['contact'] = $ObjectFormHandler->HandleForm($oRequest, $sFormMode, $sCurContactClass, $sCurContactId, $aData['forms']['contact'] = $ObjectFormHandler->HandleForm($oRequest, $sFormMode, $sCurContactClass, $sCurContactId,
$oBrick->GetForm()); $aForm);
$aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $sFormMode); $aData['forms']['preferences'] = $this->HandlePreferencesForm($oRequest, $sFormMode);
// - If user can change password, we display the form // - If user can change password, we display the form
$aData['forms']['password'] = (UserRights::CanChangePassword()) ? $this->HandlePasswordForm($oRequest, $sFormMode) : null; $aData['forms']['password'] = (UserRights::CanChangePassword()) ? $this->HandlePasswordForm($oRequest, $sFormMode) : null;
@@ -150,6 +126,35 @@ class UserProfileBrickController extends BrickController
return $oResponse; return $oResponse;
} }
public function EditPerson(Request $oRequest)
{
/** @var \Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper $oObjectFormHandler */
$oObjectFormHandler = $this->get('object_form_handler');
/** @var \Combodo\iTop\Portal\Helper\SecurityHelper $oSecurityHelper */
$oSecurityHelper = $this->get('security_helper');
$oCurContact = UserRights::GetContactObject();
$sObjectClass = get_class($oCurContact);
$sObjectId = $oCurContact->GetKey();
// Checking security layers
// Warning : This is a dirty quick fix to allow editing its own contact information
$bAllowWrite = ($sObjectClass === 'Person' && $sObjectId == UserRights::GetContactId());
if (!$oSecurityHelper->IsActionAllowed(UR_ACTION_MODIFY, $sObjectClass, $sObjectId) && !$bAllowWrite) {
IssueLog::Warning(__METHOD__ . ' at line ' . __LINE__ . ' : User #' . UserRights::GetUserId() . ' not allowed to modify ' . $sObjectClass . '::' . $sObjectId . ' object.');
throw new HttpException(Response::HTTP_NOT_FOUND, Dict::S('UI:ObjectDoesNotExist'));
}
$aForm = $this->GetBrick()->GetForm();
$aForm['submit_endpoint'] = $this->generateUrl('p_user_profile_brick_edit_person');
$aData = ['sMode' => 'edit'];
$aData['form'] = $oObjectFormHandler->HandleForm($oRequest, $aData['sMode'], $sObjectClass, $sObjectId, $aForm);
return new JsonResponse($aData);
}
/** /**
* @param \Symfony\Component\HttpFoundation\Request $oRequest * @param \Symfony\Component\HttpFoundation\Request $oRequest
* @param string $sFormMode * @param string $sFormMode
@@ -388,4 +393,34 @@ class UserProfileBrickController extends BrickController
return $aFormData; return $aFormData;
} }
/**
* @param $sBrickId
* @return \Combodo\iTop\Portal\Brick\PortalBrick|UserProfileBrick
* @throws \Combodo\iTop\Portal\Brick\BrickNotFoundException
*/
public function GetBrick($sBrickId = null)
{
/** @var \Combodo\iTop\Portal\Brick\BrickCollection $oBrickCollection */
$oBrickCollection = $this->get('brick_collection');
// If the brick id was not specified, we get the first one registered that is an instance of UserProfileBrick as default
if ($sBrickId === null) {
/** @var \Combodo\iTop\Portal\Brick\PortalBrick $oTmpBrick */
foreach ($oBrickCollection->GetBricks() as $oTmpBrick) {
if ($oTmpBrick instanceof UserProfileBrick) {
$oBrick = $oTmpBrick;
}
}
// We make sure a UserProfileBrick was found
if (!isset($oBrick) || $oBrick === null) {
$oBrick = new UserProfileBrick();
//throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, 'UserProfileBrick : Brick could not be loaded as there was no UserProfileBrick loaded in the application.');
}
} else {
$oBrick = $oBrickCollection->GetBrickById($sBrickId);
}
return $oBrick;
}
} }

View File

@@ -132,10 +132,8 @@ class ObjectFormHandlerHelper
$bModal = ($oRequest->isXmlHttpRequest() && empty($sOperation)); $bModal = ($oRequest->isXmlHttpRequest() && empty($sOperation));
// - Retrieve form properties // - Retrieve form properties
if ($aFormProperties === null) $aFormProperties = $aFormProperties ?? ApplicationHelper::GetLoadedFormFromClass($this->aCombodoPortalInstanceConf['forms'], $sObjectClass, $sMode);
{
$aFormProperties = ApplicationHelper::GetLoadedFormFromClass($this->aCombodoPortalInstanceConf['forms'], $sObjectClass, $sMode);
}
// - Create and // - Create and
if (empty($sOperation)) if (empty($sOperation))
{ {
@@ -243,13 +241,17 @@ class ObjectFormHandlerHelper
case static::ENUM_MODE_CREATE: case static::ENUM_MODE_CREATE:
case static::ENUM_MODE_EDIT: case static::ENUM_MODE_EDIT:
case static::ENUM_MODE_VIEW: case static::ENUM_MODE_VIEW:
$sFormEndpoint = $this->oUrlGenerator->generate( if(array_key_exists('submit_endpoint', $aFormProperties)) {
'p_object_'.$sMode, $sFormEndpoint = $aFormProperties['submit_endpoint'];
array( } else {
'sObjectClass' => $sObjectClass, $sFormEndpoint = $this->oUrlGenerator->generate(
'sObjectId' => $sObjectId, 'p_object_' . $sMode,
) array(
); 'sObjectClass' => $sObjectClass,
'sObjectId' => $sObjectId,
)
);
}
break; break;
case static::ENUM_MODE_APPLY_STIMULUS: case static::ENUM_MODE_APPLY_STIMULUS:
@@ -282,7 +284,8 @@ class ObjectFormHandlerHelper
->SetActionRulesToken($sActionRulesToken) ->SetActionRulesToken($sActionRulesToken)
->SetRenderer($oFormRenderer) ->SetRenderer($oFormRenderer)
->SetFormProperties($aFormProperties); ->SetFormProperties($aFormProperties);
$oFormManager->PrepareFormAndHTMLDocument();
$oFormManager->PrepareFields();
$oFormManager->Build(); $oFormManager->Build();
$aFormData['hidden_fields'] = $oFormManager->GetHiddenFieldsId(); $aFormData['hidden_fields'] = $oFormManager->GetHiddenFieldsId();
// Check the number of editable fields // Check the number of editable fields

View File

@@ -20,7 +20,7 @@
/** @noinspection PhpUnhandledExceptionInspection */ /** @noinspection PhpUnhandledExceptionInspection */
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-portal/2.7.11', array( 'itop-portal/2.7.12', array(
// Identification // Identification
'label' => 'Enhanced Customer Portal', 'label' => 'Enhanced Customer Portal',
'category' => 'Portal', 'category' => 'Portal',

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-problem-mgmt/2.7.11', 'itop-problem-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -19,7 +19,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-profiles-itil/2.7.11', 'itop-profiles-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-request-mgmt-itil/2.7.11', 'itop-request-mgmt-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-request-mgmt/2.7.11', 'itop-request-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-service-mgmt-provider/2.7.11', 'itop-service-mgmt-provider/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-service-mgmt/2.7.11', 'itop-service-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -18,7 +18,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-sla-computation/2.7.11', 'itop-sla-computation/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -25,7 +25,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-storage-mgmt/2.7.11', 'itop-storage-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, __FILE__,
'itop-tickets/2.7.11', 'itop-tickets/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -16,7 +16,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-virtualization-mgmt/2.7.11', 'itop-virtualization-mgmt/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -3,7 +3,7 @@
SetupWebPage::AddModule( SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file __FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'itop-welcome-itil/2.7.11', 'itop-welcome-itil/2.7.12',
array( array(
// Identification // Identification
// //

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<information> <information>
<version>2.7.11</version> <version>2.7.12</version>
</information> </information>

View File

@@ -2,24 +2,72 @@
This script allows to install and update iTop via CLI. This script allows to install and update iTop via CLI.
For more information, see the official Wiki : [Automated installation [iTop Documentation]](https://www.itophub.io/wiki/page?id=latest:advancedtopics:automatic_install) For more information, see the official Wiki : [Automated installation [iTop Documentation]](https://www.itophub.io/wiki/page?id=latest:advancedtopics:automatic_install)
# unattended-install.php
## Usage
Execution of the unattended installation
> Note:
> Because the installation runs from the command line, make sure that the current user has enough rights to access the different locations and that the web server will be able to access the files and directories created during the scripted installation. In order to exactly emulate the behavior of
the interactive installation it may be a good practice to run this installation from the user account used for running the web server process.
Launch the script with the following command: ```bash php unattended_install.php --param-file=fresh-install.xml ```
Where: `fresh-install.xml` is the response file containing your desired settings for the installation (there are 4 models available in the folder `xml_setup`: fresh-install.xml, itil-fresh-install.xml, itil-upgrade.xml, upgrade.xml)
Fresh installation parameters
> Important:
> In the case of a fresh installation (<mode>install</mode>), do not forget to complete below mandatory parameters before:
```xml
<database>
<server></server>
<user></user>
<pwd></pwd>
<name></name>
<db_tls_enabled></db_tls_enabled>
<db_tls_ca></db_tls_ca>
<prefix></prefix>
</database>
<url>
</url>
<graphviz_path>/usr/bin/dot</graphviz_path>
<admin_account>
<user></user>
<pwd></pwd>
<language></language>
</admin_account>
<language></language>
```
## Options
To get all available options of the script, you can perform the following command :
```php unattended-install.php --help```
# install-itop.sh
## Usage
#install-itop.sh
You can install your iTop by only using config-itop.php settings and run either You can install your iTop by only using config-itop.php settings and run either
- a non-ITIL iTop fresh installation (use itil-fresh-install.xml to have ITIL modules instead) - a non-ITIL iTop fresh installation (use itil-fresh-install.xml to have ITIL modules instead)
``` ```
./install-itop.sh ./xml_setup/fresh-install.xml ./install-itop.sh ./xml_setup/fresh-install.xml
``` ```
- a non-ITIL iTop upgrade (use itil-upgrade.xml to have ITIL modules instead) - a non-ITIL iTop upgrade (use itil-upgrade.xml to have ITIL modules instead)
``` ```
./install-itop.sh ./xml_setup/upgrade.xml ./install-itop.sh ./xml_setup/upgrade.xml
``` ```
- a specific iTop installation by providing both xml setup file - a specific iTop installation by providing both xml setup file
in below example file provided is the one generated by iTop during last setup. in below example file provided is the one generated by iTop during last setup.
``` ```
./install-itop.sh ../../log/install-2024-04-03.xml ./install-itop.sh ../../log/install-2024-04-03.xml
``` ```

View File

@@ -41,7 +41,9 @@
<testsuite name="Setup"> <testsuite name="Setup">
<directory>unitary-tests/setup</directory> <directory>unitary-tests/setup</directory>
</testsuite> </testsuite>
<!-- Note: The unitary-tests/sources/application/TwigBase is omitted for now as the test is not working --> <testsuite name="SourcesApplicationTwigBase">
<directory>unitary-tests/sources/application/TwigBase</directory>
</testsuite>
<testsuite name="SourcesApplicationSearch"> <testsuite name="SourcesApplicationSearch">
<directory>unitary-tests/sources/application/search</directory> <directory>unitary-tests/sources/application/search</directory>
</testsuite> </testsuite>

View File

@@ -1,58 +1,44 @@
<?php <?php
namespace Combodo\iTop\Test\UnitTest;
namespace Combodo\iTop\Test\UnitTest\Application\TwigBase;
use Combodo\iTop\Portal\Twig\AppExtension; use Combodo\iTop\Portal\Twig\AppExtension;
use Twig_Environment; use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use Twig_Loader_Array; use Twig\Environment;
use Twig\Loader\FilesystemLoader;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class TwigTest extends ItopDataTestCase class TwigTest extends ItopDataTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->RequireOnceItopFile('core/config.class.inc.php'); $this->RequireOnceItopFile('core/config.class.inc.php');
} }
/** /**
* Test the fix for ticket N°4384 * @covers N°4384 N°7810
* *
* @dataProvider TemplateProvider */
* public function testTemplate()
*/ {
public function testTemplate($sFileName, $sExpected) // Creating sandbox twig env. to load and test the custom form template
{ $oTwig = new Environment(new FilesystemLoader(__DIR__.'/'));
$sId = 'TestTwig';
$oAppExtension = new AppExtension();
// Creating sandbox twig env. to load and test the custom form template // Manually registering filters and functions as we didn't find how to do it automatically
$oTwig = new Twig_Environment(new Twig_Loader_Array([$sId => $sFileName])); $oAppExtension = new AppExtension();
$aFilters = $oAppExtension->getFilters();
foreach ($aFilters as $oFilter)
{
$oTwig->addFilter($oFilter);
}
$aFunctions = $oAppExtension->getFunctions();
foreach ($aFunctions as $oFunction)
{
$oTwig->addFunction($oFunction);
}
// Manually registering filters and functions as we didn't find how to do it automatically $sOutput = $oTwig->render('test.html.twig');
$aFilters = $oAppExtension->getFilters();
foreach ($aFilters as $oFilter)
{
$oTwig->addFilter($oFilter);
}
$aFunctions = $oAppExtension->getFunctions();
foreach ($aFunctions as $oFunction)
{
$oTwig->addFunction($oFunction);
}
}
public static function testTemplateProvider() $this->assertEquals(file_get_contents(__DIR__.'/test.html'), $sOutput);
{ }
$aReturn = array();
$aReturn['filter_system'] = [
'sFileName' => 'test.html',
'expected' =>file_get_contents(dirname(__FILE__).'/test.html'),
];
return $aReturn;
}
} }

View File

@@ -42,5 +42,8 @@ Smith, Dupond
<div>['echo',1]|sort('system')|join</div> <div>['echo',1]|sort('system')|join</div>
echo1 echo1
<div>[['id','']|sort('system')</div>
id
POST /subscribe?0=cat+/etc/passwd HTTP/1.1 POST /subscribe?0=cat+/etc/passwd HTTP/1.1
email=""@attacker.tld email=""@attacker.tld

View File

@@ -47,5 +47,8 @@
<div>['echo',1]|sort('system')|join</div> <div>['echo',1]|sort('system')|join</div>
{{ ['echo',1]|sort('system')|join }} {{ ['echo',1]|sort('system')|join }}
<div>[['id','']|sort('system')</div>
{{['id','']|sort('system')|join}}
POST /subscribe?0=cat+/etc/passwd HTTP/1.1 POST /subscribe?0=cat+/etc/passwd HTTP/1.1
email="{{ app.request.query.filter(0,0,1024,{'options':'system'}) }}"@attacker.tld email="{{ app.request.query.filter(0,0,1024,{'options':'system'}) }}"@attacker.tld