adding back in base_model redaction w/ whitelist
This commit is contained in:
@@ -168,17 +168,24 @@ class TelemetryManager:
|
|||||||
# TODO: Keep this up to date with any config schema changes
|
# TODO: Keep this up to date with any config schema changes
|
||||||
path_indicators = {"path", "dir"}
|
path_indicators = {"path", "dir"}
|
||||||
|
|
||||||
def redact_value(value: Any, key: str = "") -> Any:
|
def redact_value(value: str, key: Any = None) -> Any:
|
||||||
"""Recursively sanitize values, redacting those with path-like keys"""
|
"""Recursively sanitize values, redacting those with path-like keys"""
|
||||||
# If the key suggests this is a path, redact it
|
# Special case: base_model should be redacted if org is not whitelisted
|
||||||
if any(indicator in key.lower() for indicator in path_indicators):
|
if key == "base_model":
|
||||||
return "[REDACTED]"
|
org = value.split("/")[0]
|
||||||
|
if org not in self.whitelist["organizations"]:
|
||||||
|
return "[REDACTED]"
|
||||||
|
|
||||||
# Handle nested structures
|
if isinstance(value, str):
|
||||||
if isinstance(value, dict):
|
# If the key suggests this is a path, redact it
|
||||||
return {k: redact_value(v, k) for k, v in value.items()}
|
if any(indicator in key.lower() for indicator in path_indicators):
|
||||||
if isinstance(value, list):
|
return "[REDACTED]"
|
||||||
return [redact_value(item) for item in value]
|
|
||||||
|
# Handle nested structures
|
||||||
|
if isinstance(value, dict):
|
||||||
|
return {k: redact_value(v, k) for k, v in value.items()}
|
||||||
|
if isinstance(value, list):
|
||||||
|
return [redact_value(item) for item in value]
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user