mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(rust): reuse reqwest URL parser
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Some checks failed
LiteLLM Rust / rustfmt, clippy, test (push) Has been cancelled
Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
This commit is contained in:
parent
45ec1638b7
commit
a9bfee4461
4 changed files with 4 additions and 28 deletions
1
litellm-rust/Cargo.lock
generated
1
litellm-rust/Cargo.lock
generated
|
|
@ -1263,7 +1263,6 @@ dependencies = [
|
|||
"sha2 0.10.9",
|
||||
"thiserror 2.0.19",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -31,4 +31,3 @@ futures-util = { version = "0.3", default-features = false, features = ["sink",
|
|||
base64 = "0.22"
|
||||
bytes = "1"
|
||||
colored_json = "5.0"
|
||||
url = "2.5"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ rand.workspace = true
|
|||
reqwest.workspace = true
|
||||
bytes.workspace = true
|
||||
futures-util.workspace = true
|
||||
url.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
colored_json.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use reqwest::Url;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
pub const PROVIDER_DEBUG_BODY_MAX_BYTES: usize = 64 * 1024;
|
||||
|
|
@ -44,7 +45,7 @@ pub fn redact_headers(headers: &[(String, String)]) -> BTreeMap<String, String>
|
|||
}
|
||||
|
||||
pub fn redact_url(url: &str) -> String {
|
||||
let Ok(mut parsed) = url::Url::parse(url) else {
|
||||
let Ok(mut parsed) = Url::parse(url) else {
|
||||
return url.to_string();
|
||||
};
|
||||
if !parsed.username().is_empty() {
|
||||
|
|
@ -76,7 +77,7 @@ fn redact_value(value: Value) -> Value {
|
|||
Value::Object(map) => Value::Object(
|
||||
map.into_iter()
|
||||
.map(|(key, value)| {
|
||||
if is_secret_key(&key) {
|
||||
if is_credential_name(&key) {
|
||||
(key, Value::String("[REDACTED]".to_string()))
|
||||
} else {
|
||||
(key, redact_value(value))
|
||||
|
|
@ -89,10 +90,6 @@ fn redact_value(value: Value) -> Value {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_secret_key(key: &str) -> bool {
|
||||
is_credential_name(key)
|
||||
}
|
||||
|
||||
fn is_credential_name(name: &str) -> bool {
|
||||
let normalized = name
|
||||
.chars()
|
||||
|
|
@ -101,25 +98,7 @@ fn is_credential_name(name: &str) -> bool {
|
|||
.collect::<String>();
|
||||
matches!(
|
||||
normalized.as_str(),
|
||||
"authorization"
|
||||
| "proxyauthorization"
|
||||
| "xapikey"
|
||||
| "apikey"
|
||||
| "xamzsecuritytoken"
|
||||
| "cookie"
|
||||
| "setcookie"
|
||||
| "xamzsignature"
|
||||
| "xamzcredential"
|
||||
| "key"
|
||||
| "accesstoken"
|
||||
| "signature"
|
||||
| "secret"
|
||||
| "password"
|
||||
| "token"
|
||||
| "clientsecret"
|
||||
| "awssecretaccesskey"
|
||||
| "awsaccesskeyid"
|
||||
| "awssessiontoken"
|
||||
"cookie" | "setcookie" | "key" | "awsaccesskeyid"
|
||||
) || [
|
||||
"apikey",
|
||||
"secret",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue