From 1f82ea415e3e41480edd4bf4fea818b71cd0038e Mon Sep 17 00:00:00 2001 From: Jacob Weisz Date: Sat, 6 Jul 2024 01:25:28 -0500 Subject: [PATCH] Add software inventory reset --- Properties/AssemblyInfo.cs | 4 ++-- XRFAgent.csproj | 2 +- docs/ErrorCodes.md | 3 ++- modCommand.cs | 2 ++ modDatabase.cs | 8 ++++++++ modSystem.cs | 15 +++++++++++++++ 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 1540903..4ee431c 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.6")] -[assembly: AssemblyFileVersion("1.0.0.6")] +[assembly: AssemblyVersion("1.0.0.7")] +[assembly: AssemblyFileVersion("1.0.0.7")] diff --git a/XRFAgent.csproj b/XRFAgent.csproj index 844335b..1f3bfb4 100644 --- a/XRFAgent.csproj +++ b/XRFAgent.csproj @@ -25,7 +25,7 @@ false false true - 6 + 7 1.0.0.%2a false true diff --git a/docs/ErrorCodes.md b/docs/ErrorCodes.md index c63800b..9d49aaa 100644 --- a/docs/ErrorCodes.md +++ b/docs/ErrorCodes.md @@ -12,4 +12,5 @@ 6031 - External process start error 6032 - Registry access error -6051 - Detected new software installed (informational) \ No newline at end of file +6051 - Detected new software installed (informational) +6052 - Truncated installed software inventory (informational) \ No newline at end of file diff --git a/modCommand.cs b/modCommand.cs index 72fd613..4f533c2 100644 --- a/modCommand.cs +++ b/modCommand.cs @@ -37,6 +37,8 @@ public static void Handle(string inputCommand, string inputSource, string reques case "reboot" when inputData.Length == 2: case "restart" when inputData.Length == 2: if (inputData[1] == "host") { outputResponse = modSystem.RebootHost(); } break; + case "reset" when inputData.Length == 3: + if (inputData[1] == "installed" && inputData[2] == "software") { outputResponse = modSystem.ResetInstalledSoftware(); } break; case "shutdown" when inputData.Length == 2: if (inputData[1] == "host") { outputResponse = modSystem.ShutdownHost(); } break; case "update" when inputData.Length == 2: diff --git a/modDatabase.cs b/modDatabase.cs index 10a3272..ecf6acd 100644 --- a/modDatabase.cs +++ b/modDatabase.cs @@ -160,5 +160,13 @@ public static int UpdateSoftware(InstalledSoftware software) result = conn.Update(software); return result; } + + /// + /// Dumps the current contents of the INSTALLEDSOFTWARE table + /// + public static void TruncateSoftware() + { + conn.DeleteAll(); + } } } diff --git a/modSystem.cs b/modSystem.cs index 35e26c2..cfcf4ff 100644 --- a/modSystem.cs +++ b/modSystem.cs @@ -18,6 +18,10 @@ public static void Load() { } /// public static void Unload() { } + /// + /// Collects the list of installed applications, updates the local table, and sends to the server. + /// + /// Result of new applications detected public static string GetInstalledSoftware() { try @@ -68,6 +72,17 @@ public static string GetInstalledSoftware() } } + /// + /// Drops the installed software inventory, then gathers an updated version. + /// + /// Result of new applications detected + public static string ResetInstalledSoftware() + { + modLogging.LogEvent("Reset installed software inventory.", EventLogEntryType.Information, 6052); + modDatabase.TruncateSoftware(); + return GetInstalledSoftware(); + } + /// /// Gets a full Windows build number from the registry ///