mirror of
https://github.com/pldubouilh/blockfast.git
synced 2026-08-28 04:46:58 -04:00
tighten clf regex
This commit is contained in:
committed by
Pierre Dubouilh
parent
02f5bea4c0
commit
38a374858e
+17
-1
@@ -6,7 +6,7 @@ use std::{net::IpAddr, str::FromStr};
|
||||
|
||||
lazy_static! {
|
||||
static ref RE_IP: Regex = Regex::new(r"^(\S+)\s").unwrap();
|
||||
static ref RE_STATUS: Regex = Regex::new(r"(\d+)\s(\w+)$").unwrap();
|
||||
static ref RE_STATUS: Regex = Regex::new(r"(\d+)\s+\S+\s*$").unwrap();
|
||||
}
|
||||
|
||||
#[allow(clippy::bind_instead_of_map)]
|
||||
@@ -69,6 +69,22 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bodyless() {
|
||||
// CLF uses `-` for absent body bytes, both branches must still parse
|
||||
let bad = "8.8.8.8 - p [25/Sep/2021:13:49:56 +0200] \"GET / HTTP/2.0\" 401 -";
|
||||
match parse(bad, &vec![401, 429]).unwrap() {
|
||||
ParsingStatus::BadEntry(_) => {}
|
||||
_ => panic!("bad parsing"),
|
||||
}
|
||||
|
||||
let ok = "8.8.8.8 - p [25/Sep/2021:13:49:56 +0200] \"GET / HTTP/2.0\" 304 -";
|
||||
match parse(ok, &vec![401, 429]).unwrap() {
|
||||
ParsingStatus::OkEntry => {}
|
||||
_ => panic!("bad parsing"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed() {
|
||||
let vectors = [
|
||||
|
||||
Reference in New Issue
Block a user