adding back in base_model redaction w/ whitelist

This commit is contained in:
Dan Saunders
2025-02-24 01:16:03 +00:00
parent 675b65d711
commit d3d63c1432

View File

@@ -168,8 +168,15 @@ 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"""
# Special case: base_model should be redacted if org is not whitelisted
if key == "base_model":
org = value.split("/")[0]
if org not in self.whitelist["organizations"]:
return "[REDACTED]"
if isinstance(value, str):
# If the key suggests this is a path, redact it # If the key suggests this is a path, redact it
if any(indicator in key.lower() for indicator in path_indicators): if any(indicator in key.lower() for indicator in path_indicators):
return "[REDACTED]" return "[REDACTED]"