Skip to content

Commit

Permalink
mysql: fix CI
Browse files Browse the repository at this point in the history
Task #3446
  • Loading branch information
QianKaiLin committed Oct 21, 2024
1 parent 9bfc934 commit d9d6032
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
6 changes: 3 additions & 3 deletions rust/src/mysql/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl MysqlState {
}

fn new_tx(&mut self, command: String) -> MysqlTransaction {
let mut tx = MysqlTransaction::new(self.version.clone().unwrap());
let mut tx = MysqlTransaction::new(self.version.clone().unwrap_or_default());
self.tx_id += 1;
tx.tx_id = self.tx_id;
tx.tls = self.tls;
Expand Down Expand Up @@ -528,7 +528,7 @@ impl MysqlState {

// If there was gap, check we can sync up again.
if self.request_gap {
if !probe(i).is_ok() {
if probe(i).is_err() {
SCLogDebug!("Suricata interprets there's a gap in the request");
return AppLayerResult::ok();
}
Expand Down Expand Up @@ -894,7 +894,7 @@ impl MysqlState {
}

if self.response_gap {
if !probe(i).is_ok() {
if probe(i).is_err() {
SCLogDebug!("Suricata interprets there's a gap in the response");
return AppLayerResult::ok();
}
Expand Down
27 changes: 7 additions & 20 deletions rust/src/mysql/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,15 +744,12 @@ fn parse_stmt_execute_cmd(
let param_types = if let Some(new_param_types) = new_param_types {
Some(new_param_types)
} else {
match param_types {
Some(param_types) => Some(
param_types
.iter()
.map(|param_type| (param_type.field_type, param_type.flags != 0))
.collect(),
),
None => None,
}
param_types.map(|param_types| {
param_types
.iter()
.map(|param_type| (param_type.field_type, param_type.flags != 0))
.collect()
})
};

let consumed = old.len() - i.len();
Expand Down Expand Up @@ -1096,7 +1093,7 @@ fn parse_resultset_row_texts(i: &[u8]) -> IResult<&[u8], Vec<String>> {
length -= consumed;
}

Ok((rem, texts))
Ok((&[], texts))
}

fn parse_resultset_row(i: &[u8]) -> IResult<&[u8], MysqlResultSetRow> {
Expand Down Expand Up @@ -2125,16 +2122,6 @@ mod test {

use super::*;

#[test]
fn test_parse_packet_header() {
let pkt: &[u8] = &[0x07, 0x00, 0x00, 0x03];
let (rem, packet_header) = parse_packet_header(pkt).unwrap();

assert!(rem.is_empty());
assert_eq!(packet_header.pkt_len, 7);
assert_eq!(packet_header.pkt_num, 3);
}

#[test]
fn test_parse_handshake_request() {
let pkt: &[u8] = &[
Expand Down
3 changes: 1 addition & 2 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,7 @@ void OutputRegisterRootLoggers(void)
// underscore instead of dash for bittorrent_dht
RegisterSimpleJsonApplayerLogger(
ALPROTO_BITTORRENT_DHT, rs_bittorrent_dht_logger_log, "bittorrent_dht");
RegisterSimpleJsonApplayerLogger(
ALPROTO_MYSQL, SCMysqlLogger, "mysql");
RegisterSimpleJsonApplayerLogger(ALPROTO_MYSQL, SCMysqlLogger, "mysql");

OutputPacketLoggerRegister();
OutputFiledataLoggerRegister();
Expand Down

0 comments on commit d9d6032

Please sign in to comment.