diff --git a/src/Heimdall.Web/Controllers/SettingsController.cs b/src/Heimdall.Web/Controllers/SettingsController.cs
index 48c5c27..bf36583 100644
--- a/src/Heimdall.Web/Controllers/SettingsController.cs
+++ b/src/Heimdall.Web/Controllers/SettingsController.cs
@@ -221,18 +221,29 @@ public class SettingsController : ControllerBase
return Accepted(new { message = "Config reload broadcast to all connected agents" });
}
+ ///
+ /// Sensitive key patterns whose values must never be returned to the client.
+ /// Centralized list — add new patterns here as needed.
+ ///
+ private static readonly string[] SensitiveKeyPatterns =
+ ["password", "token", "secret", "apikey", "api_key", "credential", "jwt", "privatekey", "connectionstring"];
+
+ ///
+ /// Sensitive value type patterns whose values must never be returned to the client.
+ ///
+ private static readonly string[] SensitiveValueTypePatterns =
+ ["password", "token", "secret", "key", "credential"];
+
private static string RedactValue(string? valueType, string value, string? key = null)
{
- if (valueType is not null && valueType.Contains("password", StringComparison.OrdinalIgnoreCase))
+ if (key is not null && SensitiveKeyPatterns.Any(p =>
+ key.Contains(p, StringComparison.OrdinalIgnoreCase)))
return "***REDACTED***";
- if (valueType is not null && valueType.Contains("token", StringComparison.OrdinalIgnoreCase))
- return "***REDACTED***";
- if (key is not null && key.Contains("password", StringComparison.OrdinalIgnoreCase))
- return "***REDACTED***";
- if (key is not null && key.Contains("token", StringComparison.OrdinalIgnoreCase))
- return "***REDACTED***";
- if (key is not null && key.Contains("secret", StringComparison.OrdinalIgnoreCase))
+
+ if (valueType is not null && SensitiveValueTypePatterns.Any(p =>
+ valueType.Contains(p, StringComparison.OrdinalIgnoreCase)))
return "***REDACTED***";
+
return value;
}
}