]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust: fix lint warning for clippy::enum's name
authorHaleema Khan <hsadia538@gmail.com>
Wed, 12 Oct 2022 05:24:18 +0000 (10:24 +0500)
committerVictor Julien <vjulien@oisf.net>
Thu, 13 Oct 2022 09:25:42 +0000 (11:25 +0200)
Ticket: #4597

rust/src/http2/decompression.rs
rust/src/lib.rs
rust/src/ssh/parser.rs
rust/src/ssh/ssh.rs

index 164ff3224d021304733102860dcf086f0f6f650c..caa9b72aaa485754bc76526b7dd38e9126242e53 100644 (file)
@@ -27,11 +27,11 @@ pub const HTTP2_DECOMPRESSION_CHUNK_SIZE: usize = 0x1000; // 4096
 #[repr(u8)]
 #[derive(Copy, Clone, PartialOrd, PartialEq, Debug)]
 pub enum HTTP2ContentEncoding {
-    HTTP2ContentEncodingUnknown = 0,
-    HTTP2ContentEncodingGzip = 1,
-    HTTP2ContentEncodingBr = 2,
-    HTTP2ContentEncodingDeflate = 3,
-    HTTP2ContentEncodingUnrecognized = 4,
+    Unknown = 0,
+    Gzip = 1,
+    Br = 2,
+    Deflate = 3,
+    Unrecognized = 4,
 }
 
 //a cursor turning EOF into blocking errors
