Skip to content

Commit

Permalink
Add software inventory reset
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdtrekkie committed Jul 6, 2024
1 parent 05edc13 commit 1f82ea4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
2 changes: 1 addition & 1 deletion XRFAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>6</ApplicationRevision>
<ApplicationRevision>7</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
3 changes: 2 additions & 1 deletion docs/ErrorCodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
6031 - External process start error
6032 - Registry access error

6051 - Detected new software installed (informational)
6051 - Detected new software installed (informational)
6052 - Truncated installed software inventory (informational)
2 changes: 2 additions & 0 deletions modCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions modDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,13 @@ public static int UpdateSoftware(InstalledSoftware software)
result = conn.Update(software);
return result;
}

/// <summary>
/// Dumps the current contents of the INSTALLEDSOFTWARE table
/// </summary>
public static void TruncateSoftware()
{
conn.DeleteAll<InstalledSoftware>();
}
}
}
15 changes: 15 additions & 0 deletions modSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static void Load() { }
/// </summary>
public static void Unload() { }

/// <summary>
/// Collects the list of installed applications, updates the local table, and sends to the server.
/// </summary>
/// <returns>Result of new applications detected</returns>
public static string GetInstalledSoftware()
{
try
Expand Down Expand Up @@ -68,6 +72,17 @@ public static string GetInstalledSoftware()
}
}

/// <summary>
/// Drops the installed software inventory, then gathers an updated version.
/// </summary>
/// <returns>Result of new applications detected</returns>
public static string ResetInstalledSoftware()
{
modLogging.LogEvent("Reset installed software inventory.", EventLogEntryType.Information, 6052);
modDatabase.TruncateSoftware();
return GetInstalledSoftware();
}

/// <summary>
/// Gets a full Windows build number from the registry
/// </summary>
Expand Down

0 comments on commit 1f82ea4

Please sign in to comment.