From: Jeff Lucovsky Date: Sun, 31 Jul 2022 14:45:38 +0000 (-0400) Subject: rust/detect: Create detect module for rule parsing X-Git-Tag: suricata-7.0.0-beta1~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bfe427a7452d22f8061e866c4ce69ba03d15001;p=thirdparty%2Fsuricata.git rust/detect: Create detect module for rule parsing This commit creates a module named "detect" for rule parsing logic. As part of this commit, detect.rs is moved from its toplevel position into the new module. Thus, use crate::detect::detect to refer to items within detect.rs (instead of create::detect). Ticket: 5077 --- diff --git a/rust/src/dcerpc/detect.rs b/rust/src/dcerpc/detect.rs index 63e5188cc5..b06e1232ac 100644 --- a/rust/src/dcerpc/detect.rs +++ b/rust/src/dcerpc/detect.rs @@ -19,7 +19,7 @@ use super::dcerpc::{ DCERPCState, DCERPCTransaction, DCERPC_TYPE_REQUEST, DCERPC_TYPE_RESPONSE, DCERPC_UUID_ENTRY_FLAG_FF, }; -use crate::detect::{detect_match_uint, detect_parse_uint, DetectUintData}; +use crate::detect::detect::{detect_match_uint, detect_parse_uint, DetectUintData}; use std::ffi::CStr; use std::os::raw::{c_char, c_void}; use uuid::Uuid; @@ -295,7 +295,7 @@ pub unsafe extern "C" fn rs_dcerpc_opnum_free(ptr: *mut c_void) { #[cfg(test)] mod test { use super::*; - use crate::detect::DetectUintMode; + use crate::detect::detect::DetectUintMode; fn extract_op_version(i: &str) -> Result<(DetectUintMode, u16), ()> { match detect_parse_uint(i) { diff --git a/rust/src/detect_parser/byte_math.rs b/rust/src/detect/byte_math.rs similarity index 99% rename from rust/src/detect_parser/byte_math.rs rename to rust/src/detect/byte_math.rs index 09e3820e4a..98e3def601 100644 --- a/rust/src/detect_parser/byte_math.rs +++ b/rust/src/detect/byte_math.rs @@ -17,8 +17,8 @@ // Author: Jeff Lucovsky -use crate::detect_parser::error::RuleParseError; -use crate::detect_parser::parser::{parse_token, take_until_whitespace}; +use crate::detect::error::RuleParseError; +use crate::detect::parser::{parse_token, take_until_whitespace}; use std::ffi::{CStr, CString}; use std::os::raw::c_char; diff --git a/rust/src/detect.rs b/rust/src/detect/detect.rs similarity index 100% rename from rust/src/detect.rs rename to rust/src/detect/detect.rs diff --git a/rust/src/detect_parser/error.rs b/rust/src/detect/error.rs similarity index 100% rename from rust/src/detect_parser/error.rs rename to rust/src/detect/error.rs diff --git a/rust/src/detect_parser/mod.rs b/rust/src/detect/mod.rs similarity index 97% rename from rust/src/detect_parser/mod.rs rename to rust/src/detect/mod.rs index 308e01d1da..1c492a0f53 100644 --- a/rust/src/detect_parser/mod.rs +++ b/rust/src/detect/mod.rs @@ -16,5 +16,6 @@ */ pub mod byte_math; +pub mod detect; pub mod error; pub mod parser; diff --git a/rust/src/detect_parser/parser.rs b/rust/src/detect/parser.rs similarity index 96% rename from rust/src/detect_parser/parser.rs rename to rust/src/detect/parser.rs index eccf8fa821..0ac584634d 100644 --- a/rust/src/detect_parser/parser.rs +++ b/rust/src/detect/parser.rs @@ -15,7 +15,7 @@ * 02110-1301, USA. */ -use crate::detect_parser::error::RuleParseError; +use crate::detect::error::RuleParseError; use nom7::bytes::complete::is_not; use nom7::character::complete::multispace0; diff --git a/rust/src/http2/detect.rs b/rust/src/http2/detect.rs index a6452aef21..ce79540ef7 100644 --- a/rust/src/http2/detect.rs +++ b/rust/src/http2/detect.rs @@ -20,7 +20,7 @@ use super::http2::{ }; use super::parser; use crate::core::Direction; -use crate::detect::{detect_match_uint, DetectUintData}; +use crate::detect::detect::{detect_match_uint, DetectUintData}; use std::ffi::CStr; use std::str::FromStr; diff --git a/rust/src/http2/parser.rs b/rust/src/http2/parser.rs index bf2d2d13c7..a3ad68a456 100644 --- a/rust/src/http2/parser.rs +++ b/rust/src/http2/parser.rs @@ -17,7 +17,7 @@ use super::huffman; use crate::common::nom7::bits; -use crate::detect::{detect_parse_uint, DetectUintData}; +use crate::detect::detect::{detect_parse_uint, DetectUintData}; use crate::http2::http2::{HTTP2DynTable, HTTP2_MAX_TABLESIZE}; use nom7::bits::streaming::take as take_bits; use nom7::branch::alt; @@ -749,7 +749,7 @@ pub fn http2_parse_frame_settings(i: &[u8]) -> IResult<&[u8], Vec