rust: fix lint warning for clippy::enum's name

Ticket: #4597
pull/7996/head
Haleema Khan 4 years ago committed by Victor Julien
parent 5365fdccf7
commit 6c922e0b98

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

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

@ -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),
}
}
}

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

Loading…
Cancel
Save