From 902f3ba8898dba4c74b8cb47217be973e31dd16b Mon Sep 17 00:00:00 2001 From: yuyr Date: Mon, 1 Jun 2026 21:51:38 +0800 Subject: [PATCH] =?UTF-8?q?20260601=20sequence=20triage=E6=8C=89host?= =?UTF-8?q?=E8=81=9A=E5=90=88URI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tools/sequence_triage_ccr_cir.rs | 4 ++-- src/tools/sequence_triage_ccr_cir/sandwich.rs | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/tools/sequence_triage_ccr_cir.rs b/src/tools/sequence_triage_ccr_cir.rs index 009abe7..67c01e1 100644 --- a/src/tools/sequence_triage_ccr_cir.rs +++ b/src/tools/sequence_triage_ccr_cir.rs @@ -534,11 +534,11 @@ mod tests { assert_eq!(output["sandwich"]["heatmap"].as_array().unwrap().len(), 1); assert_eq!(output["sandwich"]["heatmap"][0]["total"].as_u64(), Some(5)); assert_eq!( - uri_prefix_group_occurrences(&output, "object", "rsync://example.net/pp/"), + uri_prefix_group_occurrences(&output, "object", "rsync://example.net/"), 2 ); assert_eq!( - uri_prefix_group_occurrences(&output, "reject_uri", "rsync://example.net/pp/"), + uri_prefix_group_occurrences(&output, "reject_uri", "rsync://example.net/"), 1 ); assert_eq!(asn_group_occurrences(&output, "vrp_output", "AS64496"), 1); diff --git a/src/tools/sequence_triage_ccr_cir/sandwich.rs b/src/tools/sequence_triage_ccr_cir/sandwich.rs index f7c796f..d6003b6 100644 --- a/src/tools/sequence_triage_ccr_cir/sandwich.rs +++ b/src/tools/sequence_triage_ccr_cir/sandwich.rs @@ -292,7 +292,7 @@ impl SandwichAnalysis { ) { match record.set_type { "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 = 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); - if let Some(slash_index) = uri.rfind('/') - && slash_index >= scheme_end - { - return uri[..=slash_index].to_string(); + if let Some(path_start) = uri[scheme_end..].find('/') { + let end = scheme_end + path_start + 1; + return uri[..end].to_string(); } uri.to_string() }