mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-26 15:40:18 +00:00
style: fix rustfmt formatting from PR #137
Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2d3eb4de9a
commit
9e6e1471ab
@@ -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]
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user