From fae4b37ef97f676d1ba3036e8bff93d547d5001e Mon Sep 17 00:00:00 2001 From: Andrei Tudor Date: Sun, 12 Oct 2025 22:14:39 +0300 Subject: [PATCH] Fixed vulnerability issue and upgraded to discord.net 3.18 --- .../DiscordBotCore.Configuration.csproj | 2 +- .../DiscordBotCore.Database.Sqlite.csproj | 2 +- DiscordBotCore.Logging/Logger.cs | 12 ++++---- .../DiscordBotCore.PluginCore.csproj | 2 +- DiscordBotCore/DiscordBotCore.csproj | 4 +-- .../Tests.DiscordBotCore.Configuration.csproj | 14 ++++++--- .../Tests.DiscordBotCore.Logging.csproj | 15 +++++++--- WebUI/Program.cs | 29 +++++++++---------- global.json | 7 +++++ 9 files changed, 53 insertions(+), 34 deletions(-) create mode 100644 global.json diff --git a/DiscordBotCore.Configuration/DiscordBotCore.Configuration.csproj b/DiscordBotCore.Configuration/DiscordBotCore.Configuration.csproj index 51bcd3d..0ad8e44 100644 --- a/DiscordBotCore.Configuration/DiscordBotCore.Configuration.csproj +++ b/DiscordBotCore.Configuration/DiscordBotCore.Configuration.csproj @@ -12,7 +12,7 @@ - + diff --git a/DiscordBotCore.Database.Sqlite/DiscordBotCore.Database.Sqlite.csproj b/DiscordBotCore.Database.Sqlite/DiscordBotCore.Database.Sqlite.csproj index 3790f79..805002d 100644 --- a/DiscordBotCore.Database.Sqlite/DiscordBotCore.Database.Sqlite.csproj +++ b/DiscordBotCore.Database.Sqlite/DiscordBotCore.Database.Sqlite.csproj @@ -8,7 +8,7 @@ - + diff --git a/DiscordBotCore.Logging/Logger.cs b/DiscordBotCore.Logging/Logger.cs index ab681f8..e3559ab 100644 --- a/DiscordBotCore.Logging/Logger.cs +++ b/DiscordBotCore.Logging/Logger.cs @@ -24,6 +24,13 @@ public sealed class Logger : ILogger LogMessages = new List(); } + public void Log(string message) => Log(new LogMessage(message, string.Empty, LogType.Info)); + public void Log(string message, LogType logType) => Log(new LogMessage(message, logType)); + public void Log(string message, object sender) => Log(new LogMessage(message, sender)); + public void Log(string message, object sender, LogType type) => Log(new LogMessage(message, sender, type)); + public void LogException(Exception exception, object sender, bool logFullStack = false) => Log(LogMessage.CreateFromException(exception, sender, logFullStack)); + + private string GenerateLogMessage(ILogMessage message) { string messageAsString = new string(_LogMessageFormat); @@ -54,9 +61,4 @@ public sealed class Logger : ILogger await LogToFile(messageAsString); } - public void Log(string message) => Log(new LogMessage(message, string.Empty, LogType.Info)); - public void Log(string message, LogType logType) => Log(new LogMessage(message, logType)); - public void Log(string message, object sender) => Log(new LogMessage(message, sender)); - public void Log(string message, object sender, LogType type) => Log(new LogMessage(message, sender, type)); - public void LogException(Exception exception, object sender, bool logFullStack = false) => Log(LogMessage.CreateFromException(exception, sender, logFullStack)); } diff --git a/DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj b/DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj index c4ad51a..ed69178 100644 --- a/DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj +++ b/DiscordBotCore.PluginCore/DiscordBotCore.PluginCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/DiscordBotCore/DiscordBotCore.csproj b/DiscordBotCore/DiscordBotCore.csproj index 391d934..1084833 100644 --- a/DiscordBotCore/DiscordBotCore.csproj +++ b/DiscordBotCore/DiscordBotCore.csproj @@ -6,8 +6,8 @@ AnyCPU;x64;ARM64 - - + + diff --git a/Tests/Tests.DiscordBotCore.Configuration/Tests.DiscordBotCore.Configuration.csproj b/Tests/Tests.DiscordBotCore.Configuration/Tests.DiscordBotCore.Configuration.csproj index 328675d..d9ce783 100644 --- a/Tests/Tests.DiscordBotCore.Configuration/Tests.DiscordBotCore.Configuration.csproj +++ b/Tests/Tests.DiscordBotCore.Configuration/Tests.DiscordBotCore.Configuration.csproj @@ -10,11 +10,17 @@ - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Tests/Tests.DiscordBotCore.Logging/Tests.DiscordBotCore.Logging.csproj b/Tests/Tests.DiscordBotCore.Logging/Tests.DiscordBotCore.Logging.csproj index aab6d00..06bcc39 100644 --- a/Tests/Tests.DiscordBotCore.Logging/Tests.DiscordBotCore.Logging.csproj +++ b/Tests/Tests.DiscordBotCore.Logging/Tests.DiscordBotCore.Logging.csproj @@ -11,10 +11,17 @@ - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/WebUI/Program.cs b/WebUI/Program.cs index 7dce60e..f208f27 100644 --- a/WebUI/Program.cs +++ b/WebUI/Program.cs @@ -39,24 +39,21 @@ static Assembly? LoadFromSameFolder(object? sender, ResolveEventArgs args, strin string assemblyPath = Path.Combine(librariesFolder, assemblyFileName); Console.WriteLine($"Attempting to load from: {assemblyPath}"); - - if (File.Exists(assemblyPath)) - { - try - { - var fileAssembly = Assembly.LoadFrom(assemblyPath); - Console.WriteLine($"Successfully loaded Assembly: {fileAssembly.FullName}"); - return fileAssembly; - } - catch (Exception ex) - { - Console.WriteLine($"Error loading assembly from '{assemblyPath}': {ex.Message}"); - // Optionally log the full exception for debugging - } - } - else + + if (!File.Exists(assemblyPath)) { Console.WriteLine($"File not found: {assemblyPath}"); + continue; + } + + try + { + Assembly assembly = Assembly.LoadFrom(assemblyPath); + return assembly; + } + catch (Exception ex) + { + Console.WriteLine($"Failed to load assembly: {assemblyPath}. Error message: {ex.Message}"); } } diff --git a/global.json b/global.json new file mode 100644 index 0000000..b5b37b6 --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "8.0.0", + "rollForward": "latestMajor", + "allowPrerelease": false + } +} \ No newline at end of file