Skip to content
26 changes: 26 additions & 0 deletions core/config.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/


use Combodo\iTop\Config\Validator\iTopConfigAstValidator;
use Combodo\iTop\Config\Validator\iTopConfigSyntaxValidator;

define('ITOP_APPLICATION', 'iTop');
define('ITOP_APPLICATION_SHORT', 'iTop');

Expand Down Expand Up @@ -1816,6 +1819,27 @@ public function IsProperty($sPropCode)
return (array_key_exists($sPropCode, $this->m_aSettings));
}

public static function Validate(string $sContents)
{
$oiTopConfigValidator = new iTopConfigAstValidator();
$oiTopConfigValidator->Validate($sContents);

/// 2 - only after we are sure that there is no malicious code, we can perform a syntax check!
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
$oiTopConfigValidator->Validate($sContents);
}

function DBPasswordInNewConfigIsOk()
{
$bIsWindows = (array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER));

if ($bIsWindows && (preg_match("/[%!\"]/U", $this->Get('db_pwd')) !== 0)) {
return false;
}

return true;
}

/**
* @return string identifier that can be used for example to name WebStorage/SessionStorage keys (they
* are related to a whole domain, and a domain can host multiple itop)
Expand Down Expand Up @@ -3037,4 +3061,6 @@ private function Get($sSourceName, $sKey, $sDefault, $sWholeMask)
IssueLog::Error($sErrorMessage, self::class, array($sSourceName, $sKey, $sDefault, $sWholeMask));
throw new ConfigException($sErrorMessage);
}


}
Loading