mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-03-21 11:35:52 +00:00
Adds PCIe and Storage Component Class capability to the provisioner
This commit is contained in:
parent
ad0966941d
commit
1dc2d7f409
@ -35,9 +35,11 @@
|
|||||||
<Target Name="CopyFiles" AfterTargets="DeletePDB">
|
<Target Name="CopyFiles" AfterTargets="DeletePDB">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PaccorScriptsDll Include="$(OUTDIR)paccor_scripts.dll"/>
|
<PaccorScriptsDll Include="$(OUTDIR)paccor_scripts.dll"/>
|
||||||
|
<PaccorPcieDll Include="$(OUTDIR)Pcie.dll"/>
|
||||||
|
<PaccorStorageDll Include="$(OUTDIR)Storage.dll"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Copy
|
<Copy
|
||||||
SourceFiles="@(PaccorScriptsDll)"
|
SourceFiles="@(PaccorScriptsDll);@(PaccorPcieDll);@(PaccorStorageDll)"
|
||||||
DestinationFolder="$(PublishDir)plugins"
|
DestinationFolder="$(PublishDir)plugins"
|
||||||
/>
|
/>
|
||||||
</Target>
|
</Target>
|
||||||
|
@ -6,9 +6,10 @@
|
|||||||
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
|
||||||
<StartupObject>hirs.Program</StartupObject>
|
<StartupObject>hirs.Program</StartupObject>
|
||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>true</SelfContained>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<PackageVersion>3.0.1</PackageVersion>
|
<PackageVersion>3.0.5</PackageVersion>
|
||||||
<Release></Release>
|
<Release></Release>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@ -24,22 +25,24 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.20.1" />
|
<PackageReference Include="Google.Protobuf" Version="3.28.3" />
|
||||||
<PackageReference Include="Google.Protobuf.Tools" Version="3.20.1">
|
<PackageReference Include="Google.Protobuf.Tools" Version="3.28.3">
|
||||||
<PrivateAssets>all</PrivateAssets> <!-- These assets will be consumed but won't flow to the parent project -->
|
<PrivateAssets>all</PrivateAssets> <!-- These assets will be consumed but won't flow to the parent project -->
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.TSS" Version="2.1.1" />
|
<PackageReference Include="Microsoft.TSS" Version="2.1.1" />
|
||||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="paccor.HardwareManifestPlugin" Version="1.0.0" />
|
<PackageReference Include="paccor.HardwareManifestPlugin" Version="2.0.5" />
|
||||||
<PackageReference Include="paccor.HardwareManifestPluginManager" Version="1.0.0" />
|
<PackageReference Include="paccor.HardwareManifestPluginManager" Version="2.0.5" />
|
||||||
<PackageReference Include="paccor.paccor_scripts" Version="1.0.1" />
|
<PackageReference Include="paccor.paccor_scripts" Version="2.0.5" />
|
||||||
|
<PackageReference Include="paccor.pcie" Version="0.5.0" />
|
||||||
|
<PackageReference Include="paccor.storage" Version="0.5.0" />
|
||||||
<PackageReference Include="Packaging.Targets" Version="0.1.226">
|
<PackageReference Include="Packaging.Targets" Version="0.1.226">
|
||||||
<PrivateAssets>all</PrivateAssets> <!-- These assets will be consumed but won't flow to the parent project -->
|
<PrivateAssets>all</PrivateAssets> <!-- These assets will be consumed but won't flow to the parent project -->
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
@ -81,7 +84,7 @@
|
|||||||
<Exec Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))'" Command="for /f %%i in ('dir /s /b $(FOLDER_PROTO)\*.proto') do ( $(protoc) -I=$(FOLDER_PROTO) --csharp_out=$(FOLDER_OUT) %%i )" />
|
<Exec Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))'" Command="for /f %%i in ('dir /s /b $(FOLDER_PROTO)\*.proto') do ( $(protoc) -I=$(FOLDER_PROTO) --csharp_out=$(FOLDER_OUT) %%i )" />
|
||||||
<Exec Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'" Command="for file in `ls -1R $(FOLDER_PROTO)/*.proto` ; do $(protoc) -I=$(FOLDER_PROTO) --csharp_out=$(FOLDER_OUT) $file; done " />
|
<Exec Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'" Command="for file in `ls -1R $(FOLDER_PROTO)/*.proto` ; do $(protoc) -I=$(FOLDER_PROTO) --csharp_out=$(FOLDER_OUT) $file; done " />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="$(NuGetPackageRoot)paccor.paccor_scripts/1.0.1/contentFiles/any/net6.0/resources/paccor.paccor_scripts.targets" Condition="Exists('$(NuGetPackageRoot)paccor.paccor_scripts/1.0.1/contentFiles/any/net6.0/resources/paccor.paccor_scripts.targets')" />
|
<Import Project="$(NuGetPackageRoot)paccor.paccor_scripts/2.0.5/contentFiles/any/net8.0/resources/paccor.paccor_scripts.targets" Condition="Exists('$(NuGetPackageRoot)paccor.paccor_scripts/2.0.5/contentFiles/any/net8.0/resources/paccor.paccor_scripts.targets')" />
|
||||||
<Target Name="ImportPaccorScripts" BeforeTargets="PreBuildEvent">
|
<Target Name="ImportPaccorScripts" BeforeTargets="PreBuildEvent">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PaccorScriptsLinux Include="$(dotnet_paccor_scripts_directory)/*" />
|
<PaccorScriptsLinux Include="$(dotnet_paccor_scripts_directory)/*" />
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"certificate_output_directory": "",
|
"certificate_output_directory": "",
|
||||||
"paccor_output_file": "",
|
"paccor_output_file": "",
|
||||||
"event_log_file": "",
|
"event_log_file": "",
|
||||||
"hardware_manifest_collectors": "paccor_scripts",
|
"hardware_manifest_collectors": "paccor_scripts,paccor.pcie,paccor.storage",
|
||||||
|
|
||||||
"Serilog": {
|
"Serilog": {
|
||||||
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||||
|
@ -77,7 +77,7 @@ namespace hirs {
|
|||||||
public virtual string certificate_output_directory {
|
public virtual string certificate_output_directory {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
private List<IHardwareManifest> hardwareManifests = new();
|
private List<IHardwareManifestPlugin> hardwareManifests = new();
|
||||||
private Dictionary<string, string> hardware_manifest_collectors_with_args = new();
|
private Dictionary<string, string> hardware_manifest_collectors_with_args = new();
|
||||||
private bool hardware_manifest_collection_swid_enforced = false;
|
private bool hardware_manifest_collection_swid_enforced = false;
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ namespace hirs {
|
|||||||
List<string> names = hardware_manifest_collectors_with_args.Keys.ToList();
|
List<string> names = hardware_manifest_collectors_with_args.Keys.ToList();
|
||||||
if (!string.IsNullOrWhiteSpace(configFromSettingsFile[Options.hardware_manifest_collection_swid_enforced.ToString()])) {
|
if (!string.IsNullOrWhiteSpace(configFromSettingsFile[Options.hardware_manifest_collection_swid_enforced.ToString()])) {
|
||||||
string hardware_manifest_collection_swid_enforced_str = $"{ configFromSettingsFile[Options.hardware_manifest_collection_swid_enforced.ToString()] }";
|
string hardware_manifest_collection_swid_enforced_str = $"{ configFromSettingsFile[Options.hardware_manifest_collection_swid_enforced.ToString()] }";
|
||||||
hardware_manifest_collection_swid_enforced = Boolean.Parse(hardware_manifest_collection_swid_enforced_str);
|
hardware_manifest_collection_swid_enforced = bool.Parse(hardware_manifest_collection_swid_enforced_str);
|
||||||
Log.Debug("SWID enforcement of Hardware Manifest Plugins are " + (hardware_manifest_collection_swid_enforced ? "en" : "dis") + "abled in settings.");
|
Log.Debug("SWID enforcement of Hardware Manifest Plugins are " + (hardware_manifest_collection_swid_enforced ? "en" : "dis") + "abled in settings.");
|
||||||
}
|
}
|
||||||
hardwareManifests = HardwareManifestPluginManagerUtils.LoadPlugins(names, hardware_manifest_collection_swid_enforced);
|
hardwareManifests = HardwareManifestPluginManagerUtils.LoadPlugins(names, hardware_manifest_collection_swid_enforced);
|
||||||
@ -196,23 +196,21 @@ namespace hirs {
|
|||||||
|
|
||||||
public virtual string RunHardwareManifestCollectors() {
|
public virtual string RunHardwareManifestCollectors() {
|
||||||
Log.Debug("Gathering data from loaded hardware manifest collectors.");
|
Log.Debug("Gathering data from loaded hardware manifest collectors.");
|
||||||
string manifestJson = "";
|
HardwareManifestProto.ManifestV2 manifestJson = new();
|
||||||
foreach (IHardwareManifest manifest in hardwareManifests) {
|
foreach (IHardwareManifestPlugin manifest in hardwareManifests) {
|
||||||
try {
|
try {
|
||||||
Log.Debug(" Configuring " + manifest.Name);
|
Log.Debug(" Configuring " + manifest.Name);
|
||||||
if (hardware_manifest_collectors_with_args.ContainsKey(manifest.Name)) {
|
|
||||||
manifest.Configure(CLI.SplitArgs(hardware_manifest_collectors_with_args[manifest.Name]));
|
|
||||||
}
|
|
||||||
// TODO: Combine JSON Better
|
|
||||||
// OR Return proto objects
|
|
||||||
Log.Debug(" Gathering from " + manifest.Name);
|
Log.Debug(" Gathering from " + manifest.Name);
|
||||||
manifestJson = string.Join(manifestJson, manifest.GatherHardwareManifestAsJsonString());
|
if (manifest.GatherHardwareIdentifiers()) {
|
||||||
|
manifestJson.MergeFrom(manifest.ManifestV2);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.Debug($"Problem retrieving hardware manifest from {manifest.Name}.", e.InnerException);
|
Log.Debug($"Problem retrieving hardware manifest from {manifest.Name}.", e.InnerException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//TODO: Verify JSON?
|
|
||||||
return manifestJson;
|
string manifestString = manifestJson.ToString();
|
||||||
|
return manifestString;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -262,7 +260,7 @@ namespace hirs {
|
|||||||
Log.Debug("Checking Auto Detect TPM setting.");
|
Log.Debug("Checking Auto Detect TPM setting.");
|
||||||
string auto_detect_tpm_str = $"{ configFromSettingsFile[Options.auto_detect_tpm.ToString()] }";
|
string auto_detect_tpm_str = $"{ configFromSettingsFile[Options.auto_detect_tpm.ToString()] }";
|
||||||
try {
|
try {
|
||||||
auto_detect_tpm = Boolean.Parse(auto_detect_tpm_str);
|
auto_detect_tpm = bool.Parse(auto_detect_tpm_str);
|
||||||
Log.Debug(" Auto Detect TPM is " + (auto_detect_tpm ? "en" : "dis") + "abled.");
|
Log.Debug(" Auto Detect TPM is " + (auto_detect_tpm ? "en" : "dis") + "abled.");
|
||||||
} catch (FormatException) {
|
} catch (FormatException) {
|
||||||
auto_detect_tpm = false;
|
auto_detect_tpm = false;
|
||||||
|
@ -3,6 +3,7 @@ using Hirs.Pb;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -30,14 +30,14 @@ namespace hirs {
|
|||||||
|
|
||||||
private readonly Tpm2 tpm;
|
private readonly Tpm2 tpm;
|
||||||
|
|
||||||
private readonly Boolean simulator;
|
private readonly bool simulator;
|
||||||
|
|
||||||
private List<AuthSession> sessionTracking = new List<AuthSession>();
|
private List<AuthSession> sessionTracking = new List<AuthSession>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For TCP TpmDevices
|
* For TCP TpmDevices
|
||||||
*/
|
*/
|
||||||
public CommandTpm(Boolean sim, string ip, int port) {
|
public CommandTpm(bool sim, string ip, int port) {
|
||||||
simulator = sim;
|
simulator = sim;
|
||||||
Tpm2Device tpmDevice = new TcpTpmDevice(ip, port);
|
Tpm2Device tpmDevice = new TcpTpmDevice(ip, port);
|
||||||
tpm = TpmSetupByType(tpmDevice);
|
tpm = TpmSetupByType(tpmDevice);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user