save progress
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
// Licensed under AGPL-3.0-or-later. See LICENSE in the project root.
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using StellaOps.BinaryIndex.Disassembly;
|
||||
using StellaOps.BinaryIndex.Normalization;
|
||||
using StellaOps.BinaryIndex.Semantic;
|
||||
|
||||
namespace StellaOps.BinaryIndex.DeltaSig;
|
||||
|
||||
@@ -15,17 +17,52 @@ public static class ServiceCollectionExtensions
|
||||
/// <summary>
|
||||
/// Adds delta signature generation and matching services.
|
||||
/// Requires disassembly and normalization services to be registered.
|
||||
/// If semantic services are registered, semantic fingerprinting will be available.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddDeltaSignatures(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IDeltaSignatureGenerator, DeltaSignatureGenerator>();
|
||||
services.AddSingleton<IDeltaSignatureGenerator>(sp =>
|
||||
{
|
||||
var disassembly = sp.GetRequiredService<DisassemblyService>();
|
||||
var normalization = sp.GetRequiredService<NormalizationService>();
|
||||
var logger = sp.GetRequiredService<ILogger<DeltaSignatureGenerator>>();
|
||||
|
||||
// Semantic services are optional
|
||||
var irLifting = sp.GetService<IIrLiftingService>();
|
||||
var graphExtractor = sp.GetService<ISemanticGraphExtractor>();
|
||||
var fingerprintGenerator = sp.GetService<ISemanticFingerprintGenerator>();
|
||||
|
||||
return new DeltaSignatureGenerator(
|
||||
disassembly,
|
||||
normalization,
|
||||
irLifting,
|
||||
graphExtractor,
|
||||
fingerprintGenerator,
|
||||
logger);
|
||||
});
|
||||
|
||||
services.AddSingleton<IDeltaSignatureMatcher, DeltaSignatureMatcher>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds delta signature services with semantic analysis support enabled.
|
||||
/// Requires disassembly and normalization services to be registered.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddDeltaSignaturesWithSemantic(this IServiceCollection services)
|
||||
{
|
||||
// Register semantic services first
|
||||
services.AddBinaryIndexSemantic();
|
||||
|
||||
// Then register delta signature services
|
||||
return services.AddDeltaSignatures();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all binary index services: disassembly, normalization, and delta signatures.
|
||||
/// </summary>
|
||||
@@ -44,4 +81,26 @@ public static class ServiceCollectionExtensions
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds all binary index services with semantic analysis: disassembly, normalization, semantic, and delta signatures.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection.</param>
|
||||
/// <returns>The service collection for chaining.</returns>
|
||||
public static IServiceCollection AddBinaryIndexServicesWithSemantic(this IServiceCollection services)
|
||||
{
|
||||
// Add disassembly with default plugins
|
||||
services.AddDisassemblyServices();
|
||||
|
||||
// Add normalization pipelines
|
||||
services.AddNormalizationPipelines();
|
||||
|
||||
// Add semantic analysis services
|
||||
services.AddBinaryIndexSemantic();
|
||||
|
||||
// Add delta signature services (will pick up semantic services)
|
||||
services.AddDeltaSignatures();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user