mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix is_sensitive_key
This commit is contained in:
parent
68189d1c04
commit
aac1129761
1 changed files with 8 additions and 1 deletions
|
|
@ -44,7 +44,14 @@ class SensitiveDataMasker:
|
|||
|
||||
def is_sensitive_key(self, key: str) -> bool:
|
||||
key_lower = str(key).lower()
|
||||
result = any(pattern in key_lower for pattern in self.sensitive_patterns)
|
||||
# Split on underscores and check if any segment matches the pattern
|
||||
# This avoids false positives like "max_tokens" matching "token"
|
||||
# but still catches "api_key", "access_token", etc.
|
||||
key_segments = key_lower.replace('-', '_').split('_')
|
||||
result = any(
|
||||
pattern in key_segments
|
||||
for pattern in self.sensitive_patterns
|
||||
)
|
||||
return result
|
||||
|
||||
def mask_dict(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue