20260601 sequence triage按host聚合URI
This commit is contained in:
parent
938ef53173
commit
902f3ba889
@ -534,11 +534,11 @@ mod tests {
|
|||||||
assert_eq!(output["sandwich"]["heatmap"].as_array().unwrap().len(), 1);
|
assert_eq!(output["sandwich"]["heatmap"].as_array().unwrap().len(), 1);
|
||||||
assert_eq!(output["sandwich"]["heatmap"][0]["total"].as_u64(), Some(5));
|
assert_eq!(output["sandwich"]["heatmap"][0]["total"].as_u64(), Some(5));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
uri_prefix_group_occurrences(&output, "object", "rsync://example.net/pp/"),
|
uri_prefix_group_occurrences(&output, "object", "rsync://example.net/"),
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
uri_prefix_group_occurrences(&output, "reject_uri", "rsync://example.net/pp/"),
|
uri_prefix_group_occurrences(&output, "reject_uri", "rsync://example.net/"),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
assert_eq!(asn_group_occurrences(&output, "vrp_output", "AS64496"), 1);
|
assert_eq!(asn_group_occurrences(&output, "vrp_output", "AS64496"), 1);
|
||||||
|
|||||||
@ -292,7 +292,7 @@ impl SandwichAnalysis {
|
|||||||
) {
|
) {
|
||||||
match record.set_type {
|
match record.set_type {
|
||||||
"object" | "reject_uri" => {
|
"object" | "reject_uri" => {
|
||||||
let prefix = uri_directory_prefix(&record.key);
|
let prefix = uri_host_prefix(&record.key);
|
||||||
let group_key = format!("{}|{}", record.set_type, prefix);
|
let group_key = format!("{}|{}", record.set_type, prefix);
|
||||||
let group =
|
let group =
|
||||||
self.uri_prefix_groups
|
self.uri_prefix_groups
|
||||||
@ -348,12 +348,11 @@ fn add_to_group(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn uri_directory_prefix(uri: &str) -> String {
|
fn uri_host_prefix(uri: &str) -> String {
|
||||||
let scheme_end = uri.find("://").map(|index| index + 3).unwrap_or(0);
|
let scheme_end = uri.find("://").map(|index| index + 3).unwrap_or(0);
|
||||||
if let Some(slash_index) = uri.rfind('/')
|
if let Some(path_start) = uri[scheme_end..].find('/') {
|
||||||
&& slash_index >= scheme_end
|
let end = scheme_end + path_start + 1;
|
||||||
{
|
return uri[..end].to_string();
|
||||||
return uri[..=slash_index].to_string();
|
|
||||||
}
|
}
|
||||||
uri.to_string()
|
uri.to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user