]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
nfs: add to fileinfo events
authorVictor Julien <victor@inliniac.net>
Fri, 16 Jun 2017 18:35:33 +0000 (20:35 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 19 Jun 2017 08:38:18 +0000 (10:38 +0200)
rust/src/nfs/nfs.rs
src/output-json-file.c
src/output-json-nfs.c
src/output-json-nfs.h

index 0be7acdcdbbdfd6fd6a0bb3ce837eebbd8e6eebf..650f2324a22879d83ab415b2c0c46c0aa1f8e46f 100644 (file)
@@ -721,7 +721,7 @@ impl NFSState {
         tx.type_data = Some(NFSTransactionTypeData::FILE(NFSTransactionFile::new()));
         match tx.type_data {
             Some(NFSTransactionTypeData::FILE(ref mut d)) => {
-                d.file_tracker.tx_id = tx.id;
+                d.file_tracker.tx_id = tx.id - 1;
             },
             _ => { },
         }
index 842a3d208e040875d10f568106c0c504ca5ff906..0b7fbaa98392defa5a11a5e44ed156c2d7a19d98 100644 (file)
@@ -60,6 +60,7 @@
 #include "output-json-http.h"
 #include "output-json-smtp.h"
 #include "output-json-email-common.h"
+#include "output-json-nfs.h"
 
 #include "app-layer-htp.h"
 #include "util-memcmp.h"
@@ -105,6 +106,16 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F
             if (hjs)
                 json_object_set_new(js, "email", hjs);
             break;
+#ifdef HAVE_RUST
+        case ALPROTO_NFS:
+            hjs = JsonNFSAddMetadataRPC(p->flow, ff->txid);
+            if (hjs)
+                json_object_set_new(js, "rpc", hjs);
+            hjs = JsonNFSAddMetadata(p->flow, ff->txid);
+            if (hjs)
+                json_object_set_new(js, "nfs", hjs);
+            break;
+#endif
     }
 
     json_object_set_new(js, "app_proto",
index 070c279d598ef4fe2014eafe839dbb9372d08752..2515605964dc6655e2fbc39b82cb9c079358eba5 100644 (file)
@@ -62,6 +62,32 @@ typedef struct LogNFSLogThread_ {
     MemBuffer          *buffer;
 } LogNFSLogThread;
 
+json_t *JsonNFSAddMetadataRPC(const Flow *f, uint64_t tx_id)
+{
+    NFSState *state = FlowGetAppState(f);
+    if (state) {
+        NFSTransaction *tx = AppLayerParserGetTx(f->proto, ALPROTO_NFS, state, tx_id);
+        if (tx) {
+            return rs_rpc_log_json_response(tx);
+        }
+    }
+
+    return NULL;
+}
+
+json_t *JsonNFSAddMetadata(const Flow *f, uint64_t tx_id)
+{
+    NFSState *state = FlowGetAppState(f);
+    if (state) {
+        NFSTransaction *tx = AppLayerParserGetTx(f->proto, ALPROTO_NFS, state, tx_id);
+        if (tx) {
+            return rs_nfs_log_json_response(state, tx);
+        }
+    }
+
+    return NULL;
+}
+
 static int JsonNFSLogger(ThreadVars *tv, void *thread_data,
     const Packet *p, Flow *f, void *state, void *tx, uint64_t tx_id)
 {
index 93e17510c562b935038944f256e815d827cade14..a70a510d5631b28336333642721c0eed96e68c1d 100644 (file)
@@ -25,5 +25,8 @@
 #define __OUTPUT_JSON_NFS_H__
 
 void JsonNFSLogRegister(void);
-
+#ifdef HAVE_RUST
+json_t *JsonNFSAddMetadataRPC(const Flow *f, uint64_t tx_id);
+json_t *JsonNFSAddMetadata(const Flow *f, uint64_t tx_id);
+#endif /* HAVE_RUST */
 #endif /* __OUTPUT_JSON_NFS_H__ */