]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/snmp: log version from tx
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 5 Jun 2023 15:04:04 +0000 (17:04 +0200)
committerVictor Julien <vjulien@oisf.net>
Thu, 8 Jun 2023 17:23:19 +0000 (19:23 +0200)
and not the one from state

If a SNMP flow starts with a V2 version transaction,
then there is a V3i version transaction,
we will now log V3 for the second transaction

rust/src/snmp/log.rs
src/output-json-alert.c
src/output-json-snmp.c

index e37bbba30c06c48b19cd334cb5d39a79c6038304..83414816c466721733b1cfc171914243dc18444a 100644 (file)
@@ -18,7 +18,7 @@
 // written by Pierre Chifflier  <chifflier@wzdftpd.net>
 
 use crate::jsonbuilder::{JsonBuilder, JsonError};
-use crate::snmp::snmp::{SNMPState,SNMPTransaction};
+use crate::snmp::snmp::SNMPTransaction;
 use crate::snmp::snmp_parser::{NetworkAddress,PduType};
 use std::borrow::Cow;
 
@@ -37,9 +37,9 @@ fn str_of_pdu_type(t:&PduType) -> Cow<str> {
     }
 }
 
-fn snmp_log_response(jsb: &mut JsonBuilder, state: &mut SNMPState, tx: &mut SNMPTransaction) -> Result<(), JsonError>
+fn snmp_log_response(jsb: &mut JsonBuilder, tx: &mut SNMPTransaction) -> Result<(), JsonError>
 {
-    jsb.set_uint("version", state.version as u64)?;
+    jsb.set_uint("version", tx.version as u64)?;
     if tx.encrypted {
         jsb.set_string("pdu_type", "encrypted")?;
     } else {
@@ -75,7 +75,7 @@ fn snmp_log_response(jsb: &mut JsonBuilder, state: &mut SNMPState, tx: &mut SNMP
 }
 
 #[no_mangle]
-pub extern "C" fn rs_snmp_log_json_response(jsb: &mut JsonBuilder, state: &mut SNMPState, tx: &mut SNMPTransaction) -> bool
+pub extern "C" fn rs_snmp_log_json_response(jsb: &mut JsonBuilder, tx: &mut SNMPTransaction) -> bool
 {
-    snmp_log_response(jsb, state, tx).is_ok()
+    snmp_log_response(jsb, tx).is_ok()
 }
index d7918e81ffaa0d21f9b8631cf9363c0bb0e730c3..472e6f98cded7904c9f075b71a88bb9c10da10d1 100644 (file)
@@ -253,7 +253,7 @@ static void AlertJsonSNMP(const Flow *f, const uint64_t tx_id, JsonBuilder *js)
                 tx_id);
         if (tx != NULL) {
             jb_open_object(js, "snmp");
-            rs_snmp_log_json_response(js, snmp_state, tx);
+            rs_snmp_log_json_response(js, tx);
             jb_close(js);
         }
     }
index facf50770ac89111a4c69f12baf3a84a5db616bd..27545b6f6903e6ecd6c7af70bdf8a706a2e9f521 100644 (file)
@@ -60,7 +60,7 @@ static int JsonSNMPLogger(ThreadVars *tv, void *thread_data,
     }
 
     jb_open_object(jb, "snmp");
-    if (!rs_snmp_log_json_response(jb, state, snmptx)) {
+    if (!rs_snmp_log_json_response(jb, snmptx)) {
         goto error;
     }
     jb_close(jb);