mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-11 04:38:43 +02:00
Compare commits
4 Commits
develop
...
feature/93
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43121a5a4b | ||
|
|
ff2f10e5b6 | ||
|
|
ddaf014898 | ||
|
|
a71fefa328 |
@@ -1546,7 +1546,16 @@ class ShortcutMenuNode extends MenuNode
|
|||||||
public function GetHyperlink($aExtraParams)
|
public function GetHyperlink($aExtraParams)
|
||||||
{
|
{
|
||||||
$sContext = $this->oShortcut->Get('context');
|
$sContext = $this->oShortcut->Get('context');
|
||||||
$aContext = unserialize($sContext);
|
try {
|
||||||
|
$aContext = utils::Unserialize($sContext, ['allowed_classes' => false]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
IssueLog::Warning("User shortcut corrupted, delete the shortcut", LogChannels::CONSOLE, [
|
||||||
|
'shortcut_name' => $this->oShortcut->GetName(),
|
||||||
|
'root_cause' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
// delete the shortcut
|
||||||
|
$this->oShortcut->DBDelete();
|
||||||
|
}
|
||||||
if (isset($aContext['menu'])) {
|
if (isset($aContext['menu'])) {
|
||||||
unset($aContext['menu']);
|
unset($aContext['menu']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3252,4 +3252,50 @@ TXT
|
|||||||
|
|
||||||
return $aTrace;
|
return $aTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP unserialize encapsulation, allow throwing exception when not allowed object class is detected (for security hardening)
|
||||||
|
*
|
||||||
|
* @param mixed $data data to unserialize
|
||||||
|
* @param array $aOptions PHP @unserialise options
|
||||||
|
* @param bool $bThrowNotAllowedObjectClassException flag to throw exception
|
||||||
|
*
|
||||||
|
* @return mixed PHP @unserialise return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function Unserialize(mixed $data, array $aOptions, bool $bThrowNotAllowedObjectClassException = true): mixed
|
||||||
|
{
|
||||||
|
$data = unserialize($data, $aOptions);
|
||||||
|
|
||||||
|
if ($bThrowNotAllowedObjectClassException) {
|
||||||
|
try {
|
||||||
|
self::AssertNoIncompleteClassDetected($data);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new CoreException('Unserialization failed because an incomplete class was detected.', [], '', $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that data provided doesn't contain any incomplete class.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function AssertNoIncompleteClassDetected(mixed $data): void
|
||||||
|
{
|
||||||
|
if (is_object($data)) {
|
||||||
|
if ($data instanceof __PHP_Incomplete_Class) {
|
||||||
|
throw new Exception('__PHP_Incomplete_Class_Name object detected');
|
||||||
|
}
|
||||||
|
foreach (get_object_vars($data) as $property) {
|
||||||
|
self::AssertNoIncompleteClassDetected($property);
|
||||||
|
}
|
||||||
|
} elseif (is_array($data)) {
|
||||||
|
foreach ($data as $value) {
|
||||||
|
self::AssertNoIncompleteClassDetected($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4829,7 +4829,7 @@ class AttributeCaseLog extends AttributeLongText
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($sIndex) > 0) {
|
if (strlen($sIndex) > 0) {
|
||||||
$aIndex = unserialize($sIndex);
|
$aIndex = utils::Unserialize($sIndex, ['allowed_classes' => false], false);
|
||||||
$value = new ormCaseLog($sLog, $aIndex);
|
$value = new ormCaseLog($sLog, $aIndex);
|
||||||
} else {
|
} else {
|
||||||
$value = new ormCaseLog($sLog);
|
$value = new ormCaseLog($sLog);
|
||||||
|
|||||||
@@ -8,8 +8,13 @@ use AttributeFriendlyName;
|
|||||||
use AttributeLinkedSet;
|
use AttributeLinkedSet;
|
||||||
use cmdbAbstract;
|
use cmdbAbstract;
|
||||||
use cmdbAbstractObject;
|
use cmdbAbstractObject;
|
||||||
|
use CoreException;
|
||||||
use Dict;
|
use Dict;
|
||||||
|
use Exception;
|
||||||
|
use IssueLog;
|
||||||
|
use LogChannels;
|
||||||
use Metamodel;
|
use Metamodel;
|
||||||
|
use utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DataTableSettings
|
* Class DataTableSettings
|
||||||
@@ -130,7 +135,10 @@ class DataTableSettings
|
|||||||
*/
|
*/
|
||||||
public function unserialize($sData)
|
public function unserialize($sData)
|
||||||
{
|
{
|
||||||
$aData = unserialize($sData);
|
$aData = utils::Unserialize($sData, ['allowed_classes' => false]);
|
||||||
|
if (!is_array($aData)) {
|
||||||
|
throw new CoreException('Wrong data table settings format, expected an array', ['datatable_settings_data' => $aData]);
|
||||||
|
}
|
||||||
$this->iDefaultPageSize = $aData['iDefaultPageSize'];
|
$this->iDefaultPageSize = $aData['iDefaultPageSize'];
|
||||||
$this->aColumns = $aData['aColumns'];
|
$this->aColumns = $aData['aColumns'];
|
||||||
foreach ($this->aClassAliases as $sAlias => $sClass) {
|
foreach ($this->aClassAliases as $sAlias => $sClass) {
|
||||||
@@ -269,7 +277,19 @@ class DataTableSettings
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oSettings->unserialize($pref);
|
|
||||||
|
try {
|
||||||
|
$oSettings->unserialize($pref);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
IssueLog::Warning("User table settings corrupted, back to the default values provided by the data model", LogChannels::CONSOLE, [
|
||||||
|
'table_id' => $sTableId,
|
||||||
|
'root_cause' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
// unset the preference
|
||||||
|
appUserPreferences::UnsetPref($oSettings->GetPrefsKey($sTableId));
|
||||||
|
// use the default values provided by the data model
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $oSettings;
|
return $oSettings;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user