From dbfef34f6e5a72fca3222c0d5c005dd171dad36c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 20 Jul 2018 13:24:45 +0200 Subject: [PATCH] Audit: Log a command's payload as json $data may be arbitrarily nested. refs #3535 Signed-off-by: Eric Lippmann --- .../Monitoring/Command/Transport/ApiCommandTransport.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Command/Transport/ApiCommandTransport.php b/modules/monitoring/library/Monitoring/Command/Transport/ApiCommandTransport.php index 73237fe2a..06e6afd58 100644 --- a/modules/monitoring/library/Monitoring/Command/Transport/ApiCommandTransport.php +++ b/modules/monitoring/library/Monitoring/Command/Transport/ApiCommandTransport.php @@ -12,6 +12,7 @@ use Icinga\Module\Monitoring\Command\Renderer\IcingaApiCommandRenderer; use Icinga\Module\Monitoring\Exception\CommandTransportException; use Icinga\Module\Monitoring\Exception\CurlException; use Icinga\Module\Monitoring\Web\Rest\RestRequest; +use Icinga\Util\Json; /** * Command transport over Icinga 2's REST API @@ -198,11 +199,7 @@ class ApiCommandTransport implements CommandTransportInterface ); $data = $command->getData(); - $payload = []; - foreach ($data as $key => $value) { - $payload[] = "$key=$value"; - } - $payload = implode(', ', $payload); + $payload = Json::encode($data); AuditHook::logActivity( 'monitoring/command', "Issued command {$command->getEndpoint()} with the following payload: $payload",