]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/json: update callers to use explicit directions
authorVictor Julien <victor@inliniac.net>
Fri, 2 Mar 2018 11:15:11 +0000 (12:15 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 2 Mar 2018 16:46:36 +0000 (17:46 +0100)
14 files changed:
src/detect-engine-profile.c
src/output-json-alert.c
src/output-json-dnp3.c
src/output-json-dns.c
src/output-json-drop.c
src/output-json-file.c
src/output-json-http.c
src/output-json-metadata.c
src/output-json-nfs.c
src/output-json-smtp.c
src/output-json-ssh.c
src/output-json-template.c
src/output-json-tftp.c
src/output-json-tls.c

index fc43c3fd01dd0d792fe2ded5110e82210b057a07..3b1d5cd7826b0f4f24ab9a69a61fd15c91188fc4 100644 (file)
@@ -60,7 +60,7 @@ SCMutex g_rule_dump_write_m = SCMUTEX_INITIALIZER;
 void RulesDumpMatchArray(const DetectEngineThreadCtx *det_ctx,
         const SigGroupHead *sgh, const Packet *p)
 {
-    json_t *js = CreateJSONHeader(p, 0, "inspectedrules");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "inspectedrules");
     if (js == NULL)
         return;
     json_t *ir = json_object();
index b494823decaeaae96684de5b75f384039ba4e35c..59d818bc45df3ae033d648cad09b2365078f231b 100644 (file)
@@ -389,7 +389,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
     if (p->alerts.cnt == 0 && !(p->flags & PKT_HAS_TAG))
         return TM_ECODE_OK;
 
-    json_t *js = CreateJSONHeader(p, 0, "alert");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "alert");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
@@ -589,7 +589,7 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p)
     if ((p->flags & PKT_HAS_TAG) && (json_output_ctx->flags &
             LOG_JSON_TAGGED_PACKETS)) {
         MemBufferReset(aft->json_buffer);
-        json_t *packetjs = CreateJSONHeader(p, 0, "packet");
+        json_t *packetjs = CreateJSONHeader(p, LOG_DIR_PACKET, "packet");
         if (unlikely(packetjs != NULL)) {
             AlertJsonPacket(p, packetjs);
             OutputJSONBuffer(packetjs, aft->file_ctx, &aft->json_buffer);
index a405dcc890991e8da00d2a53e5f3d0428445a1ec..0f2fdd3cde23030415f495d2b6158eeaa76c2a49 100644 (file)
@@ -312,7 +312,7 @@ static int JsonDNP3LoggerToServer(ThreadVars *tv, void *thread_data,
 
     MemBufferReset(buffer);
     if (tx->has_request && tx->request_done) {
-        json_t *js = CreateJSONHeader(p, 1, "dnp3");
+        json_t *js = CreateJSONHeader(p, LOG_DIR_FLOW, "dnp3");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
@@ -341,7 +341,7 @@ static int JsonDNP3LoggerToClient(ThreadVars *tv, void *thread_data,
 
     MemBufferReset(buffer);
     if (tx->has_response && tx->response_done) {
-        json_t *js = CreateJSONHeader(p, 1, "dnp3");
+        json_t *js = CreateJSONHeader(p, LOG_DIR_FLOW, "dnp3");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
index 58d34b64e7dd3b0d081af874e9f2d64374629ab0..8920b1b2886d6e728eebb4f567719adaf811d26a 100644 (file)
@@ -663,7 +663,7 @@ static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
 
 #ifdef HAVE_RUST
     for (uint16_t i = 0; i < 0xffff; i++) {
-        js = CreateJSONHeader(p, 1, "dns");
+        js = CreateJSONHeader(p, LOG_DIR_PACKET, "dns");
         if (unlikely(js == NULL)) {
             return TM_ECODE_OK;
         }
@@ -684,7 +684,7 @@ static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
     DNSTransaction *tx = txptr;
     DNSQueryEntry *query = NULL;
     TAILQ_FOREACH(query, &tx->query_list, next) {
-        js = CreateJSONHeader(p, 1, "dns");
+        js = CreateJSONHeader(p, LOG_DIR_PACKET, "dns");
         if (unlikely(js == NULL))
             return TM_ECODE_OK;
         if (dnslog_ctx->include_metadata) {
@@ -707,13 +707,14 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
 
     LogDnsLogThread *td = (LogDnsLogThread *)thread_data;
     LogDnsFileCtx *dnslog_ctx = td->dnslog_ctx;
-    json_t *js;
 
     if (unlikely(dnslog_ctx->flags & LOG_ANSWERS) == 0) {
         return TM_ECODE_OK;
     }
 
-    js = CreateJSONHeader(p, 0, "dns");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "dns");
+    if (unlikely(js == NULL))
+        return TM_ECODE_OK;
 
     if (dnslog_ctx->include_metadata) {
         JsonAddMetadata(p, f, js);
@@ -747,8 +748,6 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
     }
 #else
     DNSTransaction *tx = txptr;
-    if (unlikely(js == NULL))
-        return TM_ECODE_OK;
 
     LogAnswers(td, js, tx, tx_id);
 #endif
index a84c9d6efc99bbd6a16db5c55c6794ac6a3dbe72..653e82f50ffe0f19d00b3d30ce532cbe0b296412 100644 (file)
@@ -88,8 +88,8 @@ static int g_droplog_flows_start = 1;
 static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
 {
     JsonDropOutputCtx *drop_ctx = aft->drop_ctx;
-    uint16_t proto = 0;
-    json_t *js = CreateJSONHeader(p, 0, "drop");
+
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "drop");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
@@ -106,6 +106,7 @@ static int DropLogJSON (JsonDropLogThread *aft, const Packet *p)
     /* reset */
     MemBufferReset(aft->buffer);
 
+    uint16_t proto = 0;
     if (PKT_IS_IPV4(p)) {
         json_object_set_new(djs, "len", json_integer(IPV4_GET_IPLEN(p)));
         json_object_set_new(djs, "tos", json_integer(IPV4_GET_IPTOS(p)));
index f00471adf8bbacba3d3bdc07119aa25d94350dcf..8c9ff617927da9ac7606199cd27eaefa85df7d7e 100644 (file)
@@ -81,7 +81,7 @@ typedef struct JsonFileLogThread_ {
 json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
         const bool stored)
 {
-    json_t *js = CreateJSONHeader(p, 0, "fileinfo");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "fileinfo");
     json_t *hjs = NULL;
     if (unlikely(js == NULL))
         return NULL;
index ac8a9f34c988a690c5f31f39c767fb17a76891a2..7110e6b44ee7c8f9061a4828eb08c956e14e58e4 100644 (file)
@@ -452,7 +452,7 @@ static int JsonHttpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
     htp_tx_t *tx = txptr;
     JsonHttpLogThread *jhl = (JsonHttpLogThread *)thread_data;
 
-    json_t *js = CreateJSONHeaderWithTxId(p, 1, "http", tx_id);
+    json_t *js = CreateJSONHeaderWithTxId(p, LOG_DIR_FLOW, "http", tx_id);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index 370609b178d999d62d52b6c75308bec24707f146..de918d3ea1b0f2f6fc06b721cc345784755049b4 100644 (file)
@@ -82,7 +82,7 @@ typedef struct JsonMetadataLogThread_ {
 
 static int MetadataJson(ThreadVars *tv, JsonMetadataLogThread *aft, const Packet *p)
 {
-    json_t *js = CreateJSONHeader(p, 0, "metadata");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "metadata");
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index df614dc47286b6eef8aae9296f47ba7f4d2572a7..ba9f97abfaa0d1cc90e5dbbc618dcb43fdb8654d 100644 (file)
@@ -94,12 +94,11 @@ static int JsonNFSLogger(ThreadVars *tv, void *thread_data,
 {
     NFSTransaction *nfstx = tx;
     LogNFSLogThread *thread = thread_data;
-    json_t *js, *nfsjs;
 
     if (rs_nfs_tx_logging_is_filtered(nfstx))
         return TM_ECODE_OK;
 
-    js = CreateJSONHeader(p, 0, "nfs");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "nfs");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
@@ -114,7 +113,7 @@ static int JsonNFSLogger(ThreadVars *tv, void *thread_data,
     }
     json_object_set_new(js, "rpc", rpcjs);
 
-    nfsjs = rs_nfs_log_json_response(state, tx);
+    json_t *nfsjs = rs_nfs_log_json_response(state, tx);
     if (unlikely(nfsjs == NULL)) {
         goto error;
     }
index 264420b8747880708a1c58c6c6fd0d6a6b2662f1..eb7cd283deb769217c01b720da80860ac9c6a944 100644 (file)
@@ -88,7 +88,7 @@ static int JsonSmtpLogger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
     SCEnter();
     JsonEmailLogThread *jhl = (JsonEmailLogThread *)thread_data;
 
-    json_t *js = CreateJSONHeaderWithTxId(p, 1, "smtp", tx_id);
+    json_t *js = CreateJSONHeaderWithTxId(p, LOG_DIR_FLOW, "smtp", tx_id);
     if (unlikely(js == NULL))
         return TM_ECODE_OK;
 
index 2bbe4acd97f810596226fbe654de9d74b8534ebe..20b0191517e784e1b4b75f817b2d5e4ba3520204 100644 (file)
@@ -106,7 +106,7 @@ static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p,
         ssh_state->srv_hdr.software_version == NULL)
         return 0;
 
-    json_t *js = CreateJSONHeader(p, 1, "ssh");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_FLOW, "ssh");
     if (unlikely(js == NULL))
         return 0;
 
index f59ec2baf4b33e1cb3bd3d6173cfbf56d64bf00b..38bb6b756aa12db7951a4e6bd3cb5cd69e645801 100644 (file)
@@ -74,7 +74,7 @@ static int JsonTemplateLogger(ThreadVars *tv, void *thread_data,
 
     SCLogNotice("Logging template transaction %"PRIu64".", templatetx->tx_id);
 
-    json_t *js = CreateJSONHeader(p, 0, "template");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "template");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
index 6953917c1180c79c4be3f9476ceb72853d620dfe..ed6b73c35ebc42ae3c5c4d44b35dad6264837731 100644 (file)
@@ -71,7 +71,7 @@ static int JsonTFTPLogger(ThreadVars *tv, void *thread_data,
 {
     LogTFTPLogThread *thread = thread_data;
 
-    json_t *js = CreateJSONHeader(p, 0, "tftp");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_PACKET, "tftp");
     if (unlikely(js == NULL)) {
         return TM_ECODE_FAILED;
     }
index 95a5f1f3dc53f4d1aa200fc368b12ff3e13df0fc..5c424c0d5891384840f96ef10242d25346c9abe3 100644 (file)
@@ -357,7 +357,7 @@ static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p,
         return 0;
     }
 
-    json_t *js = CreateJSONHeader(p, 1, "tls");
+    json_t *js = CreateJSONHeader(p, LOG_DIR_FLOW, "tls");
     if (unlikely(js == NULL)) {
         return 0;
     }