fix snmp community redaction

This commit is contained in:
Graham McIntire 2026-02-02 17:03:46 -06:00
parent 135e3d3799
commit 89a53eb07a
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -30,7 +30,7 @@ fn redact_community(community: &str) -> String {
if len <= 2 { if len <= 2 {
"**".to_string() "**".to_string()
} else { } else {
format!("{}***", &community[..2]) format!("{}**", &community[..2])
} }
} }
@ -253,7 +253,7 @@ mod tests {
#[test] #[test]
fn test_redact_community_normal() { fn test_redact_community_normal() {
assert_eq!(redact_community("public"), "pu***"); assert_eq!(redact_community("public"), "pu**");
} }
#[test] #[test]
@ -269,11 +269,11 @@ mod tests {
#[test] #[test]
fn test_redact_community_three_chars() { fn test_redact_community_three_chars() {
assert_eq!(redact_community("abc"), "ab***"); assert_eq!(redact_community("abc"), "ab**");
} }
#[test] #[test]
fn test_redact_community_long() { fn test_redact_community_long() {
assert_eq!(redact_community("mysecretcommunity"), "my***"); assert_eq!(redact_community("mysecretcommunity"), "my**");
} }
} }

View file

@ -347,7 +347,7 @@ fn redact_community(community: &str) -> String {
if len <= 2 { if len <= 2 {
"**".to_string() "**".to_string()
} else { } else {
format!("{}***", &community[..2]) format!("{}**", &community[..2])
} }
} }
@ -1039,7 +1039,7 @@ mod tests {
#[test] #[test]
fn test_redact_community_normal() { fn test_redact_community_normal() {
assert_eq!(redact_community("public"), "pu***"); assert_eq!(redact_community("public"), "pu**");
} }
#[test] #[test]
@ -1055,11 +1055,11 @@ mod tests {
#[test] #[test]
fn test_redact_community_three_chars() { fn test_redact_community_three_chars() {
assert_eq!(redact_community("abc"), "ab***"); assert_eq!(redact_community("abc"), "ab**");
} }
#[test] #[test]
fn test_redact_community_long() { fn test_redact_community_long() {
assert_eq!(redact_community("mysecretcommunity"), "my***"); assert_eq!(redact_community("mysecretcommunity"), "my**");
} }
} }