bump ImageSharp version vulnerability fix

decouple Loader from Common dll
fix current user url in api
This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-10-02 10:06:45 +03:00
parent 51248edbd3
commit e090f2d093
9 changed files with 76 additions and 27 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
<PackageReference Include="Polly" Version="8.5.2" />
<PackageReference Include="RabbitMQ.Stream.Client" Version="1.8.9" />
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
<PackageReference Include="Stub.System.Data.SQLite.Core.NetStandard" Version="1.0.119" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
<PackageReference Include="System.Drawing.Common" Version="5.0.3" />
-1
View File
@@ -12,7 +12,6 @@ namespace Azaion.Common;
public static class Constants
{
public const string CONFIG_PATH = "config.json";
public const string LOADER_CONFIG_PATH = "loaderconfig.json";
public const string DEFAULT_API_URL = "https://api.azaion.com";
public const string AZAION_SUITE_EXE = "Azaion.Suite.exe";
+3 -2
View File
@@ -9,8 +9,9 @@ public class Detection : YoloLabel
{
[JsonProperty(PropertyName = "an")][Key("an")] public string AnnotationName { get; set; } = null!;
[JsonProperty(PropertyName = "p")][Key("p")] public double Confidence { get; set; }
[JsonProperty(PropertyName = "dn")][Key("dn")] public string Description { get; set; }
[JsonProperty(PropertyName = "af")][Key("af")] public AffiliationEnum Affiliation { get; set; }
[JsonProperty(PropertyName = "dn")] [Key("dn")] public string Description { get; set; } = null!;
[JsonProperty(PropertyName = "af")] [Key("af")] public AffiliationEnum Affiliation { get; set; }
//For db & serialization
public Detection(){}
+8 -6
View File
@@ -3,16 +3,18 @@ namespace Azaion.Common.Database;
public class MediaFile
{
public string Name { get; set; } = null!;
public string LocalPath { get; set; } = null!;
public DateTime? ProcessedDate { get; set; }
public MediaDetectionStatus MediaDetectionStatus { get; set; } = MediaDetectionStatus.New;
public string MediaUrl { get; set; } = null!;
public DateTime? LastProcessedDate { get; set; }
public MediaStatus Status { get; set; } = MediaStatus.New;
public int? RecognisedObjects { get; set; }
}
public enum MediaDetectionStatus
public enum MediaStatus
{
None,
New,
Processing,
Processed,
AIProcessing,
AIProcessed,
ManualConfirmed,
Error
}
+1 -1
View File
@@ -29,7 +29,7 @@ public class AzaionApi(ILogger logger, HttpClient client, ICache cache, ApiCrede
get
{
var user = cache.GetFromCache(Constants.CURRENT_USER_CACHE_KEY,
() => Get<User>("currentUser"));
() => Get<User>("users/current"));
if (user == null)
throw new Exception("Can't get current user");
return user;
+2 -3
View File
@@ -1,5 +1,4 @@
using System.Windows;
using Azaion.Common;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -29,7 +28,7 @@ public partial class App
var host = Host.CreateDefaultBuilder()
.ConfigureAppConfiguration((_, config) => config
.AddCommandLine(Environment.GetCommandLineArgs())
.AddJsonFile(Constants.LOADER_CONFIG_PATH, optional: true))
.AddJsonFile(ConstantsLoader.LOADER_CONFIG_PATH, optional: true))
.UseSerilog()
.ConfigureServices((context, services) =>
{
@@ -37,7 +36,7 @@ public partial class App
services.Configure<DirectoriesConfig>(context.Configuration.GetSection(nameof(DirectoriesConfig)));
services.AddHttpClient<IAzaionApi, AzaionApi>((sp, client) =>
{
client.BaseAddress = new Uri(Constants.DEFAULT_API_URL);
client.BaseAddress = new Uri(ConstantsLoader.DEFAULT_API_URL);
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("User-Agent", "Azaion.LoaderUI");
});
+1 -4
View File
@@ -24,6 +24,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.5" />
<PackageReference Include="NetMQ" Version="4.0.1.16" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.1" />
@@ -45,8 +46,4 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Azaion.Common\Azaion.Common.csproj" />
</ItemGroup>
</Project>
+52
View File
@@ -1,3 +1,8 @@
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
using Newtonsoft.Json;
namespace Azaion.LoaderUI;
public static class ConstantsLoader
@@ -5,4 +10,51 @@ public static class ConstantsLoader
public const string SUITE_FOLDER = "suite";
public const string SUITE_STAGE_FOLDER = "suite-stage";
public const int EXTERNAL_LOADER_PORT = 5020;
public const string AZAION_SUITE_EXE = "Azaion.Suite.exe";
public const string LOADER_CONFIG_PATH = "loaderconfig.json";
public const string DEFAULT_ZMQ_LOADER_HOST = "127.0.0.1";
public const string DEFAULT_API_URL = "https://api.azaion.com";
public const string EXTERNAL_LOADER_PATH = "azaion-loader.exe";
public const string EXTERNAL_INFERENCE_PATH = "azaion-inference.exe";
public static Version GetLocalVersion()
{
var localFileInfo = FileVersionInfo.GetVersionInfo(AZAION_SUITE_EXE);
if (string.IsNullOrWhiteSpace(localFileInfo.ProductVersion))
throw new Exception($"Can't find {AZAION_SUITE_EXE} and its version");
return new Version(localFileInfo.FileVersion!);
}
private static string GenDefaultKey()
{
var date = DateTime.UtcNow;
return $"sAzaion_default_dfvkjhg_{date:yyyy}-{date:MM}_{date:dd}_{date:HH}_key";
}
public static string Encrypt<T>(T model, string? key = null) where T : class
{
var json = JsonConvert.SerializeObject(model);
var inputBytes = Encoding.UTF8.GetBytes(json);
var keyBytes = SHA256.HashData(Encoding.UTF8.GetBytes(key ?? GenDefaultKey()));
var iv = RandomNumberGenerator.GetBytes(16);
using var aes = Aes.Create();
aes.Key = keyBytes;
aes.IV = iv;
aes.Mode = CipherMode.CFB;
aes.Padding = PaddingMode.ISO10126;
using var encryptor = aes.CreateEncryptor();
var ciphertext = encryptor.TransformFinalBlock(inputBytes, 0, inputBytes.Length);
var result = new byte[iv.Length + ciphertext.Length];
iv.CopyTo(result, 0);
ciphertext.CopyTo(result, iv.Length);
return Convert.ToBase64String(result);
}
}
+8 -9
View File
@@ -6,7 +6,6 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Azaion.Common;
using MessagePack;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -56,9 +55,9 @@ public partial class Login
Validate(creds);
TbStatus.Foreground = Brushes.Black;
var localVersion = Constants.GetLocalVersion();
var localVersion = ConstantsLoader.GetLocalVersion();
var installerVersion = await GetInstallerVer() ?? localVersion;
var credsEncrypted = Security.Encrypt(creds);
var credsEncrypted = ConstantsLoader.Encrypt(creds);
if (installerVersion > localVersion)
{
@@ -71,17 +70,17 @@ public partial class Login
Process.Start(new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c updater.cmd {Process.GetCurrentProcess().Id} {installerName} {Constants.AZAION_SUITE_EXE} \"{credsEncrypted}\""
Arguments = $"/c updater.cmd {Process.GetCurrentProcess().Id} {installerName} {ConstantsLoader.AZAION_SUITE_EXE} \"{credsEncrypted}\""
});
}
else
{
TbStatus.Text = "Your version is up to date!";
Process.Start(Constants.AZAION_SUITE_EXE, $"-c {credsEncrypted}");
Process.Start(ConstantsLoader.AZAION_SUITE_EXE, $"-c {credsEncrypted}");
await Task.Delay(800);
TbStatus.Text = "Loading...";
while (!Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Constants.EXTERNAL_INFERENCE_PATH)).Any())
while (!Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ConstantsLoader.EXTERNAL_INFERENCE_PATH)).Any())
await Task.Delay(500);
await Task.Delay(1500);
}
@@ -106,13 +105,13 @@ public partial class Login
using var process = new Process();
process.StartInfo = new ProcessStartInfo
{
FileName = Constants.EXTERNAL_LOADER_PATH,
Arguments = $"--port {ConstantsLoader.EXTERNAL_LOADER_PORT} --api {Constants.DEFAULT_API_URL}",
FileName = ConstantsLoader.EXTERNAL_LOADER_PATH,
Arguments = $"--port {ConstantsLoader.EXTERNAL_LOADER_PORT} --api {ConstantsLoader.DEFAULT_API_URL}",
CreateNoWindow = true
};
process.Start();
dealer.Options.Identity = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString("N"));
dealer.Connect($"tcp://{Constants.DEFAULT_ZMQ_INFERENCE_HOST}:{ConstantsLoader.EXTERNAL_LOADER_PORT}");
dealer.Connect($"tcp://{ConstantsLoader.DEFAULT_ZMQ_LOADER_HOST}:{ConstantsLoader.EXTERNAL_LOADER_PORT}");
var result = SendCommand(dealer, RemoteCommand.Create(CommandType.Login, creds));
if (result.CommandType != CommandType.Ok)