From 8ba8c0bf6f11a3685074563334edf073691f5723 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 6 May 2014 13:54:03 +0200 Subject: [PATCH] json output: don't set 'unknown' for missing data Instead of setting 'unknown' or '' just pass NULL to json_* function, which results in omitting the data. --- src/output-json-file.c | 10 ++++------ src/output-json-http.c | 4 ---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/output-json-file.c b/src/output-json-file.c index 822f8ce398..9aa417122d 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -93,7 +93,7 @@ static json_t *LogFileMetaGetUri(const Packet *p, const File *ff) { } } - return json_string(""); + return NULL; } static json_t *LogFileMetaGetHost(const Packet *p, const File *ff) { @@ -112,7 +112,7 @@ static json_t *LogFileMetaGetHost(const Packet *p, const File *ff) { } } - return json_string(""); + return NULL; } static json_t *LogFileMetaGetReferer(const Packet *p, const File *ff) { @@ -136,7 +136,7 @@ static json_t *LogFileMetaGetReferer(const Packet *p, const File *ff) { } } - return json_string(""); + return NULL; } static json_t *LogFileMetaGetUserAgent(const Packet *p, const File *ff) { @@ -160,7 +160,7 @@ static json_t *LogFileMetaGetUserAgent(const Packet *p, const File *ff) { } } - return json_string(""); + return NULL; } /** @@ -201,8 +201,6 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F SCFree(s); if (ff->magic) json_object_set_new(fjs, "magic", json_string((char *)ff->magic)); - else - json_object_set_new(fjs, "magic", json_string("unknown")); switch (ff->state) { case FILE_STATE_CLOSED: json_object_set_new(fjs, "state", json_string("CLOSED")); diff --git a/src/output-json-http.c b/src/output-json-http.c index a9519b0e6e..9ed0df1f00 100644 --- a/src/output-json-http.c +++ b/src/output-json-http.c @@ -197,8 +197,6 @@ static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx) json_object_set_new(hjs, "hostname", json_string(c)); SCFree(c); } - } else { - json_object_set_new(hjs, "hostname", json_string("")); } /* uri */ @@ -222,8 +220,6 @@ static void JsonHttpLogJSON(JsonHttpLogThread *aft, json_t *js, htp_tx_t *tx) json_object_set_new(hjs, "http_user_agent", json_string(c)); SCFree(c); } - } else { - json_object_set_new(hjs, "http_user_agent", json_string("unknown>")); } /* x-forwarded-for */ -- 2.47.3