Skip to content

Commit

Permalink
Update Dependencies (#705)
Browse files Browse the repository at this point in the history
* Fix CodeQL Issues

* Update dependencies

* Small cleanup
  • Loading branch information
gfs committed Oct 24, 2023
1 parent 2fddf88 commit acb21da
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="System.Data.SQLite" Version="1.0.117" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
<PackageReference Include="murmurhash" Version="1.0.3" />
</ItemGroup>

Expand Down
2 changes: 0 additions & 2 deletions Benchmarks/InsertTestsWithIntermittentTransactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public InsertTestsWithIntermittentTransactions()
[Params(0)]
public int StartingSize { get; set; }

// Bag of reusable objects to write to the database.

public static void Insert_X_Objects(int X, int ObjectPadding = 0, string runName = "Insert_X_Objects")
{
dbManager.BeginTransaction();

Check warning on line 51 in Benchmarks/InsertTestsWithIntermittentTransactions.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Dereference of a possibly null reference.

Check warning on line 51 in Benchmarks/InsertTestsWithIntermittentTransactions.cs

View workflow job for this annotation

GitHub Actions / CodeQL-Build

Dereference of a possibly null reference.
Expand Down
2 changes: 1 addition & 1 deletion Cli/AttackSurfaceAnalyzerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ private static ASA_ERROR RunExportCollectCommand(ExportCollectCommandOptions opt
foreach (RESULT_TYPE resultType in Enum.GetValues(typeof(RESULT_TYPE)))
{
var resultsForType =
DatabaseManager.GetComparisonResults(opts.FirstRunId, opts.SecondRunId, analysesHash,
DatabaseManager.GetComparisonResults(opts.FirstRunId ?? string.Empty, opts.SecondRunId, analysesHash,
resultType);
foreach (var result in resultsForType)
{
Expand Down
12 changes: 6 additions & 6 deletions Cli/Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" />
<PackageReference Include="Microsoft.CST.OAT.Blazor.Components" Version="1.2.45" />
<PackageReference Include="Microsoft.CST.OAT.Scripting" Version="1.2.45" />
<PackageReference Include="Sarif.Sdk" Version="4.1.0" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.3.1.21360" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CST.OAT.Blazor.Components" Version="1.2.54" />
<PackageReference Include="Microsoft.CST.OAT.Scripting" Version="1.2.54" />
<PackageReference Include="Sarif.Sdk" Version="4.3.4" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="3.3.2.23201" />
</ItemGroup>
</Project>
41 changes: 27 additions & 14 deletions Lib/Collectors/RegistryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public class RegistryMonitor : BaseMonitor, IDisposable
{
public RegistryMonitor()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
log = new("System");
}
}

public override bool CanRunOnPlatform()
Expand Down Expand Up @@ -43,15 +47,18 @@ public override void StartRun()
{
throw new PlatformNotSupportedException("ExecuteWindows is only supported on Windows platforms.");
}
// backup the current auditpolicy
ExternalCommandRunner.RunExternalCommand("auditpol", $"/backup /file:{tmpFileName}");
if (log is { })
{
// backup the current auditpolicy
ExternalCommandRunner.RunExternalCommand("auditpol", $"/backup /file:{tmpFileName}");

// start listening to the event log
log.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
log.EnableRaisingEvents = true;
// start listening to the event log
log.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
log.EnableRaisingEvents = true;

// Enable auditing for registry events GUID for Registry subcategory of audit policy https://msdn.microsoft.com/en-us/library/dd973928.aspx
ExternalCommandRunner.RunExternalCommand("auditpol", "/set /subcategory:{0CCE921E-69AE-11D9-BED3-505054503030} /success:enable /failure:enable");
// Enable auditing for registry events GUID for Registry subcategory of audit policy https://msdn.microsoft.com/en-us/library/dd973928.aspx
ExternalCommandRunner.RunExternalCommand("auditpol", "/set /subcategory:{0CCE921E-69AE-11D9-BED3-505054503030} /success:enable /failure:enable");
}
}

public override void StopRun()
Expand All @@ -60,24 +67,30 @@ public override void StopRun()
{
throw new PlatformNotSupportedException("ExecuteWindows is only supported on Windows platforms.");
}
// restore the old auditpolicy
ExternalCommandRunner.RunExternalCommand("auditpol", $"/restore /file:{tmpFileName}");
if (log is { })
{
// restore the old auditpolicy
ExternalCommandRunner.RunExternalCommand("auditpol", $"/restore /file:{tmpFileName}");

//delete temporary file
ExternalCommandRunner.RunExternalCommand("del", tmpFileName);
//delete temporary file
ExternalCommandRunner.RunExternalCommand("del", tmpFileName);

log.EnableRaisingEvents = false;
log.EnableRaisingEvents = false;
}
}

protected virtual void Dispose(bool disposing)
{
if (disposing)
{
log.Dispose();
if (log is { })
{
log.Dispose();
}
}
}

private readonly EventLog log = new("System");
private readonly EventLog? log;

private readonly string tmpFileName = Path.GetTempFileName();
}
Expand Down
18 changes: 9 additions & 9 deletions Lib/Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@

<ItemGroup>
<PackageReference Include="MedallionShell" Version="1.6.2" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" />
<PackageReference Include="Microsoft.CST.OAT" Version="1.2.45" />
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.2.13" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CST.OAT" Version="1.2.54" />
<PackageReference Include="Microsoft.CST.RecursiveExtractor" Version="1.2.20" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.5" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.12" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" />
<PackageReference Include="System.Management" Version="7.0.1" />
<PackageReference Include="System.Management" Version="7.0.2" />
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="7.0.0" />
Expand All @@ -61,7 +61,7 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="sqlite" Version="3.13.0" />
<PackageReference Include="Microsoft.TSS" Version="2.1.1" />
<PackageReference Include="PeNet" Version="3.0.0" />
<PackageReference Include="PeNet" Version="4.0.2" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\analyses.json" Link="analyses.json" />
Expand Down
2 changes: 1 addition & 1 deletion Lib/Utils/SqliteDatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ public override void InsertRun(AsaRun run)
}
catch (SqliteException e)
{
Log.Warning(e.StackTrace);
Log.Warning(e.StackTrace ?? string.Empty);
Log.Warning(e.Message);
}
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/DiffTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using System.Linq;
using Microsoft.CST.AttackSurfaceAnalyzer.Collectors;
using Microsoft.CST.AttackSurfaceAnalyzer.Objects;
using Microsoft.CST.AttackSurfaceAnalyzer.Types;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Win32;

namespace Tests;
namespace Microsoft.CST.AttackSurfaceAnalyzer.Tests;

/// <summary>
/// Test that the compare logic generates the correct diffs for various object configurations
/// </summary>
[TestClass]
public class DiffTests
{
Expand Down
6 changes: 3 additions & 3 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit acb21da

Please sign in to comment.