rust: fix clippy lints for clippy::collapsible_if

pull/8073/head
Jason Ish 4 years ago committed by Victor Julien
parent 572505870a
commit 119e02cf81

@ -128,12 +128,9 @@ impl DCERPCUDPState {
fn find_incomplete_tx(&mut self, hdr: &DCERPCHdrUdp) -> Option<&mut DCERPCTransaction> { fn find_incomplete_tx(&mut self, hdr: &DCERPCHdrUdp) -> Option<&mut DCERPCTransaction> {
for tx in &mut self.transactions { for tx in &mut self.transactions {
if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid { if tx.seqnum == hdr.seqnum && tx.activityuuid == hdr.activityuuid && ((hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) || (hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done)) {
if (hdr.pkt_type == DCERPC_TYPE_REQUEST && !tx.req_done) || SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
(hdr.pkt_type == DCERPC_TYPE_RESPONSE && !tx.resp_done) { return Some(tx);
SCLogDebug!("found tx id {}, last tx_id {}, {} {}", tx.id, self.tx_id, tx.seqnum, tx.activityuuid[0]);
return Some(tx);
}
} }
} }
None None

@ -308,10 +308,8 @@ fn http2_detect_sizeupdate_match(
blocks: &[parser::HTTP2FrameHeaderBlock], ctx: &DetectUintData<u64>, blocks: &[parser::HTTP2FrameHeaderBlock], ctx: &DetectUintData<u64>,
) -> std::os::raw::c_int { ) -> std::os::raw::c_int {
for block in blocks.iter() { for block in blocks.iter() {
if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate { if block.error == parser::HTTP2HeaderDecodeStatus::HTTP2HeaderDecodeSizeUpdate && detect_match_uint(ctx, block.sizeupdate) {
if detect_match_uint(ctx, block.sizeupdate) { return 1;
return 1;
}
} }
} }
return 0; return 0;

@ -278,14 +278,12 @@ fn add_proposals(
IkeV2Transform::Auth(IkeTransformAuthType::NONE) => false, IkeV2Transform::Auth(IkeTransformAuthType::NONE) => false,
IkeV2Transform::Auth(_) => true, IkeV2Transform::Auth(_) => true,
_ => false, _ => false,
}) { }) && !transforms.iter().any(|x| match *x {
if !transforms.iter().any(|x| match *x {
IkeV2Transform::Encryption(ref enc) => enc.is_aead(), IkeV2Transform::Encryption(ref enc) => enc.is_aead(),
_ => false, _ => false,
}) { }) {
SCLogDebug!("No integrity transform found"); SCLogDebug!("No integrity transform found");
tx.set_event(IkeEvent::WeakCryptoNoAuth); tx.set_event(IkeEvent::WeakCryptoNoAuth);
}
} }
// Finally // Finally
if direction == Direction::ToClient { if direction == Direction::ToClient {

@ -2086,10 +2086,8 @@ fn smb_probe_tcp_midstream(direction: Direction, slice: &[u8], rdir: *mut u8, be
fn smb_probe_tcp(flags: u8, slice: &[u8], rdir: *mut u8, begins: bool) -> AppProto fn smb_probe_tcp(flags: u8, slice: &[u8], rdir: *mut u8, begins: bool) -> AppProto
{ {
if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM { if flags & STREAM_MIDSTREAM == STREAM_MIDSTREAM && smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 {
if smb_probe_tcp_midstream(flags.into(), slice, rdir, begins) == 1 { unsafe { return ALPROTO_SMB; }
unsafe { return ALPROTO_SMB; }
}
} }
match parse_nbss_record_partial(slice) { match parse_nbss_record_partial(slice) {
Ok((_, ref hdr)) => { Ok((_, ref hdr)) => {

@ -570,15 +570,13 @@ fn smb1_request_record_one<'b>(state: &mut SMBState, r: &SmbRecord<'b>, command:
false false
}, },
}; };
if !have_tx { if !have_tx && smb1_create_new_tx(command) {
if smb1_create_new_tx(command) { let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX);
let tx_key = SMBCommonHdr::from1(r, SMBHDR_TYPE_GENERICTX); let tx = state.new_generic_tx(1, command as u16, tx_key);
let tx = state.new_generic_tx(1, command as u16, tx_key); SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command));
SCLogDebug!("tx {} created for {}/{}", tx.id, command, &smb1_command_string(command)); tx.set_events(events);
tx.set_events(events); if no_response_expected {
if no_response_expected { tx.response_done = true;
tx.response_done = true;
}
} }
} }
} }

@ -635,14 +635,12 @@ pub fn smb2_request_record<'b>(state: &mut SMBState, r: &Smb2Record<'b>)
}, },
}; };
/* if we don't have a tx, create it here (maybe) */ /* if we don't have a tx, create it here (maybe) */
if !have_tx { if !have_tx && smb2_create_new_tx(r.command) {
if smb2_create_new_tx(r.command) { let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX);
let tx_key = SMBCommonHdr::from2(r, SMBHDR_TYPE_GENERICTX); let tx = state.new_generic_tx(2, r.command, tx_key);
let tx = state.new_generic_tx(2, r.command, tx_key); SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}",
SCLogDebug!("TS TX {} command {} created with session_id {} tree_id {} message_id {}", tx.id, r.command, r.session_id, r.tree_id, r.message_id);
tx.id, r.command, r.session_id, r.tree_id, r.message_id); tx.set_events(events);
tx.set_events(events);
}
} }
} }

Loading…
Cancel
Save