-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial Yubikey support * Rebuilt the Yubikey Policy to allow multiple policies Added more testcases 5.7.1 is now available. * Allow same version for Min and Max firmware * Revert b36a062 Fixed Firmware checks Added FIPS yubikey check * Update to xUnit To be able to use KeyAlgorithms in XML they need to be public * Fix nunit output change from 1=>2 Update .any() to Assert.Contains Regresion in CCV, error for missing substition should have what module it came from * Add EWT logging Add Program to generate Manifest Add some fixes and logging and more EWT tests for Yubikeys * Copy the EWT dll/man to the output Add checks for XML * Basic MSI * Rename support projects to support. Add another XML Policy test * fix after changing to support. * Update GenerateEWTManifest to net8.0-windows7.0 * Update install.ps1 to install the Manifest for EWT Logging * Remove MSI installer as that was.. to big for this stage * Also checks if the provider is registered with Get-WinEvent before unregistering * Make Tasks static
- Loading branch information
Showing
22 changed files
with
2,025 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Diagnostics.Tracing; | ||
using TameMyCerts; | ||
|
||
// Generate the manifest | ||
string? manifest = EventSource.GenerateManifest(typeof(EWTLogger), "TameMyCerts.Events.dll"); | ||
// Save the manifest to a file | ||
if (manifest is not null) | ||
{ | ||
File.WriteAllText("TameMyCerts.Events.man", manifest); | ||
Console.WriteLine("Manifest generated and saved to TameMyCerts.Events.man"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Failed to generate manifest. The manifest content is null."); | ||
} |
44 changes: 44 additions & 0 deletions
44
Support.GenerateEWTManifest/Support.GenerateEWTManifest.csproj
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,44 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TameMyCerts\TameMyCerts.csproj" /> | ||
</ItemGroup> | ||
|
||
<Target Name="GenerateManifest" AfterTargets="Build"> | ||
<Exec Command="$(TargetDir)\$(TargetName).exe" WorkingDirectory="$(TargetDir)" /> | ||
</Target> | ||
|
||
<Target Name="MessageCompiler" AfterTargets="Build" DependsOnTargets="GenerateManifest"> | ||
<Exec Command=""$(NuGetPackageRoot)microsoft.windows.sdk.buildtools\10.0.26100.1742\bin\10.0.26100.0\x64\mc.exe" "TameMyCerts.Events.man" -r ." WorkingDirectory="$(TargetDir)" /> | ||
</Target> | ||
|
||
<Target Name="ResourceCompiler" AfterTargets="Build" DependsOnTargets="MessageCompiler"> | ||
<Exec Command=""$(NuGetPackageRoot)microsoft.windows.sdk.buildtools\10.0.26100.1742\bin\10.0.26100.0\x64\rc.exe" "TameMyCerts.Events.rc"" WorkingDirectory="$(TargetDir)" /> | ||
</Target> | ||
|
||
<Target Name="BuildDll" AfterTargets="Build" DependsOnTargets="MessageCompiler"> | ||
<Exec Command=""$(MSBuildSDKsPath)\..\Current\Bin\Roslyn\csc.exe" /out:TameMyCerts.Events.dll /target:library /win32res:TameMyCerts.Events.res" WorkingDirectory="$(TargetDir)" /> | ||
</Target> | ||
|
||
<Target Name="CopyOutputFiles" AfterTargets="Build"> | ||
<ItemGroup> | ||
<!-- Include DLLs, XMLs, and JSON files from the output path --> | ||
<FilesToCopy Include="$(OutputPath)**\TameMyCerts.Events.dll" /> | ||
<FilesToCopy Include="$(OutputPath)**\TameMyCerts.Events.man" /> | ||
</ItemGroup> | ||
|
||
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="..\TameMyCerts\bin\$(Configuration)\$(TargetFramework)\" SkipUnchangedFiles="true" /> | ||
|
||
</Target> | ||
</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,22 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.Tracing; | ||
using TameMyCerts; | ||
|
||
namespace TameMyCerts.Tests | ||
{ | ||
public class EWTLoggerListener : EventListener | ||
{ | ||
private readonly List<EventWrittenEventArgs> events = new List<EventWrittenEventArgs>(); | ||
protected override void OnEventWritten(EventWrittenEventArgs eventData) { events.Add(eventData); } | ||
public List<EventWrittenEventArgs> Events => events; | ||
public void ClearEvents() { events.Clear(); } | ||
|
||
protected override void OnEventSourceCreated(EventSource eventSource) | ||
{ | ||
if (eventSource.Name == "TameMyCerts") | ||
{ | ||
EnableEvents(eventSource, EventLevel.LogAlways, (EventKeywords)(-1)); | ||
} | ||
} | ||
} | ||
} |
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,99 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestPlatform.Utilities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using TameMyCerts.Enums; | ||
using TameMyCerts.Models; | ||
using TameMyCerts.Validators; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static System.Net.Mime.MediaTypeNames; | ||
|
||
namespace TameMyCerts.Tests; | ||
|
||
public class XMLPolicyTests | ||
{ | ||
private EWTLoggerListener _listener; | ||
private readonly ITestOutputHelper output; | ||
|
||
public XMLPolicyTests(ITestOutputHelper output) | ||
{ | ||
this.output = output; | ||
this._listener = new EWTLoggerListener(); | ||
} | ||
|
||
internal void PrintResult(CertificateRequestValidationResult result) | ||
{ | ||
output.WriteLine("0x{0:X} ({0}) {1}.", result.StatusCode, | ||
new Win32Exception(result.StatusCode).Message); | ||
output.WriteLine(string.Join("\n", result.Description)); | ||
} | ||
|
||
[Fact] | ||
public void Test_reading_compliant_XML() | ||
{ | ||
var filename = Path.GetTempFileName(); | ||
|
||
string sampleXML = @"<CertificateRequestPolicy xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" | ||
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | ||
<AuditOnly>false</AuditOnly> | ||
</CertificateRequestPolicy>"; | ||
File.WriteAllText(filename, sampleXML); | ||
|
||
CertificateRequestPolicyCacheEntry cacheEntry = new CertificateRequestPolicyCacheEntry(filename); | ||
|
||
Assert.False(cacheEntry.CertificateRequestPolicy.AuditOnly); | ||
Assert.Empty(cacheEntry.ErrorMessage); | ||
|
||
File.Delete(filename); | ||
} | ||
|
||
[Fact] | ||
public void Test_Unknown_XML_Element() | ||
{ | ||
var filename = Path.GetTempFileName(); | ||
|
||
string sampleXML = @"<CertificateRequestPolicy xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" | ||
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | ||
<ThisDoewNotExist>false</ThisDoewNotExist> | ||
</CertificateRequestPolicy> | ||
"; | ||
File.WriteAllText(filename, sampleXML); | ||
_listener.ClearEvents(); | ||
|
||
CertificateRequestPolicyCacheEntry cacheEntry = new CertificateRequestPolicyCacheEntry(filename); | ||
|
||
Assert.Empty(cacheEntry.ErrorMessage); | ||
Assert.Equal(2, _listener.Events.Count); | ||
Assert.Equal(92, _listener.Events[0].EventId); | ||
|
||
File.Delete(filename); | ||
} | ||
|
||
[Fact] | ||
public void Test_Unknown_XML_Element2() | ||
{ | ||
var filename = Path.GetTempFileName(); | ||
|
||
string sampleXML = @"<CertificateRequestPolicy xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" | ||
xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> | ||
<DirectoryServicesMapping><AllowedOrganizationalUnits><Test>This should fault</Test></AllowedOrganizationalUnits></DirectoryServicesMapping> | ||
</CertificateRequestPolicy> | ||
"; | ||
File.WriteAllText(filename, sampleXML); | ||
_listener.ClearEvents(); | ||
|
||
CertificateRequestPolicyCacheEntry cacheEntry = new CertificateRequestPolicyCacheEntry(filename); | ||
|
||
Assert.Empty(cacheEntry.ErrorMessage); | ||
Assert.Equal(2, _listener.Events.Count); | ||
Assert.Equal(92, _listener.Events[0].EventId); | ||
|
||
File.Delete(filename); | ||
} | ||
|
||
} |
Oops, something went wrong.