]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: Update der, kerberos and snmp parser dependencies
authorEmmanuel Thompson <eet6646@gmail.com>
Mon, 27 Apr 2020 17:09:20 +0000 (13:09 -0400)
committerVictor Julien <victor@inliniac.net>
Wed, 8 Jul 2020 14:50:38 +0000 (16:50 +0200)
- The update to der-parser allows us to use the latest API changes

rust/Cargo.toml.in
rust/src/krb/krb5.rs
rust/src/snmp/snmp.rs

index 0b143d3e1349a656b105cc1542ed9db21d0ac66c..d4c3b271b6a5cd6f5ff1d9bde7cc8da12aa9af56 100644 (file)
@@ -30,12 +30,12 @@ num-traits = "0.2"
 widestring = "0.4"
 md5 = "0.7.0"
 
-der-parser = "3.0"
-kerberos-parser = "0.4"
+der-parser = "4.0"
+kerberos-parser = "0.5"
 
 ntp-parser = "0.4"
 ipsec-parser = "0.5"
-snmp-parser = "0.5"
+snmp-parser = "0.6"
 tls-parser = "0.9"
 x509-parser = "0.6.5"
 libc = "0.2.67"
index 69ada428661c0c006ca4bbf1d028f2eedf0bdac8..d6c8ba54d7540f17939ea730877267fced5b5af7 100644 (file)
@@ -23,6 +23,7 @@ use nom;
 use nom::IResult;
 use nom::number::streaming::be_u32;
 use der_parser::der::der_read_element_header;
+use der_parser::ber::BerClass;
 use kerberos_parser::krb5_parser;
 use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,Realm};
 use crate::applayer::{self, *};
