Skip to content

Commit

Permalink
Rename convert class to avoid collision with System.Convert (#116)
Browse files Browse the repository at this point in the history
* Rename convert class to avoid collision with System.Convert

* Set v2.0.2
  • Loading branch information
iadgovuser29 authored Nov 20, 2024
1 parent 9704571 commit c4cc100
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-hardwaremanifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: dotnet/HardwareManifestPlugin
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-paccor_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: dotnet/paccor_scripts
run: dotnet restore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>NSA Cybersecurity Directorate</Authors>
<PackageId>paccor.HardwareManifestPlugin</PackageId>
<PackageVersion>2.0.1</PackageVersion>
<PackageVersion>2.0.2</PackageVersion>
<PackageTags>paccor;platform;certificate;hardware;manifest;interface</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand All @@ -19,14 +19,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.20.1" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.20.1">
<PackageReference Include="Google.Protobuf" Version="3.28.3" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.28.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<!--Source Link -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="PlatformCertificate.Proto" Version="2.0.3" />
<PackageReference Include="PlatformCertificate.Proto.ProtoFiles" Version="2.0.7" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="PlatformCertificate.Proto" Version="2.0.8" />
<PackageReference Include="PlatformCertificate.Proto.ProtoFiles" Version="2.0.8" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using PlatformCertificateProto;

namespace HardwareManifestPlugin {
public class Convert {
public class HardwareManifestConverter {
public static ManifestV3 FromManifestV2(ManifestV2 v2, string traitDescription, string traitDescriptionUri) {
// Wrap V2 Manifest with Trait details and return a V3 Manifest
ManifestV3 v3 = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>NSA Cybersecurity Directorate</Authors>
<PackageId>paccor.HardwareManifestPluginManager</PackageId>
<PackageVersion>2.0.0</PackageVersion>
<PackageVersion>2.0.2</PackageVersion>
<PackageTags>paccor;platform;certificate;hardware;manifest;plugin;manager</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand All @@ -19,7 +19,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand All @@ -28,7 +28,7 @@

<ItemGroup>
<!--Source Link -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<!--Package resources -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void TestConvertFromManifestV2() {
const string traitDescriptionUri = "https://github.com/nsacyber/paccor/scripts";
var settings = Google.Protobuf.JsonParser.Settings.Default.WithIgnoreUnknownFields(true);
ManifestV2 v2 = new Google.Protobuf.JsonParser(settings).Parse<ManifestV2>(V2ManifestJsonStr);
ManifestV3 v3 = HardwareManifestPlugin.Convert.FromManifestV2(v2, traitDescription, traitDescriptionUri);
ManifestV3 v3 = HardwareManifestPlugin.HardwareManifestConverter.FromManifestV2(v2, traitDescription, traitDescriptionUri);
Assert.That(V3ManifestJsonStr, Is.EqualTo(v3.ToString()));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -10,11 +10,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions dotnet/paccor_scripts/paccor_scripts/paccor_scripts.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
<Authors>NSA Cybersecurity Directorate</Authors>
<PackageId>paccor.paccor_scripts</PackageId>
<PackageVersion>2.0.0</PackageVersion>
<PackageVersion>2.0.2</PackageVersion>
<PackageTags>paccor;platform;certificate;hardware;manifest;scripts;component;class;registry;evidence;collection</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand Down Expand Up @@ -46,9 +46,9 @@

<ItemGroup>
<!--Source Link -->
<PackageReference Include="Google.Protobuf" Version="3.20.1" /><!-- Google.Protobuf reference required for MessageParser -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="PlatformCertificate.Proto" Version="2.0.3" />
<PackageReference Include="Google.Protobuf" Version="3.28.3" /><!-- Google.Protobuf reference required for MessageParser -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="PlatformCertificate.Proto" Version="2.0.8" />
</ItemGroup>
<ItemGroup>
<!--Package resources -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HardwareManifestProto;
using HardwareManifestPlugin;
using HardwareManifestProto;
using System.Runtime.InteropServices;

namespace paccor_scripts {
Expand All @@ -16,11 +17,12 @@ public PaccorComponentScriptsPlugin() {
Name = "paccor_scripts";
Description = "paccor component gathering scripts";
CollectsV2HardwareInformation = true;
CollectsV2HardwareInformation = false;
CollectsV3HardwareInformation = false;
}

public override bool GatherHardwareIdentifiers() {
bool result = false;
string json = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
Task<Tuple<int, string, string>> task = Task.Run(RunWindows);
Tuple<int, string, string> results = task.Result;
Expand All @@ -30,18 +32,20 @@ public override bool GatherHardwareIdentifiers() {
// The allcomponents powershell script writes output to a file to preserve binary data
// that can get corrupted during redirection
if (System.IO.File.Exists(WinTempOutput)) {
string json = System.IO.File.ReadAllText(WinTempOutput);
ManifestV2 = ManifestV2.Parser.WithDiscardUnknownFields(true).ParseJson(json);
result = true;
json = System.IO.File.ReadAllText(WinTempOutput);
}
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) {
Task<Tuple<int, string, string>> task = Task.Run(RunLinux);
Tuple<int, string, string> results = task.Result;
if (task.Exception != null) {
throw task.Exception;
}
string json = results.Item3;
json = results.Item3;
}

if (!string.IsNullOrWhiteSpace(json)) {
ManifestV2 = ManifestV2.Parser.WithDiscardUnknownFields(true).ParseJson(json);
ManifestV3 = HardwareManifestConverter.FromManifestV2(ManifestV2, TraitDescription, TraitDescriptionUri);
result = true;
}
return result;
Expand Down

0 comments on commit c4cc100

Please sign in to comment.