style: fix rustfmt formatting from PR #137

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-18 11:56:13 -08:00
co-authored by Claude Opus 4.6
parent 2d3eb4de9a
commit 9e6e1471ab
2 changed files with 26 additions and 7 deletions
+25 -5
View File
@@ -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]
+1 -2
View File
@@ -1008,8 +1008,7 @@ fn extract_host_from_url(url: &str) -> Option<String> {
/// 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()));
}