new: [debug] Added an on-demand sync debug to assist some debug sessions

- very primitives, simply concatenates events to be pushed into a file
pull/4980/head
iglocska 2019-08-08 14:34:20 +02:00
parent ff144ab783
commit c3a0201195
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
2 changed files with 19 additions and 0 deletions

View File

@ -1179,6 +1179,16 @@ class Event extends AppModel
$request = $this->setupSyncRequest($server);
$uri = $url . '/events' . $this->__getLastUrlPathComponent($urlPath);
$data = json_encode($event);
if (!empty(Configure::read('Security.sync_audit'))) {
$pushLogEntry = sprintf(
"==============================================================\n\n[%s] Pushing Event #%d to Server #%d:\n\n%s\n\n",
date("Y-m-d H:i:s"),
$event['Event']['id'],
$server['Server']['id'],
$data
);
file_put_contents(APP . 'files/scripts/tmp/debug_server_' . $server['Server']['id'] . '.log', $pushLogEntry, FILE_APPEND);
}
$response = $HttpSocket->post($uri, $data, $request);
return $this->__handleRestfulEventToServerResponse($response, $newLocation, $newTextBody);
}

View File

@ -1241,6 +1241,15 @@ class Server extends AppModel
'test' => 'testForEmpty',
'type' => 'string',
'null' => true
),
'sync_audit' => array(
'level' => 1,
'description' => __('Enable this setting to create verbose logs of synced event data for debugging reasons. Logs are saved in your MISP directory\'s app/files/scripts/tmp/ directory.'),
'value' => false,
'errorMessage' => '',
'test' => 'testBoolFalse',
'type' => 'boolean',
'null' => true
)
),
'SecureAuth' => array(