rust: Update der, kerberos and snmp parser dependencies

- The update to der-parser allows us to use the latest API changes
pull/5149/head
Emmanuel Thompson 5 years ago committed by Victor Julien
parent dfcc8a88f6
commit 6b8517dc12

@ -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"

@ -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

@ -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();
}

Loading…
Cancel
Save