]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/detect: Create detect module for rule parsing
authorJeff Lucovsky <jlucovsky@oisf.net>
Sun, 31 Jul 2022 14:45:38 +0000 (10:45 -0400)
committerVictor Julien <vjulien@oisf.net>
Fri, 23 Sep 2022 13:51:23 +0000 (15:51 +0200)
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

rust/src/dcerpc/detect.rs
rust/src/detect/byte_math.rs [moved from rust/src/detect_parser/byte_math.rs with 99% similarity]
rust/src/detect/detect.rs [moved from rust/src/detect.rs with 100% similarity]
rust/src/detect/error.rs [moved from rust/src/detect_parser/error.rs with 100% similarity]
rust/src/detect/mod.rs [moved from rust/src/detect_parser/mod.rs with 97% similarity]
rust/src/detect/parser.rs [moved from rust/src/detect_parser/parser.rs with 96% similarity]
rust/src/http2/detect.rs
rust/src/http2/parser.rs
rust/src/lib.rs
rust/src/smb/detect.rs

index 63e5188cc542635d8b187482f995075e0cdedc9d..b06e1232aca5f43c411f0e72935874bc0f72e8bf 100644 (file)
@@ -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) {
similarity index 99%
rename from rust/src/detect_parser/byte_math.rs
rename to rust/src/detect/byte_math.rs
index 09e3820e4ae72f07415c85844f4ab6be847a627b..98e3def601eb1235bd867b7ce520ee8b0b5f9cbb 100644 (file)
@@ -17,8 +17,8 @@
 
 // Author: Jeff Lucovsky <jlucovsky@oisf.net>
 
-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;
 
similarity index 100%
rename from rust/src/detect.rs
rename to rust/src/detect/detect.rs
similarity index 97%
rename from rust/src/detect_parser/mod.rs
rename to rust/src/detect/mod.rs
index 308e01d1dafe4fd547e61f22a0b1d0ed0a9331c7..1c492a0f534b7520a730a6729fcdd4064de6ba9d 100644 (file)
@@ -16,5 +16,6 @@
  */
 
 pub mod byte_math;
+pub mod detect;
 pub mod error;
 pub mod parser;
similarity index 96%
rename from rust/src/detect_parser/parser.rs
rename to rust/src/detect/parser.rs
index eccf8fa821104222ad28b67303d964710e47cba9..0ac584634d74904793fc83751b83c1b14e36d28d 100644 (file)
@@ -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;
index a6452aef2157549e81ae545ee967321f3358dbd2..ce79540ef701d8b81c9fc518db2ada1e8f6c619d 100644 (file)
@@ -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;
 
index bf2d2d13c796b8ec6f1be289e25d3a075107dec7..a3ad68a456c4afac5a04d675bc08c24a50390362 100644 (file)
@@ -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<HTTP2FrameSett
 mod tests {
 
     use super::*;
-    use crate::detect::DetectUintMode;
+    use crate::detect::detect::DetectUintMode;
 
     #[test]
     fn test_http2_parse_header() {
index d0ea2af89bb62f511a1b89c109d50ee7a114a2e8..a8b729bf61039b3ab54d76d8a61cd70b25360b2d 100644 (file)
@@ -113,7 +113,6 @@ pub mod smb;
 pub mod krb;
 pub mod dcerpc;
 pub mod modbus;
-pub mod detect_parser;
 
 pub mod ike;
 pub mod snmp;
index 97ab525d9f5589dd9b47d4824a35c63212d74146..82a423333ad582c7b9f55c6b37da42fc1cbdd749 100644 (file)
@@ -20,7 +20,7 @@ use crate::core::*;
 use crate::smb::smb::*;
 use crate::dcerpc::detect::{DCEIfaceData, DCEOpnumData, DETECT_DCE_OPNUM_RANGE_UNINITIALIZED};
 use crate::dcerpc::dcerpc::DCERPC_TYPE_REQUEST;
-use crate::detect::detect_match_uint;
+use crate::detect::detect::detect_match_uint;
 
 #[no_mangle]
 pub unsafe extern "C" fn rs_smb_tx_get_share(tx: &mut SMBTransaction,