|
|
|
@ -72,44 +72,33 @@ static int JsonTemplateLogger(ThreadVars *tv, void *thread_data,
|
|
|
|
|
|
|
|
|
|
SCLogNotice("Logging template transaction %"PRIu64".", templatetx->tx_id);
|
|
|
|
|
|
|
|
|
|
json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "template", NULL);
|
|
|
|
|
JsonBuilder *js = CreateEveHeader(p, LOG_DIR_PACKET, "template", NULL);
|
|
|
|
|
if (unlikely(js == NULL)) {
|
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_t *templatejs = json_object();
|
|
|
|
|
if (unlikely(templatejs == NULL)) {
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
jb_open_object(js, "template");
|
|
|
|
|
|
|
|
|
|
/* Convert the request buffer to a string then log. */
|
|
|
|
|
char *request_buffer = BytesToString(templatetx->request_buffer,
|
|
|
|
|
templatetx->request_buffer_len);
|
|
|
|
|
if (request_buffer != NULL) {
|
|
|
|
|
json_object_set_new(templatejs, "request", json_string(request_buffer));
|
|
|
|
|
SCFree(request_buffer);
|
|
|
|
|
/* Log the request buffer. */
|
|
|
|
|
if (templatetx->request_buffer != NULL) {
|
|
|
|
|
jb_set_string_from_bytes(js, "request", templatetx->request_buffer,
|
|
|
|
|
templatetx->request_buffer_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Convert the response buffer to a string then log. */
|
|
|
|
|
char *response_buffer = BytesToString(templatetx->response_buffer,
|
|
|
|
|
templatetx->response_buffer_len);
|
|
|
|
|
if (response_buffer != NULL) {
|
|
|
|
|
json_object_set_new(templatejs, "response",
|
|
|
|
|
json_string(response_buffer));
|
|
|
|
|
SCFree(response_buffer);
|
|
|
|
|
/* Log the response buffer. */
|
|
|
|
|
if (templatetx->response_buffer != NULL) {
|
|
|
|
|
jb_set_string_from_bytes(js, "response", templatetx->response_buffer,
|
|
|
|
|
templatetx->response_buffer_len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_object_set_new(js, "template", templatejs);
|
|
|
|
|
/* Close template. */
|
|
|
|
|
jb_close(js);
|
|
|
|
|
|
|
|
|
|
MemBufferReset(thread->buffer);
|
|
|
|
|
OutputJSONBuffer(js, thread->templatelog_ctx->file_ctx, &thread->buffer);
|
|
|
|
|
OutputJsonBuilderBuffer(js, thread->templatelog_ctx->file_ctx, &thread->buffer);
|
|
|
|
|
|
|
|
|
|
json_decref(js);
|
|
|
|
|
jb_free(js);
|
|
|
|
|
return TM_ECODE_OK;
|
|
|
|
|
|
|
|
|
|
error:
|
|
|
|
|
json_decref(js);
|
|
|
|
|
return TM_ECODE_FAILED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void OutputTemplateLogDeInitCtxSub(OutputCtx *output_ctx)
|
|
|
|
|