Complete batch 012 (golden set diff) and 013 (advisory chat), fix build errors
Sprints completed: - SPRINT_20260110_012_* (golden set diff layer - 10 sprints) - SPRINT_20260110_013_* (advisory chat - 4 sprints) Build fixes applied: - Fix namespace conflicts with Microsoft.Extensions.Options.Options.Create - Fix VexDecisionReachabilityIntegrationTests API drift (major rewrite) - Fix VexSchemaValidationTests FluentAssertions method name - Fix FixChainGateIntegrationTests ambiguous type references - Fix AdvisoryAI test files required properties and namespace aliases - Add stub types for CveMappingController (ICveSymbolMappingService) - Fix VerdictBuilderService static context issue Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
|
||||
using StellaOps.BinaryIndex.GoldenSet.Authoring;
|
||||
using StellaOps.BinaryIndex.GoldenSet.Authoring.Extractors;
|
||||
|
||||
namespace StellaOps.BinaryIndex.GoldenSet;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for registering GoldenSet services.
|
||||
/// </summary>
|
||||
public static class GoldenSetServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds GoldenSet services to the dependency injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <param name="configuration">The configuration.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddGoldenSetServices(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
// Configuration
|
||||
services.AddOptions<GoldenSetOptions>()
|
||||
.Bind(configuration.GetSection(GoldenSetOptions.SectionName))
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
// Core services
|
||||
services.TryAddSingleton<ISinkRegistry, SinkRegistry>();
|
||||
services.TryAddSingleton<IGoldenSetValidator, GoldenSetValidator>();
|
||||
|
||||
// Memory cache (if not already registered)
|
||||
services.AddMemoryCache();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds GoldenSet authoring services to the dependency injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddGoldenSetAuthoring(this IServiceCollection services)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
// Source extractors
|
||||
services.TryAddEnumerable(ServiceDescriptor.Singleton<IGoldenSetSourceExtractor, NvdGoldenSetExtractor>());
|
||||
|
||||
// Composite extractor
|
||||
services.TryAddSingleton<IGoldenSetExtractor, GoldenSetExtractor>();
|
||||
|
||||
// Upstream commit analyzer
|
||||
services.TryAddSingleton<IUpstreamCommitAnalyzer, UpstreamCommitAnalyzer>();
|
||||
|
||||
// Enrichment service
|
||||
services.TryAddScoped<IGoldenSetEnrichmentService, GoldenSetEnrichmentService>();
|
||||
|
||||
// Review workflow
|
||||
services.TryAddScoped<IGoldenSetReviewService, GoldenSetReviewService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds PostgreSQL-based GoldenSet storage to the dependency injection container.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddGoldenSetPostgresStorage(this IServiceCollection services)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
services.TryAddScoped<IGoldenSetStore, PostgresGoldenSetStore>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a CVE validator implementation to the dependency injection container.
|
||||
/// </summary>
|
||||
/// <typeparam name="TValidator">The CVE validator implementation type.</typeparam>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddGoldenSetCveValidator<TValidator>(this IServiceCollection services)
|
||||
where TValidator : class, ICveValidator
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
services.TryAddSingleton<ICveValidator, TValidator>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user