mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
🎨 N°8231 Code format and comments
This commit is contained in:
@@ -1711,6 +1711,11 @@ interface iRestServiceProvider
|
||||
public function ExecOperation($sVersion, $sVerb, $aParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* A REST service provider implementing this interface will have its input JSON data sanitized for logging purposes
|
||||
* @since 2.7.13, 3.2.1-1
|
||||
* @see \iRestServiceProvider
|
||||
*/
|
||||
interface iRestInputSanitizer
|
||||
{
|
||||
public function SanitizeJsonInput(string $sJsonInput): string;
|
||||
|
||||
@@ -159,16 +159,15 @@ class ObjectResult
|
||||
$this->fields[$sAttCode] = $this->MakeResultValue($oObject, $sAttCode, $bExtendedOutput);
|
||||
}
|
||||
|
||||
public function SanitizeContent()
|
||||
public function SanitizeContent()
|
||||
{
|
||||
foreach($this->fields as $sFieldAttCode => $fieldValue)
|
||||
{
|
||||
foreach($this->fields as $sFieldAttCode => $fieldValue) {
|
||||
try {
|
||||
$oAttDef = MetaModel::GetAttributeDef($this->class, $sFieldAttCode);
|
||||
} catch (Exception $e) { // for special cases like ID
|
||||
continue;
|
||||
}
|
||||
$this->SanitizeFieldIfSensitive($this->fields, $sFieldAttCode, $fieldValue, $oAttDef);
|
||||
$this->SanitizeFieldIfSensitive($this->fields, $sFieldAttCode, $fieldValue, $oAttDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -929,6 +928,10 @@ class CoreServices implements iRestServiceProvider, iRestInputSanitizer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes sensitive fields on a "json ready" representation of a DBObject
|
||||
* Useful for logging purposes
|
||||
*/
|
||||
trait SanitizeTrait
|
||||
{
|
||||
/**
|
||||
@@ -942,8 +945,7 @@ trait SanitizeTrait
|
||||
private function SanitizeFieldIfSensitive(array &$fields, string $sFieldAttCode, $fieldValue, $oAttDef): void
|
||||
{
|
||||
// for simple attribute
|
||||
if ($oAttDef instanceof iAttributeNoGroupBy) // iAttributeNoGroupBy is equivalent to sensitive attribute
|
||||
{
|
||||
if ($oAttDef instanceof iAttributeNoGroupBy) { // iAttributeNoGroupBy is equivalent to sensitive attribute
|
||||
$fields[$sFieldAttCode] = '*****';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ class RestServicesSanitizeOutputTest extends ItopCustomDatamodelTestCase
|
||||
private const SIMPLE_PASSWORD = '123456';
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @return string Abs path to the XML delta to use for the tests of that class
|
||||
*/
|
||||
protected function setUp(): void
|
||||
public function GetDatamodelDeltaAbsPath(): string
|
||||
{
|
||||
parent::setUp();
|
||||
return __DIR__.'/Delta/delta_test_sanitize_output.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,12 +156,4 @@ class RestServicesSanitizeOutputTest extends ItopCustomDatamodelTestCase
|
||||
json_encode($oRestResultWithObject));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string Abs path to the XML delta to use for the tests of that class
|
||||
*/
|
||||
public function GetDatamodelDeltaAbsPath(): string
|
||||
{
|
||||
return __DIR__.'/Delta/delta_test_sanitize_output.xml';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user