From d3d63c1432c8b3e7003b1fdd34bc5372ac3432dc Mon Sep 17 00:00:00 2001 From: Dan Saunders Date: Mon, 24 Feb 2025 01:16:03 +0000 Subject: [PATCH] adding back in base_model redaction w/ whitelist --- src/axolotl/telemetry/manager.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/axolotl/telemetry/manager.py b/src/axolotl/telemetry/manager.py index dd2e4b4fe..646688c73 100644 --- a/src/axolotl/telemetry/manager.py +++ b/src/axolotl/telemetry/manager.py @@ -168,17 +168,24 @@ class TelemetryManager: # TODO: Keep this up to date with any config schema changes 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""" - # If the key suggests this is a path, redact it - if any(indicator in key.lower() for indicator in path_indicators): - return "[REDACTED]" + # 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]" - # 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] + if isinstance(value, str): + # If the key suggests this is a path, redact it + if any(indicator in key.lower() for indicator in path_indicators): + return "[REDACTED]" + + # 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