@@ -160,28 +160,28 @@ fn http2_decompress<'a>(
 impl HTTP2DecoderHalf {
     pub fn new() -> HTTP2DecoderHalf {
         HTTP2DecoderHalf {
-            encoding: HTTP2ContentEncoding::HTTP2ContentEncodingUnknown,
+            encoding: HTTP2ContentEncoding::Unknown,
             decoder: HTTP2Decompresser::UNASSIGNED,
         }
     }
 
     pub fn http2_encoding_fromvec(&mut self, input: &[u8]) {
         //use first encoding...
-        if self.encoding == HTTP2ContentEncoding::HTTP2ContentEncodingUnknown {
+        if self.encoding == HTTP2ContentEncoding::Unknown {
             if input == b"gzip" {
-                self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingGzip;
+                self.encoding = HTTP2ContentEncoding::Gzip;
                 self.decoder = HTTP2Decompresser::GZIP(GzDecoder::new(HTTP2cursor::new()));
             } else if input == b"deflate" {
-                self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingDeflate;
+                self.encoding = HTTP2ContentEncoding::Deflate;
                 self.decoder = HTTP2Decompresser::DEFLATE(DeflateDecoder::new(HTTP2cursor::new()));
             } else if input == b"br" {
-                self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingBr;
+                self.encoding = HTTP2ContentEncoding::Br;
                 self.decoder = HTTP2Decompresser::BROTLI(brotli::Decompressor::new(
                     HTTP2cursor::new(),
                     HTTP2_DECOMPRESSION_CHUNK_SIZE,
                 ));
             } else {
-                self.encoding = HTTP2ContentEncoding::HTTP2ContentEncodingUnrecognized;
+                self.encoding = HTTP2ContentEncoding::Unrecognized;
             }
         }
     }
index 0a5086208965d37cdbb3778efb30cebcfe5627e9..3a65448e521b68befcf71323e265226f0b72161c 100644 (file)
@@ -53,7 +53,6 @@
 #![allow(clippy::match_ref_pats)]
 #![allow(clippy::module_inception)]
 #![allow(clippy::needless_range_loop)]
-#![allow(clippy::enum_variant_names)]
 #![allow(clippy::if_same_then_else)]
 #![allow(clippy::match_like_matches_macro)]
 #![allow(clippy::extra_unused_lifetimes)]
index 6dced26a41b0750d09476881aeb835a9512c7efa..3c2b79fa0b01ff0cfd05468bcff168329be937fe 100644 (file)
@@ -30,34 +30,34 @@ use std::fmt;
 
 #[derive(PartialEq, Eq, Copy, Clone, Debug)]
 pub enum MessageCode {
-       SshMsgDisconnect,
-       SshMsgIgnore,
-       SshMsgUnimplemented,
-       SshMsgDebug,
-       SshMsgServiceRequest,
-       SshMsgServiceAccept,
-       SshMsgKexinit,
-       SshMsgNewKeys,
-       SshMsgKexdhInit,
-       SshMsgKexdhReply,
+       Disconnect,
+       Ignore,
+       Unimplemented,
+       Debug,
+       ServiceRequest,
+       ServiceAccept,
+       Kexinit,
+       NewKeys,
+       KexdhInit,
+       KexdhReply,
        
-       SshMsgUndefined(u8),
+       Undefined(u8),
 }
 
 impl MessageCode {
     fn from_u8(value: u8) -> MessageCode {
         match value {
-            1 => MessageCode::SshMsgDisconnect,
-            2 => MessageCode::SshMsgIgnore,
-            3 => MessageCode::SshMsgUnimplemented,
-            4 => MessageCode::SshMsgDebug,
-            5 => MessageCode::SshMsgServiceRequest,
-            6 => MessageCode::SshMsgServiceAccept,
-            20 => MessageCode::SshMsgKexinit,
-            21 => MessageCode::SshMsgNewKeys,
-            30 => MessageCode::SshMsgKexdhInit,
-            31 => MessageCode::SshMsgKexdhReply,
-            _ => MessageCode::SshMsgUndefined(value),
+            1 => MessageCode::Disconnect,
+            2 => MessageCode::Ignore,
+            3 => MessageCode::Unimplemented,
+            4 => MessageCode::Debug,
+            5 => MessageCode::ServiceRequest,
+            6 => MessageCode::ServiceAccept,
+            20 => MessageCode::Kexinit,
+            21 => MessageCode::NewKeys,
+            30 => MessageCode::KexdhInit,
+            31 => MessageCode::KexdhReply,
+            _ => MessageCode::Undefined(value),
         }
     }
 }
index 3dd02d0c84566ba73e2641e836c353e09c0a9087..1d6924ec7652b7d9ad699dd357eef3df093939e5 100644 (file)
@@ -66,7 +66,7 @@ impl SshHeader {
     pub fn new() -> SshHeader {
         SshHeader {
             record_left: 0,
-            record_left_msg: parser::MessageCode::SshMsgUndefined(0),
+            record_left_msg: parser::MessageCode::Undefined(0),
 
             flags: SSHConnectionState::SshStateInProgress,
             protover: Vec::new(),
@@ -132,7 +132,7 @@ impl SSHState {
                 let start = hdr.record_left as usize;
                 match hdr.record_left_msg {
                     // parse reassembled tcp segments
-                    parser::MessageCode::SshMsgKexinit if hassh_is_enabled() => {
+                    parser::MessageCode::Kexinit if hassh_is_enabled() => {
                         if let Ok((_rem, key_exchange)) =
                             parser::ssh_parse_key_exchange(&input[..start])
                         {
@@ -142,7 +142,7 @@ impl SSHState {
                                 &resp,
                             );
                         }
-                        hdr.record_left_msg = parser::MessageCode::SshMsgUndefined(0);
+                        hdr.record_left_msg = parser::MessageCode::Undefined(0);
                     }
                     _ => {}
                 }
@@ -156,14 +156,14 @@ impl SSHState {
                 Ok((rem, head)) => {
                     SCLogDebug!("SSH valid record {}", head);
                     match head.msg_code {
-                        parser::MessageCode::SshMsgKexinit if hassh_is_enabled() => {
+                        parser::MessageCode::Kexinit if hassh_is_enabled() => {
                             //let endkex = SSH_RECORD_HEADER_LEN + head.pkt_len - 2;
                             let endkex = input.len() - rem.len();
                             if let Ok((_, key_exchange)) = parser::ssh_parse_key_exchange(&input[SSH_RECORD_HEADER_LEN..endkex]) {
                                 key_exchange.generate_hassh(&mut hdr.hassh_string, &mut hdr.hassh, &resp);
                             }
                         }
-                        parser::MessageCode::SshMsgNewKeys => {
+                        parser::MessageCode::NewKeys => {
                             hdr.flags = SSHConnectionState::SshStateFinished;
                             if ohdr.flags >= SSHConnectionState::SshStateFinished {
                                 unsafe {
@@ -190,15 +190,15 @@ impl SSHState {
                             hdr.record_left = head.pkt_len - 2 - remlen;
                             //header with rem as incomplete data
                             match head.msg_code { 
-                                parser::MessageCode::SshMsgNewKeys => {
+                                parser::MessageCode::NewKeys => {
                                     hdr.flags = SSHConnectionState::SshStateFinished;
                                 }
-                                parser::MessageCode::SshMsgKexinit if hassh_is_enabled() => {
+                                parser::MessageCode::Kexinit if hassh_is_enabled() => {
                                     // check if buffer is bigger than maximum reassembled packet size
                                     hdr.record_left = head.pkt_len - 2;
                                     if hdr.record_left < SSH_MAX_REASSEMBLED_RECORD_LEN as u32 {
                                         // saving type of incomplete kex message
-                                        hdr.record_left_msg = parser::MessageCode::SshMsgKexinit;
+                                        hdr.record_left_msg = parser::MessageCode::Kexinit;
                                         return AppLayerResult::incomplete(
                                             (il - rem.len()) as u32,
                                             (head.pkt_len - 2) as u32