diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-31 19:52:59 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2026-10-31 19:52:59 -0500 |
| commit | cbd03ff1adc5d703a2023ae9532b3001542c0c2d (patch) | |
| tree | f86be6c9790273ca64ba59376de3b2b26c4879b0 /src/slskd/Program.cs | |
| parent | 926446c443afca46b853a0b8f5fa85297b56ede2 (diff) | |
| parent | 2e127575c5231ea94a2f327084c5da29b8a9e895 (diff) | |
| download | slskd-cbd03ff1adc5d703a2023ae9532b3001542c0c2d.tar.gz | |
Merge branch 'bugs' of github.com:slskd/slskd into bugs
Diffstat (limited to 'src/slskd/Program.cs')
| -rw-r--r-- | src/slskd/Program.cs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 1865453f..879f76b7 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -454,7 +454,17 @@ namespace slskd if (OptionsAtStartup.Debug) { - Log.Information($"Configuration:\n{Configuration.GetDebugView()}"); + // redact values for any key matching the name of a property marked [Secret]. keys from YAML may be + // snake or kebab case, so normalize before comparing. this over-redacts, which is fine here + var secretNames = typeof(Options).Assembly.GetTypes() + .Where(t => t == typeof(Options) || (t.FullName?.StartsWith($"{typeof(Options).FullName}+") ?? false)) + .SelectMany(t => t.GetProperties()) + .Where(p => p.GetCustomAttributes(typeof(SecretAttribute), inherit: false).Length > 0) + .Select(p => p.Name.ToLowerInvariant()) + .ToHashSet(); + + Log.Information($"Configuration:\n{Configuration.GetDebugView(context => + secretNames.Contains(context.Key.Replace("_", string.Empty).Replace("-", string.Empty).ToLowerInvariant()) ? "*****" : context.Value)}"); } if (!OptionsAtStartup.TryValidate(out var result)) @@ -465,7 +475,7 @@ namespace slskd } catch (Exception ex) { - Log.Information($"Invalid configuration: {(!OptionsAtStartup.Debug ? ex : ex.Message)}"); + Log.Information($"Invalid configuration: {(OptionsAtStartup.Debug ? ex : ex.Message)}"); return; } |
