namespace ZB.MOM.WW.MxGateway.Client.Cli; /// Utility to redact secrets (API keys, MXAccess credentials) from error messages for safe output. internal static class MxGatewayCliSecretRedactor { /// /// Replaces every occurrence of any supplied secret in the value with a /// redacted placeholder. Null or empty secrets are ignored, so callers can /// pass optional credentials without pre-filtering. /// /// The message text to redact. /// The secret values to remove (API key, verify-user password, secured payloads). public static string Redact(string value, params string?[] secrets) { if (string.IsNullOrEmpty(value) || secrets is null) { return value; } string redacted = value; foreach (string? secret in secrets) { if (!string.IsNullOrEmpty(secret)) { redacted = redacted.Replace(secret, "[redacted]", StringComparison.Ordinal); } } return redacted; } }