diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-10-25 16:23:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-25 16:23:07 -0500 |
| commit | 2b827344d11e7490b323defa898264cadbdb6089 (patch) | |
| tree | 57fedb94861bb4116a8aed9cc7fecb5e87aa06ff /src/slskd/Program.cs | |
| parent | a4cce04d38544ad6d4c1506b9facb32407a79509 (diff) | |
| parent | be81b3b85b21d502feaf4918a0da92f445f7c2ab (diff) | |
| download | slskd-2b827344d11e7490b323defa898264cadbdb6089.tar.gz | |
Merge pull request #1911 from slskd/auth
Refine access levels on a number of endpoints, number of small tweaks and adjustments
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 e236886b..372dc998 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; } |
