Add unit tests for SBOM ingestion and transformation
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Implement `SbomIngestServiceCollectionExtensionsTests` to verify the SBOM ingestion pipeline exports snapshots correctly. - Create `SbomIngestTransformerTests` to ensure the transformation produces expected nodes and edges, including deduplication of license nodes and normalization of timestamps. - Add `SbomSnapshotExporterTests` to test the export functionality for manifest, adjacency, nodes, and edges. - Introduce `VexOverlayTransformerTests` to validate the transformation of VEX nodes and edges. - Set up project file for the test project with necessary dependencies and configurations. - Include JSON fixture files for testing purposes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.CommandLine;
|
||||
using System;
|
||||
using System.CommandLine;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -9,7 +10,8 @@ using StellaOps.Auth.Client;
|
||||
using StellaOps.Cli.Commands;
|
||||
using StellaOps.Cli.Configuration;
|
||||
using StellaOps.Cli.Services;
|
||||
using StellaOps.Cli.Telemetry;
|
||||
using StellaOps.Cli.Telemetry;
|
||||
using StellaOps.AirGap.Policy;
|
||||
|
||||
namespace StellaOps.Cli;
|
||||
|
||||
@@ -24,7 +26,8 @@ internal static class Program
|
||||
services.AddSingleton(options);
|
||||
|
||||
var verbosityState = new VerbosityState();
|
||||
services.AddSingleton(verbosityState);
|
||||
services.AddSingleton(verbosityState);
|
||||
services.AddAirGapEgressPolicy(configuration);
|
||||
|
||||
services.AddLogging(builder =>
|
||||
{
|
||||
@@ -89,7 +92,7 @@ internal static class Program
|
||||
{
|
||||
client.BaseAddress = authorityUri;
|
||||
}
|
||||
});
|
||||
}).AddEgressPolicyGuard("stellaops-cli", "authority-revocation");
|
||||
}
|
||||
|
||||
services.AddHttpClient<IBackendOperationsClient, BackendOperationsClient>(client =>
|
||||
@@ -100,7 +103,7 @@ internal static class Program
|
||||
{
|
||||
client.BaseAddress = backendUri;
|
||||
}
|
||||
});
|
||||
}).AddEgressPolicyGuard("stellaops-cli", "backend-api");
|
||||
|
||||
services.AddHttpClient<IConcelierObservationsClient, ConcelierObservationsClient>(client =>
|
||||
{
|
||||
@@ -110,7 +113,14 @@ internal static class Program
|
||||
{
|
||||
client.BaseAddress = concelierUri;
|
||||
}
|
||||
});
|
||||
}).AddEgressPolicyGuard("stellaops-cli", "concelier-api");
|
||||
|
||||
services.AddHttpClient("stellaops-cli.ingest-download")
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||
{
|
||||
AutomaticDecompression = DecompressionMethods.All
|
||||
})
|
||||
.AddEgressPolicyGuard("stellaops-cli", "sources-ingest");
|
||||
|
||||
services.AddSingleton<IScannerExecutor, ScannerExecutor>();
|
||||
services.AddSingleton<IScannerInstaller, ScannerInstaller>();
|
||||
@@ -127,8 +137,30 @@ internal static class Program
|
||||
};
|
||||
|
||||
var rootCommand = CommandFactory.Create(serviceProvider, options, cts.Token, loggerFactory);
|
||||
var commandConfiguration = new CommandLineConfiguration(rootCommand);
|
||||
var commandExit = await commandConfiguration.InvokeAsync(args, cts.Token).ConfigureAwait(false);
|
||||
var commandConfiguration = new CommandLineConfiguration(rootCommand);
|
||||
int commandExit;
|
||||
try
|
||||
{
|
||||
commandExit = await commandConfiguration.InvokeAsync(args, cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (AirGapEgressBlockedException ex)
|
||||
{
|
||||
var guardLogger = loggerFactory.CreateLogger("StellaOps.Cli.AirGap");
|
||||
guardLogger.LogError("{ErrorCode}: {Reason} Remediation: {Remediation}", AirGapEgressBlockedException.ErrorCode, ex.Reason, ex.Remediation);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ex.DocumentationUrl))
|
||||
{
|
||||
guardLogger.LogInformation("Documentation: {DocumentationUrl}", ex.DocumentationUrl);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ex.SupportContact))
|
||||
{
|
||||
guardLogger.LogInformation("Support contact: {SupportContact}", ex.SupportContact);
|
||||
}
|
||||
|
||||
Console.Error.WriteLine(ex.Message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
var finalExit = Environment.ExitCode != 0 ? Environment.ExitCode : commandExit;
|
||||
if (cts.IsCancellationRequested && finalExit == 0)
|
||||
|
||||
Reference in New Issue
Block a user