From 9e6e1471ab8dce86893385282a0b0d7debc5fc9a Mon Sep 17 00:00:00 2001 From: Illia Polosukhin Date: Wed, 18 Feb 2026 11:56:13 -0800 Subject: [PATCH] style: fix rustfmt formatting from PR #137 Co-Authored-By: Claude Opus 4.6 --- src/tools/wasm/allowlist.rs | 30 +++++++++++++++++++++++++----- src/tools/wasm/wrapper.rs | 3 +-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/tools/wasm/allowlist.rs b/src/tools/wasm/allowlist.rs index 36b5dac6..4415b32b 100644 --- a/src/tools/wasm/allowlist.rs +++ b/src/tools/wasm/allowlist.rs @@ -398,11 +398,31 @@ mod tests { #[test] fn test_path_traversal_blocked() { let validator = validator_with_patterns(); - assert!(!validator.validate("https://api.openai.com/v1/../admin", "GET").is_allowed()); - assert!(!validator.validate("https://api.openai.com/v1/../../etc/passwd", "GET").is_allowed()); - assert!(!validator.validate("https://api.openai.com/v1/%2E%2E/admin", "GET").is_allowed()); - assert!(!validator.validate("https://api.openai.com/v1/%2e%2e/%2e%2e/root", "GET").is_allowed()); - assert!(validator.validate("https://api.openai.com/v1/chat/completions", "POST").is_allowed()); + assert!( + !validator + .validate("https://api.openai.com/v1/../admin", "GET") + .is_allowed() + ); + assert!( + !validator + .validate("https://api.openai.com/v1/../../etc/passwd", "GET") + .is_allowed() + ); + assert!( + !validator + .validate("https://api.openai.com/v1/%2E%2E/admin", "GET") + .is_allowed() + ); + assert!( + !validator + .validate("https://api.openai.com/v1/%2e%2e/%2e%2e/root", "GET") + .is_allowed() + ); + assert!( + validator + .validate("https://api.openai.com/v1/chat/completions", "POST") + .is_allowed() + ); } #[test] diff --git a/src/tools/wasm/wrapper.rs b/src/tools/wasm/wrapper.rs index 389d090b..5424fb79 100644 --- a/src/tools/wasm/wrapper.rs +++ b/src/tools/wasm/wrapper.rs @@ -1008,8 +1008,7 @@ fn extract_host_from_url(url: &str) -> Option { /// This prevents DNS rebinding attacks where an attacker's domain resolves to an /// internal IP after passing the allowlist check. fn reject_private_ip(url: &str) -> Result<(), String> { - let parsed = url::Url::parse(url) - .map_err(|e| format!("Failed to parse URL: {e}"))?; + let parsed = url::Url::parse(url).map_err(|e| format!("Failed to parse URL: {e}"))?; if !matches!(parsed.scheme(), "http" | "https") { return Err(format!("Unsupported URL scheme: {}", parsed.scheme())); }