Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions engine/src/ast/field_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ mod tests {

#[test]
fn test_ip_compare() {
assert!(
FilterParser::new(&SCHEME)
.lex_as::<ComparisonExpr>("ip.addr == 10.10.10.10")
.is_ok()
);

let expr = assert_ok!(
FilterParser::new(&SCHEME).lex_as("ip.addr <= 10:20:30:40:50:60:70:80"),
ComparisonExpr {
Expand Down Expand Up @@ -1138,6 +1144,18 @@ mod tests {

#[test]
fn test_bytes_compare() {
assert_err!(
FilterParser::new(&SCHEME).lex_as::<ComparisonExpr>("http.host == 10.10.10.10"),
LexErrorKind::ExpectedName("byte separator"),
"."
);

assert!(
FilterParser::new(&SCHEME)
.lex_as::<ComparisonExpr>(r#"http.host == "10.10.10.10""#)
.is_ok()
);

// just check that parsing doesn't conflict with IPv6
{
let expr = assert_ok!(
Expand Down
10 changes: 7 additions & 3 deletions engine/src/rhs_types/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ fn write_char(vec: &mut Vec<u8>, c: char) {
enum ByteSeparator {
Colon,
Dash,
Dot,
}

impl Lex<'_> for ByteSeparator {
Expand All @@ -187,7 +186,6 @@ impl Lex<'_> for ByteSeparator {
match sep {
":" => Ok((ByteSeparator::Colon, rest)),
"-" => Ok((ByteSeparator::Dash, rest)),
"." => Ok((ByteSeparator::Dot, rest)),
_ => Err((LexErrorKind::ExpectedName("byte separator"), sep)),
}
}
Expand Down Expand Up @@ -345,11 +343,17 @@ mod test {
#[test]
fn test() {
assert_ok!(
BytesExpr::lex("01:2e:f3-77.12;"),
BytesExpr::lex("01:2e:f3-77:12;"),
BytesExpr::from(vec![0x01, 0x2E, 0xF3, 0x77, 0x12]),
";"
);

assert_err!(
BytesExpr::lex("10.10.10.10"),
LexErrorKind::ExpectedName("byte separator"),
"."
);

assert_ok!(
BytesExpr::lex(r#""s\\t\"r\x0A\000t""#),
BytesExpr::from("s\\t\"r\n\0t".to_owned())
Expand Down
Loading