95 lines
2.7 KiB
C#
95 lines
2.7 KiB
C#
using StellaOps.Scanner.Reachability.Slices;
|
|
using StellaOps.Scanner.WebService.Domain;
|
|
|
|
namespace StellaOps.Scanner.WebService.Services;
|
|
|
|
/// <summary>
|
|
/// Query request for reachability slices.
|
|
/// </summary>
|
|
public sealed record SliceQueryRequest
|
|
{
|
|
public string? CveId { get; init; }
|
|
public IReadOnlyList<string>? Symbols { get; init; }
|
|
public IReadOnlyList<string>? Entrypoints { get; init; }
|
|
public string? PolicyHash { get; init; }
|
|
public required string ScanId { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Response from slice query.
|
|
/// </summary>
|
|
public sealed record SliceQueryResponse
|
|
{
|
|
public required string SliceDigest { get; init; }
|
|
public required string Verdict { get; init; }
|
|
public required double Confidence { get; init; }
|
|
public IReadOnlyList<string>? PathWitnesses { get; init; }
|
|
public required bool CacheHit { get; init; }
|
|
public string? JobId { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replay request for slice verification.
|
|
/// </summary>
|
|
public sealed record SliceReplayRequest
|
|
{
|
|
public required string SliceDigest { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Response from slice replay verification.
|
|
/// </summary>
|
|
public sealed record SliceReplayResponse
|
|
{
|
|
public required bool Match { get; init; }
|
|
public required string OriginalDigest { get; init; }
|
|
public required string RecomputedDigest { get; init; }
|
|
public SliceDiff? Diff { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Diff information when replay doesn't match.
|
|
/// </summary>
|
|
public sealed record SliceDiff
|
|
{
|
|
public IReadOnlyList<string>? MissingNodes { get; init; }
|
|
public IReadOnlyList<string>? ExtraNodes { get; init; }
|
|
public IReadOnlyList<string>? MissingEdges { get; init; }
|
|
public IReadOnlyList<string>? ExtraEdges { get; init; }
|
|
public string? VerdictDiff { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Service for querying and managing reachability slices.
|
|
/// </summary>
|
|
public interface ISliceQueryService
|
|
{
|
|
/// <summary>
|
|
/// Query reachability for CVE/symbols and generate slice.
|
|
/// </summary>
|
|
Task<SliceQueryResponse> QueryAsync(
|
|
SliceQueryRequest request,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Retrieve an attested slice by digest.
|
|
/// </summary>
|
|
Task<ReachabilitySlice?> GetSliceAsync(
|
|
string digest,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Retrieve DSSE envelope for a slice.
|
|
/// </summary>
|
|
Task<object?> GetSliceDsseAsync(
|
|
string digest,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Verify slice reproducibility by recomputing.
|
|
/// </summary>
|
|
Task<SliceReplayResponse> ReplayAsync(
|
|
SliceReplayRequest request,
|
|
CancellationToken cancellationToken = default);
|
|
}
|