]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output-json-file: let caller decide if file is stored
authorJason Ish <ish@unx.ca>
Thu, 18 Jan 2018 12:17:00 +0000 (06:17 -0600)
committerJason Ish <ish@unx.ca>
Thu, 18 Jan 2018 12:18:30 +0000 (06:18 -0600)
Mainly for the filestore module, which may have its own
knowledge of the file being stored before others.

src/output-json-file.c
src/output-json-file.h

index 33b1b401050fe49bea5740769f42fdd157047f56..b295ea5baaf620e092f9a156500edf11fd85a151 100644 (file)
@@ -78,7 +78,8 @@ typedef struct JsonFileLogThread_ {
     MemBuffer *buffer;
 } JsonFileLogThread;
 
-json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff)
+json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
+        const bool stored)
 {
     json_t *js = CreateJSONHeader((Packet *)p, 0, "fileinfo"); //TODO const
     json_t *hjs = NULL;
@@ -176,8 +177,7 @@ json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff)
     }
 #endif
 
-    json_object_set_new(fjs, "stored",
-                        (ff->flags & FILE_STORED) ? json_true() : json_false());
+    json_object_set_new(fjs, "stored", stored ? json_true() : json_false());
     if (ff->flags & FILE_STORED) {
         json_object_set_new(fjs, "file_id", json_integer(ff->file_store_id));
     }
@@ -196,7 +196,8 @@ json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff)
  */
 static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff)
 {
-    json_t *js = JsonBuildFileInfoRecord(p, ff);
+    json_t *js = JsonBuildFileInfoRecord(p, ff,
+            ff->flags & FILE_STORED ? true : false);
     if (unlikely(js == NULL)) {
         return;
     }
index 774693c539db2c10843dda73b8155d3439307f86..fdd38d60eafa3c2d5a34a7dff5b11030bc961d03 100644 (file)
@@ -27,7 +27,8 @@
 void JsonFileLogRegister(void);
 
 #ifdef HAVE_LIBJANSSON
-json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff);
+json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
+        const bool stored);
 #endif
 
 #endif /* __OUTPUT_JSON_FILE_H__ */