-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix first run bug. * Remove unneeded .ToArray() * Delete SqliteFilename * Fix Roslyn Warnings * Update DatabaseManager.cs * Update InsertTestsWithIntermittentTransactions.cs * Allow journal mode configuration Fix pragmas to apply everytime a connection is opened per dotnet/efcore#5024 * Use a settings object for passing database settings. Add a few more settings (pragma passthroughs). * Add CommitTests * Rename files. * Move/Rename files. Adds Query Tests * Update QueryTests.cs Documentation * Make Synchronous a string so the values are more obvious * Code Cleanup * Add LiteDbManager placeholder. * Add prelim litedb support (for benchmarking). * Progress towards LiteDb Benchmark * Small fixes * Update LiteDbManager.cs * Add System.Data.Sqlite implementation of DB manager * Add nullable checks. * Nullable fixes * More nullable fixes * Nullable Fixes pt. 1 Mostly finished with lib. * Finish nullable work in lib Aside from the experimental litedb work. * More nullable fixes. * More nullable work. Re-adds SystemSQLite support. * Fixes for SystemSQLite support * Finish nullable work * clean up GetCollectModified * Add LiteDb Query Tests * Move System.Data.SQLite and LiteDB code into the benchmarks Removes those dependencies from the main library and cli. * Fix null reference exceptions * Remove old default arguments We now use null * Add a GetAllMissing function * Update BaseCompare to use GetAllMissing * Fix constructors so Objects are properly deserializable. * Add new GetAllMissing2 function This is a hybrid between the two approaches. * Adds crypto tests * Pull get missing query out out function * Update FileSystemCollector.cs * Update csproj files to improve assembly names * Update csproj and pipelines * Fix pipelines * Rename tests file. * Update to use SHA512 * Nullable work. * Fix build. * Help the pipeline find the tests properly * Update Strings.cs * Update Strings.cs * Update AsaLibTests.cs * Update pr-validation.yml Now properly fail when tests fail but still report test results. * Add BatchSize for writenext * Update SqlConnectionHolder.cs * Update SqlConnectionHolder.cs * Update batching * fix race condition * Update InsertTestsWithoutTransactions.cs * Fix batch size default and max batch size. * Fix comobjectcollector * Fix registry collector. * Centralize code for translating sid to names Only attempt to do so when it could possibly succeed, this reduces number of exceptions dramatically. * Update AsaLibTests.cs * Update AsaLibTests.cs * Fix registry objects to distinguish which view they were gathered from. * Gather Com Objects in Both Views
- Loading branch information
Showing
129 changed files
with
4,854 additions
and
1,970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using AttackSurfaceAnalyzer.Objects; | ||
using AttackSurfaceAnalyzer.Utils; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace AttackSurfaceAnalyzer.Benchmarks | ||
{ | ||
public class AsaDatabaseBenchmark | ||
{ | ||
// Bag of reusable objects to write to the database. | ||
public static readonly ConcurrentBag<FileSystemObject> BagOfObjects = new ConcurrentBag<FileSystemObject>(); | ||
|
||
public static FileSystemObject GetRandomObject(int ObjectPadding = 0) | ||
{ | ||
BagOfObjects.TryTake(out FileSystemObject? obj); | ||
|
||
if (obj != null) | ||
{ | ||
obj.Path = CryptoHelpers.GetRandomString(32); | ||
return obj; | ||
} | ||
else | ||
{ | ||
return new FileSystemObject(CryptoHelpers.GetRandomString(32)) | ||
{ | ||
// Pad this field with extra data. | ||
FileType = CryptoHelpers.GetRandomString(ObjectPadding), | ||
}; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<ReleaseVersion>2.1-alpha</ReleaseVersion> | ||
<LangVersion>8.0</LangVersion> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" /> | ||
<PackageReference Include="LiteDB" Version="5.0.4" /> | ||
<PackageReference Include="System.Data.SQLite" Version="1.0.112" /> | ||
<PackageReference Include="murmurhash" Version="1.0.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Lib\Lib.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="BenchmarkDotNet.Artifacts\OldResults\AttackSurfaceAnalyzer.Benchmarks.LiteDbInsertTests-report-github.md" /> | ||
<None Include="BenchmarkDotNet.Artifacts\OldResults\AttackSurfaceAnalyzer.Benchmarks.LiteDbInsertTests-report.csv" /> | ||
<None Include="BenchmarkDotNet.Artifacts\OldResults\AttackSurfaceAnalyzer.Benchmarks.LiteDbInsertTests-report.html" /> | ||
<None Include="BenchmarkDotNet.Artifacts\OldResults\AttackSurfaceAnalyzer.Benchmarks.LiteDbInsertTests-report-full.json" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using AttackSurfaceAnalyzer.Utils; | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace AttackSurfaceAnalyzer.Benchmarks | ||
{ | ||
[MarkdownExporterAttribute.GitHub] | ||
[JsonExporterAttribute.Full] | ||
public class CommitTest | ||
{ | ||
//Rows to write in the open transaction before the commit | ||
[Params(10000, 20000, 40000)] | ||
public int N { get; set; } | ||
|
||
// The number of Shards/Threads to use for Database operations | ||
[Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)] | ||
public int Shards { get; set; } | ||
|
||
[Params("OFF", "DELETE", "WAL", "MEMORY")] | ||
public string JournalMode { get; set; } | ||
|
||
public CommitTest() | ||
{ | ||
Logger.Setup(true, true); | ||
Strings.Setup(); | ||
} | ||
|
||
[Benchmark] | ||
public void CommitTransaction() | ||
{ | ||
DatabaseManager.Commit(); | ||
} | ||
|
||
public void Setup() | ||
{ | ||
DatabaseManager.Setup(filename: $"AsaBenchmark_{Shards}.sqlite", new DBSettings() | ||
{ | ||
JournalMode = JournalMode, | ||
ShardingFactor = Shards | ||
}); | ||
} | ||
|
||
[IterationSetup] | ||
public void IterationSetup() | ||
{ | ||
Setup(); | ||
DatabaseManager.BeginTransaction(); | ||
InsertTestsWithoutTransactions.Insert_X_Objects(N); | ||
} | ||
|
||
[IterationCleanup] | ||
public void IterationCleanup() | ||
{ | ||
DatabaseManager.Destroy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using AttackSurfaceAnalyzer.Objects; | ||
using AttackSurfaceAnalyzer.Utils; | ||
using BenchmarkDotNet.Attributes; | ||
using Murmur; | ||
using Serilog; | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Security.Policy; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Utf8Json; | ||
|
||
namespace AttackSurfaceAnalyzer.Benchmarks | ||
{ | ||
[MarkdownExporterAttribute.GitHub] | ||
[JsonExporterAttribute.Full] | ||
public class CryptoTests : AsaDatabaseBenchmark | ||
{ | ||
// The amount of padding to add to the object in bytes | ||
// Default size is approx 530 bytes serialized | ||
// Does not include SQL overhead | ||
[Params(0)] | ||
public int ObjectPadding { get; set; } | ||
|
||
// The number of iterations per run | ||
[Params(100000)] | ||
public int N { get; set; } | ||
|
||
static HashAlgorithm murmur128 = MurmurHash.Create128(); | ||
static HashAlgorithm sha256 = SHA256.Create(); | ||
|
||
static HashAlgorithm sha512 = SHA512.Create(); | ||
|
||
private ConcurrentQueue<byte[]> hashObjects = new ConcurrentQueue<byte[]>(); | ||
|
||
#nullable disable | ||
public CryptoTests() | ||
#nullable restore | ||
{ | ||
|
||
} | ||
|
||
[Benchmark (Baseline = true)] | ||
public void Generate_N_SHA256_Hashes() | ||
{ | ||
for (int i = 0; i < N; i++) | ||
{ | ||
hashObjects.TryDequeue(out byte[]? result); | ||
if (result is byte[]) | ||
{ | ||
_ = sha256.ComputeHash(result); | ||
hashObjects.Enqueue(result); | ||
} | ||
else | ||
{ | ||
Log.Information("The queue is polluted with nulls"); | ||
} | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void Generate_N_SHA512_Hashes() | ||
{ | ||
for (int i = 0; i < N; i++) | ||
{ | ||
hashObjects.TryDequeue(out byte[]? result); | ||
if (result is byte[]) | ||
{ | ||
_ = sha512.ComputeHash(result); | ||
hashObjects.Enqueue(result); | ||
} | ||
else | ||
{ | ||
Log.Information("The queue is polluted with nulls"); | ||
} | ||
} | ||
} | ||
|
||
[Benchmark] | ||
public void Generate_N_Murmur_Hashes() | ||
{ | ||
for (int i = 0; i < N; i++) | ||
{ | ||
hashObjects.TryDequeue(out byte[]? result); | ||
if (result is byte[]) | ||
{ | ||
_ = murmur128.ComputeHash(result); | ||
hashObjects.Enqueue(result); | ||
} | ||
else | ||
{ | ||
Log.Information("The queue is polluted with nulls"); | ||
} | ||
} | ||
} | ||
|
||
|
||
[GlobalSetup] | ||
public void GlobalSetup() | ||
{ | ||
while (hashObjects.Count < N) | ||
{ | ||
hashObjects.Enqueue(JsonSerializer.Serialize<FileSystemObject>(GetRandomObject(ObjectPadding))); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.