44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
|
|
using System.Text.Json;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
namespace MemScanEDR.Models;
|
||
|
|
|
||
|
|
public class AppSettings
|
||
|
|
{
|
||
|
|
public AIConfig AI { get; set; } = AIConfig.DefaultFor(AIProvider.Heuristic);
|
||
|
|
public string CeMcpPath { get; set; } = "auto";
|
||
|
|
public string CeMcpCommand { get; set; } = "python";
|
||
|
|
public string WebHost { get; set; } = "127.0.0.1";
|
||
|
|
public int WebPort { get; set; } = 8080;
|
||
|
|
public string ScanProfile { get; set; } = "balanced";
|
||
|
|
public string LogDir { get; set; } = "./logs";
|
||
|
|
public string DbPath { get; set; } = "./data/audit.db";
|
||
|
|
public string RulesDir { get; set; } = "./rules";
|
||
|
|
|
||
|
|
private static readonly string SettingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json");
|
||
|
|
|
||
|
|
public void Save()
|
||
|
|
{
|
||
|
|
var dir = Path.GetDirectoryName(SettingsPath);
|
||
|
|
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
|
||
|
|
Directory.CreateDirectory(dir);
|
||
|
|
var json = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true });
|
||
|
|
File.WriteAllText(SettingsPath, json);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static AppSettings Load()
|
||
|
|
{
|
||
|
|
if (!File.Exists(SettingsPath))
|
||
|
|
return new AppSettings();
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var json = File.ReadAllText(SettingsPath);
|
||
|
|
return JsonSerializer.Deserialize<AppSettings>(json) ?? new AppSettings();
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
return new AppSettings();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|