Skip to content

Commit

Permalink
rust: update parser dependencies
Browse files Browse the repository at this point in the history
Time locked to 0.3.20 to guarantee MSRV of 1.63.
Update snmp-parser to 0.10.0.
Update asn1-rs to 0.6.1.
Update kerberos-parser to 0.8.0.
Update x509-parser 0.16.0.
Update der-parser to 9.0.0.
Remove specific use of der-parser 6.

Ticket: #6817.
Ticket: #6818.
  • Loading branch information
victorjulien committed Mar 2, 2024
1 parent 6d0e11e commit 1f31613
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 89 deletions.
111 changes: 49 additions & 62 deletions rust/Cargo.lock.in

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions rust/Cargo.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,16 @@ hkdf = "~0.12.3"
aes = "~0.7.5"
aes-gcm = "~0.9.4"

der-parser = "~8.2.0"
kerberos-parser = { version = "~0.7.1", default_features = false }

# Kerberos parsing still depends on der-parser 6.0.1.
der-parser6 = { package = "der-parser", version = "~6.0.1", default_features = false }
der-parser = { version = "~9.0.0", default_features = false }
kerberos-parser = { version = "~0.8.0", default_features = false }

sawp-modbus = "~0.12.1"
sawp = "~0.12.1"
ntp-parser = "~0.6.0"
ipsec-parser = "~0.7.0"
snmp-parser = "~0.9.0"
snmp-parser = "~0.10.0"
tls-parser = "~0.11.0"
x509-parser = "~0.15.0"
x509-parser = "~0.16.0"
libc = "~0.2.82"
sha2 = "~0.10.2"
digest = "~0.10.3"
Expand All @@ -61,11 +58,10 @@ regex = "~1.5.5"
lazy_static = "~1.4.0"
base64 = "~0.13.0"
bendy = { version = "~0.3.3", default-features = false }
asn1-rs = { version = "~0.5.2" }
asn1-rs = { version = "~0.6.1" }

# The time crate has a policy of supporting Rust versions up to 6
# month olds, so it needs to be pinned even at the patch level.
time = "=0.3.13"
# last version to work with MSRV 1.63
time = "=0.3.20"

suricata-derive = { path = "./derive" }

Expand Down
14 changes: 7 additions & 7 deletions rust/src/kerberos.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018 Open Information Security Foundation
/* Copyright (C) 2018-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
Expand All @@ -20,11 +20,11 @@
use nom7::IResult;
use nom7::error::{ErrorKind, ParseError};
use nom7::number::streaming::le_u16;
use der_parser6;
use der_parser6::der::parse_der_oid;
use der_parser6::error::BerError;
use der_parser;
use der_parser::der::parse_der_oid;
use der_parser::error::BerError;
use kerberos_parser::krb5::{ApReq, PrincipalName, Realm};
use kerberos_parser::krb5_parser::parse_ap_req;
use asn1_rs::FromDer;

#[derive(Debug)]
pub enum SecBlobError {
Expand Down Expand Up @@ -57,14 +57,14 @@ pub struct Kerberos5Ticket {

fn parse_kerberos5_request_do(blob: &[u8]) -> IResult<&[u8], ApReq, SecBlobError>
{
let (_,b) = der_parser6::parse_der(blob).map_err(nom7::Err::convert)?;
let (_,b) = der_parser::parse_der(blob).map_err(nom7::Err::convert)?;
let blob = b.as_slice().or(
Err(nom7::Err::Error(SecBlobError::KrbFmtError))
)?;
let parser = |i| {
let (i, _base_o) = parse_der_oid(i)?;
let (i, _tok_id) = le_u16(i)?;
let (i, ap_req) = parse_ap_req(i)?;
let (i, ap_req) = ApReq::from_der(i)?;
Ok((i, ap_req))
};
parser(blob).map_err(nom7::Err::convert)
Expand Down
7 changes: 4 additions & 3 deletions rust/src/krb/krb5.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2017-2021 Open Information Security Foundation
/* Copyright (C) 2017-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
Expand All @@ -24,7 +24,8 @@ use nom7::number::streaming::be_u32;
use der_parser::der::der_read_element_header;
use der_parser::ber::Class;
use kerberos_parser::krb5_parser;
use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,Realm};
use kerberos_parser::krb5::{EncryptionType,ErrorCode,MessageType,PrincipalName,Realm,KrbError};
use asn1_rs::FromDer;
use crate::applayer::{self, *};
use crate::core;
use crate::core::{AppProto,Flow,ALPROTO_FAILED,ALPROTO_UNKNOWN,Direction};
Expand Down Expand Up @@ -203,7 +204,7 @@ impl KRB5State {
self.req_id = 0;
},
30 => {
let res = krb5_parser::parse_krb_error(i);
let res = KrbError::from_der(i);
if let Ok((_,error)) = res {
let mut tx = self.new_tx(direction);
if self.req_id > 0 {
Expand Down
12 changes: 6 additions & 6 deletions rust/src/smb/auth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2018 Open Information Security Foundation
/* Copyright (C) 2018-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
Expand All @@ -21,12 +21,12 @@ use crate::smb::ntlmssp_records::*;
use crate::smb::smb::*;

use nom7::{Err, IResult};
use der_parser6::ber::BerObjectContent;
use der_parser6::der::{parse_der_oid, parse_der_sequence};
use der_parser::ber::BerObjectContent;
use der_parser::der::{parse_der_oid, parse_der_sequence};

fn parse_secblob_get_spnego(blob: &[u8]) -> IResult<&[u8], &[u8], SecBlobError>
{
let (rem, base_o) = der_parser6::parse_der(blob).map_err(Err::convert)?;
let (rem, base_o) = der_parser::parse_der(blob).map_err(Err::convert)?;
SCLogDebug!("parse_secblob_get_spnego: base_o {:?}", base_o);
let d = match base_o.content.as_slice() {
Err(_) => { return Err(Err::Error(SecBlobError::NotSpNego)); },
Expand Down Expand Up @@ -59,7 +59,7 @@ fn parse_secblob_get_spnego(blob: &[u8]) -> IResult<&[u8], &[u8], SecBlobError>

fn parse_secblob_spnego_start(blob: &[u8]) -> IResult<&[u8], &[u8], SecBlobError>
{
let (rem, o) = der_parser6::parse_der(blob).map_err(Err::convert)?;
let (rem, o) = der_parser::parse_der(blob).map_err(Err::convert)?;
let d = match o.content.as_slice() {
Ok(d) => {
SCLogDebug!("d: next data len {}",d.len());
Expand Down Expand Up @@ -96,7 +96,7 @@ fn parse_secblob_spnego(blob: &[u8]) -> Option<SpnegoRequest>
Ok(s) => s,
_ => { continue; },
};
let o = match der_parser6::parse_der(n) {
let o = match der_parser::parse_der(n) {
Ok((_,x)) => x,
_ => { continue; },
};
Expand Down

0 comments on commit 1f31613

Please sign in to comment.