From 8e7ce81e96e07d485480f1717ea633010ea1565d Mon Sep 17 00:00:00 2001 From: ibering Date: Wed, 21 Feb 2024 11:17:35 +0100 Subject: [PATCH 1/2] #ITC-3139 MSSQL wizard logs password to changelog: hide custom variables password from changelog (host templates, service templates, hosts and services) --- src/Model/Table/ChangelogsTable.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Model/Table/ChangelogsTable.php b/src/Model/Table/ChangelogsTable.php index 4d8a5df33d..0e9a630ad1 100644 --- a/src/Model/Table/ChangelogsTable.php +++ b/src/Model/Table/ChangelogsTable.php @@ -254,7 +254,7 @@ public function getCompareRules() { 'CheckPeriod' => '{(id|name)}', 'NotifyPeriod' => '{(id|name)}', 'CheckCommand' => '{(id|name)}', - 'Hosttemplate.customvariables' => '{n}.{(id|name|value)}', + 'Hosttemplate.customvariables' => '{n}.{(id|name|value|password)}', 'Hosttemplate.hosttemplatecommandargumentvalues' => '{n}.{(id|value)}', 'Contact' => '{n}.{(id|name)}', 'Contactgroup' => '{n}.{(id|name)}', @@ -266,7 +266,7 @@ public function getCompareRules() { 'NotifyPeriod' => '{(id|name)}', 'CheckCommand' => '{(id|name)}', 'EventhandlerCommand' => '{(id|name)}', - 'Servicetemplate.customvariables' => '{n}.{(id|name|value)}', + 'Servicetemplate.customvariables' => '{n}.{(id|name|value|password)}', 'Servicetemplate.servicetemplatecommandargumentvalues' => '{n}.{(id|value)}', 'Servicetemplate.servicetemplateeventcommandargumentvalues' => '{n}.{(id|value)}', 'Contact' => '{n}.{(id|name)}', @@ -292,7 +292,7 @@ public function getCompareRules() { 'CheckCommand' => '{(id|name)}', 'Hostgroup' => '{n}.{(id|name)}', 'Parenthost' => '{n}.{(id|name)}', - 'Host.customvariables' => '{n}.{(id|name|value)}', + 'Host.customvariables' => '{n}.{(id|name|value|password)}', 'Host.hostcommandargumentvalues' => '{n}.{(id|value)}', 'Contact' => '{n}.{(id|name)}', 'Contactgroup' => '{n}.{(id|name)}', @@ -305,7 +305,7 @@ public function getCompareRules() { 'NotifyPeriod' => '{(id|name)}', 'CheckCommand' => '{(id|name)}', 'Servicegroup' => '{n}.{(id|name)}', - 'Service.customvariables' => '{n}.{(id|name|value)}', + 'Service.customvariables' => '{n}.{(id|name|value|password)}', 'Service.servicecommandargumentvalues' => '{n}.{(id|value)}', 'Service.serviceeventcommandargumentvalues' => '{n}.{(id|value)}', 'Contact' => '{n}.{(id|name)}', @@ -871,6 +871,12 @@ public function formatDataForView(array $dataUnserialized, string $action): arra } } } + if ($isArray) { + if (!empty(Hash::extract($diffs, '{n}.{*}[password=1].value'))) { + $diffs = Hash::insert($diffs, '{n}.{*}[password=1].value', '🤫'); + } + } + $dataUnserialized[$index][$tableName] = [ 'data' => $diffs, 'isArray' => $isArray @@ -878,6 +884,7 @@ public function formatDataForView(array $dataUnserialized, string $action): arra } } } + $dataUnserialized = Hash::insert($dataUnserialized, '{n}.{s}.data.{n}[password=1].value', '🤫'); return $dataUnserialized; } } From 26ed727f015796245149cdd085452b4cc8e3fd28 Mon Sep 17 00:00:00 2001 From: ibering Date: Wed, 21 Feb 2024 13:55:35 +0100 Subject: [PATCH 2/2] #ITC-3139 MSSQL wizard logs password to changelog: insert does not work with string wildcard (old and new as path key added) --- src/Model/Table/ChangelogsTable.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Model/Table/ChangelogsTable.php b/src/Model/Table/ChangelogsTable.php index 0e9a630ad1..8ca6617450 100644 --- a/src/Model/Table/ChangelogsTable.php +++ b/src/Model/Table/ChangelogsTable.php @@ -872,8 +872,11 @@ public function formatDataForView(array $dataUnserialized, string $action): arra } } if ($isArray) { - if (!empty(Hash::extract($diffs, '{n}.{*}[password=1].value'))) { - $diffs = Hash::insert($diffs, '{n}.{*}[password=1].value', '🤫'); + if (!empty(Hash::extract($diffs, '{n}.old[password=1].value'))) { + $diffs = Hash::insert($diffs, '{n}.old[password=1].value', '🤫'); + } + if (!empty(Hash::extract($diffs, '{n}.new[password=1].value'))) { + $diffs = Hash::insert($diffs, '{n}.new[password=1].value', '🤫'); } }