@@ -120,7 +121,7 @@ impl KRB5State {
         match der_read_element_header(i) {
             Ok((_rem,hdr)) => {
                 // Kerberos messages start with an APPLICATION header
-                if hdr.class != 0b01 { return 0; }
+                if hdr.class != BerClass::Application { return 0; }
                 match hdr.tag.0 {
                     10 => {
                         self.req_id = 10;
@@ -443,7 +444,7 @@ pub extern "C" fn rs_krb5_probing_parser(_flow: *const Flow,
     match der_read_element_header(slice) {
         Ok((rem, ref hdr)) => {
             // Kerberos messages start with an APPLICATION header
-            if hdr.class != 0b01 { return unsafe{ALPROTO_FAILED}; }
+            if hdr.class != BerClass::Application { return unsafe{ALPROTO_FAILED}; }
             // Tag number should be <= 30
             if hdr.tag.0 >= 30 { return unsafe{ALPROTO_FAILED}; }
             // Kerberos messages contain sequences
index 0040f50f443066fabaf44db479dbe3bdffd95308..1a2b357f640402914c4880c515ccc798059982f0 100644 (file)
@@ -51,33 +51,33 @@ impl SNMPEvent {
     }
 }
 
-pub struct SNMPState {
+pub struct SNMPState<'a> {
     /// SNMP protocol version
     pub version: u32,
 
     /// List of transactions for this session
-    transactions: Vec<SNMPTransaction>,
+    transactions: Vec<SNMPTransaction<'a>>,
 
     /// tx counter for assigning incrementing id's to tx's
     tx_id: u64,
 }
 
-pub struct SNMPPduInfo {
+pub struct SNMPPduInfo<'a> {
     pub pdu_type: PduType,
 
     pub err: ErrorStatus,
 
-    pub trap_type: Option<(TrapType,Oid,NetworkAddress)>,
+    pub trap_type: Option<(TrapType,Oid<'a>,NetworkAddress)>,
 
-    pub vars: Vec<Oid>,
+    pub vars: Vec<Oid<'a>>,
 }
 
-pub struct SNMPTransaction {
+pub struct SNMPTransaction<'a> {
     /// PDU version
     pub version: u32,
 
     /// PDU info, if present (and cleartext)
-    pub info: Option<SNMPPduInfo>,
+    pub info: Option<SNMPPduInfo<'a>>,
 
     /// Community, if present (SNMPv2)
     pub community: Option<String>,
@@ -103,8 +103,8 @@ pub struct SNMPTransaction {
 
 
 
-impl SNMPState {
-    pub fn new() -> SNMPState {
+impl<'a> SNMPState<'a> {
+    pub fn new() -> SNMPState<'a> {
         SNMPState{
             version: 0,
             transactions: Vec::new(),
@@ -113,8 +113,8 @@ impl SNMPState {
     }
 }
 
-impl Default for SNMPPduInfo {
-    fn default() -> SNMPPduInfo {
+impl<'a> Default for SNMPPduInfo<'a> {
+    fn default() -> SNMPPduInfo<'a> {
         SNMPPduInfo{
             pdu_type: PduType(0),
             err: ErrorStatus::NoError,
@@ -124,8 +124,8 @@ impl Default for SNMPPduInfo {
     }
 }
 
-impl SNMPState {
-    fn add_pdu_info(&mut self, pdu: &SnmpPdu, tx: &mut SNMPTransaction) {
+impl<'a> SNMPState<'a> {
+    fn add_pdu_info(&mut self, pdu: &SnmpPdu<'a>, tx: &mut SNMPTransaction<'a>) {
         let mut pdu_info = SNMPPduInfo::default();
         pdu_info.pdu_type = pdu.pdu_type();
         match *pdu {
@@ -138,13 +138,14 @@ impl SNMPState {
                 pdu_info.trap_type = Some((t.generic_trap,t.enterprise.clone(),t.agent_addr.clone()));
             }
         }
-        for ref var in pdu.vars_iter() {
-            pdu_info.vars.push(var.oid.clone());
+
+        for var in pdu.vars_iter() {
+            pdu_info.vars.push(var.oid.to_owned());
         }
         tx.info = Some(pdu_info);
     }
 
-    fn handle_snmp_v12(&mut self, msg:SnmpMessage, _direction: u8) -> i32 {
+    fn handle_snmp_v12(&mut self, msg: SnmpMessage<'a>, _direction: u8) -> i32 {
         let mut tx = self.new_tx();
         // in the message, version is encoded as 0 (version 1) or 1 (version 2)
         if self.version != msg.version + 1 {
@@ -157,7 +158,7 @@ impl SNMPState {
         0
     }
 
-    fn handle_snmp_v3(&mut self, msg: SnmpV3Message, _direction: u8) -> i32 {
+    fn handle_snmp_v3(&mut self, msg: SnmpV3Message<'a>, _direction: u8) -> i32 {
         let mut tx = self.new_tx();
         if self.version != msg.version {
             SCLogDebug!("SNMP version mismatch: expected {}, received {}", self.version, msg.version);
@@ -186,7 +187,7 @@ impl SNMPState {
     /// Parse an SNMP request message
     ///
     /// Returns 0 if successful, or -1 on error
-    fn parse(&mut self, i: &[u8], direction: u8) -> i32 {
+    fn parse(&mut self, i: &'a [u8], direction: u8) -> i32 {
         if self.version == 0 {
             match parse_pdu_enveloppe_version(i) {
                 Ok((_,x)) => self.version = x,
@@ -211,7 +212,7 @@ impl SNMPState {
         self.transactions.clear();
     }
 
-    fn new_tx(&mut self) -> SNMPTransaction {
+    fn new_tx(&mut self) -> SNMPTransaction<'a> {
         self.tx_id += 1;
         SNMPTransaction::new(self.version, self.tx_id)
     }
@@ -264,8 +265,8 @@ impl SNMPState {
     }
 }
 
-impl SNMPTransaction {
-    pub fn new(version: u32, id: u64) -> SNMPTransaction {
+impl<'a> SNMPTransaction<'a> {
+    pub fn new(version: u32, id: u64) -> SNMPTransaction<'a> {
         SNMPTransaction {
             version,
             info: None,
@@ -287,7 +288,7 @@ impl SNMPTransaction {
     }
 }
 
-impl Drop for SNMPTransaction {
+impl<'a> Drop for SNMPTransaction<'a> {
     fn drop(&mut self) {
         self.free();
     }