Compare commits
2 Commits
037bd195db
...
dce789db94
| Author | SHA1 | Date | |
|---|---|---|---|
| dce789db94 | |||
| cedf28199e |
@@ -1,9 +1,7 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(dotnet build:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit -m \"$(cat <<''EOF''\nRelease v1.2.0: Integrate osquery for enhanced system information\n\nMajor Features:\n- Integrated osquery for comprehensive system information gathering\n- Added OsqueryService for executing SQL queries against system tables\n- Implemented Osquery Console tab for interactive SQL queries\n\nSystem Info Improvements:\n- Enhanced system info collection using osquery tables\n- Added support for multiple GPU detection\n- Improved memory detection with proper GB formatting\n- Fixed OS Architecture detection (x64/x86)\n- Better network interface detection (IPv4 only)\n- Human-readable timestamp formatting\n\nUI/UX Enhancements:\n- Added window resizing with corner drag support\n- Implemented dynamic window sizing (SizeToContent)\n- Added ScrollViewer for content overflow\n- Improved IP address formatting with bullet points\n- Added field labels to all system info displays\n- Set minimum/maximum window size constraints\n\nBug Fixes:\n- Fixed XAML StackPanel Spacing property issue\n- Merged duplicate MainWindow constructors\n- Fixed non-nullable field warnings\n- Fixed EventHandler nullability signatures\n- Removed redundant hostname/OS name fields\n- Fixed GPU registry query to detect all GPUs\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")"
|
||||
"Bash(\"BuildDir\\bin\\Debug\\Assets\\osqueryi.exe\" --json \"SELECT datetime((SELECT CAST(unix_time AS INTEGER) FROM time) - total_seconds, ''unixepoch'') as boot_time FROM uptime;\")"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<StartupObject>LD_SysInfo.App</StartupObject>
|
||||
<ApplicationIcon>Assets\LDShortcut.ico</ApplicationIcon>
|
||||
<OutputPath>C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\net8.0-windows\</OutputPath>
|
||||
<OutputPath>C:\Users\Sonder\source\repos\psg-oversight-app\BuildDir\bin\Debug\</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<IncludeSatelliteAssembliesForPublish>false</IncludeSatelliteAssembliesForPublish>
|
||||
|
||||
<!-- 🔢 Version Info -->
|
||||
|
||||
@@ -9,6 +9,13 @@ namespace LD_SysInfo.Services
|
||||
{
|
||||
public static class OsqueryService
|
||||
{
|
||||
private static string GetLogPath(string filename)
|
||||
{
|
||||
string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PSG-Oversight");
|
||||
Directory.CreateDirectory(logDir);
|
||||
return Path.Combine(logDir, filename);
|
||||
}
|
||||
|
||||
private static string GetOsqueryPath()
|
||||
{
|
||||
var baseDir = AppContext.BaseDirectory;
|
||||
@@ -16,7 +23,11 @@ namespace LD_SysInfo.Services
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
File.AppendAllText("osquery_error.log", $"[{DateTime.Now}] ❌ osqueryi.exe not found at {path}\n");
|
||||
try
|
||||
{
|
||||
File.AppendAllText(GetLogPath("osquery_error.log"), $"[{DateTime.Now}] ❌ osqueryi.exe not found at {path}\n");
|
||||
}
|
||||
catch { /* Silently fail if we can't write logs */ }
|
||||
throw new FileNotFoundException("osqueryi.exe not found", path);
|
||||
}
|
||||
|
||||
@@ -42,8 +53,12 @@ namespace LD_SysInfo.Services
|
||||
process.WaitForExit();
|
||||
|
||||
// Optional debug logging
|
||||
File.AppendAllText("osquery_debug.log",
|
||||
try
|
||||
{
|
||||
File.AppendAllText(GetLogPath("osquery_debug.log"),
|
||||
$"[{DateTime.Now}] Ran query: {sql}\nOutput length: {output.Length}\n");
|
||||
}
|
||||
catch { /* Silently fail if we can't write logs */ }
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -69,8 +84,12 @@ namespace LD_SysInfo.Services
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.AppendAllText("osquery_error.log",
|
||||
try
|
||||
{
|
||||
File.AppendAllText(GetLogPath("osquery_error.log"),
|
||||
$"[{DateTime.Now}] ⚠️ JSON parse failed for query '{sql}': {ex.Message}\n");
|
||||
}
|
||||
catch { /* Silently fail if we can't write logs */ }
|
||||
return new List<Dictionary<string, string>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,10 +142,10 @@ namespace LD_SysInfo
|
||||
}
|
||||
|
||||
// ✅ Drives
|
||||
info.Drives = OsqueryService.Query("SELECT device, size, free_space, type FROM logical_drives;")
|
||||
info.Drives = OsqueryService.Query("SELECT device_id, size, free_space, type FROM logical_drives;")
|
||||
.Select(d => new DriveInfoSummary
|
||||
{
|
||||
Name = d.GetValueOrDefault("device"),
|
||||
Name = d.GetValueOrDefault("device_id"),
|
||||
TotalSizeGB = d.ContainsKey("size") && double.TryParse(d["size"], out double size)
|
||||
? Math.Round(size / (1024.0 * 1024.0 * 1024.0), 2) : 0,
|
||||
FreeSpaceGB = d.ContainsKey("free_space") && double.TryParse(d["free_space"], out double free)
|
||||
@@ -179,9 +179,9 @@ namespace LD_SysInfo
|
||||
.Where(ni => !string.IsNullOrEmpty(ni.IpAddress))
|
||||
.ToList();
|
||||
|
||||
// ✅ Last boot time
|
||||
info.LastBootTime = OsqueryService.Query("SELECT datetime(boot_time, 'unixepoch') AS last_boot FROM uptime;")
|
||||
.FirstOrDefault()?.GetValueOrDefault("last_boot");
|
||||
// ✅ Last boot time - calculate from current time minus uptime
|
||||
info.LastBootTime = OsqueryService.Query("SELECT datetime((SELECT CAST(unix_time AS INTEGER) FROM time) - total_seconds, 'unixepoch') as boot_time FROM uptime;")
|
||||
.FirstOrDefault()?.GetValueOrDefault("boot_time");
|
||||
|
||||
// ✅ Installed apps (user + system)
|
||||
info.InstalledApplications = OsqueryService.Query("SELECT name, version, publisher FROM programs;")
|
||||
@@ -218,7 +218,17 @@ namespace LD_SysInfo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.AppendAllText("osquery_error.log", $"[{DateTime.Now}] {ex}\n");
|
||||
try
|
||||
{
|
||||
string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PSG-Oversight");
|
||||
Directory.CreateDirectory(logDir);
|
||||
string logPath = Path.Combine(logDir, "osquery_error.log");
|
||||
File.AppendAllText(logPath, $"[{DateTime.Now}] {ex}\n");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Silently fail if we can't write logs
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
Reference in New Issue
Block a user