Don't expose SteamLogin in weak password warning

While not strictly a sensitive property, there is no good reason why we should print it in the log instead of a bot name, which is far less sensitive in nature.
This commit is contained in:
Archi
2022-02-18 11:16:31 +01:00
parent 1a7be0bac8
commit 697b78aa21
2 changed files with 8 additions and 4 deletions

View File

@@ -1397,7 +1397,7 @@ public sealed class Bot : IAsyncDisposable {
return;
}
(BotConfig? botConfig, _) = await BotConfig.Load(configFile).ConfigureAwait(false);
(BotConfig? botConfig, _) = await BotConfig.Load(configFile, BotName).ConfigureAwait(false);
if (botConfig == null) {
await Destroy().ConfigureAwait(false);
@@ -1499,7 +1499,7 @@ public sealed class Bot : IAsyncDisposable {
return;
}
(BotConfig? botConfig, string? latestJson) = await BotConfig.Load(configFilePath).ConfigureAwait(false);
(BotConfig? botConfig, string? latestJson) = await BotConfig.Load(configFilePath, botName).ConfigureAwait(false);
if (botConfig == null) {
ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.ErrorBotConfigInvalid, configFilePath));

View File

@@ -540,7 +540,7 @@ public sealed class BotConfig {
return result;
}
internal static async Task<(BotConfig? BotConfig, string? LatestJson)> Load(string filePath) {
internal static async Task<(BotConfig? BotConfig, string? LatestJson)> Load(string filePath, string? botName = null) {
if (string.IsNullOrEmpty(filePath)) {
throw new ArgumentNullException(nameof(filePath));
}
@@ -600,7 +600,11 @@ public sealed class BotConfig {
(bool isWeak, string? reason) = Utilities.TestPasswordStrength(decryptedSteamPassword!, disallowedValues);
if (isWeak) {
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningWeakSteamPassword, !string.IsNullOrEmpty(botConfig.SteamLogin) ? botConfig.SteamLogin! : filePath, reason));
if (string.IsNullOrEmpty(botName)) {
botName = Path.GetFileNameWithoutExtension(filePath);
}
ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningWeakSteamPassword, botName, reason));
}
}
);