namespace StellaOps.Scanner.ChangeTrace.Integration;
///
/// Simplified client interface for ReachGraph operations.
/// This is an adapter interface to decouple ChangeTrace from ReachGraph internals.
///
public interface IReachGraphClient
{
///
/// Get reachability information for a package in an image.
///
/// Image digest (sha256:...).
/// Package URL.
/// Cancellation token.
/// Reachability result.
Task GetReachabilityAsync(
string imageDigest,
string purl,
CancellationToken ct = default);
///
/// Get call paths to a vulnerable function.
///
/// Image digest.
/// Function name.
/// Maximum number of paths to return.
/// Cancellation token.
/// Call path result.
Task GetCallPathsAsync(
string imageDigest,
string functionName,
int maxPaths = 5,
CancellationToken ct = default);
}
///
/// Reachability result for a package.
///
public sealed record ReachabilityResult
{
///
/// Whether the package is reachable from entrypoints.
///
public required bool IsReachable { get; init; }
///
/// Number of reachable call paths.
///
public required int ReachableCallPaths { get; init; }
///
/// Total number of exported symbols.
///
public int TotalSymbols { get; init; }
///
/// Number of reachable symbols.
///
public int ReachableSymbols { get; init; }
///
/// Fraction of package that is unreachable (0.0 to 1.0).
///
public double UnreachableFraction { get; init; }
///
/// Entrypoints that reach this package.
///
public IReadOnlyList? ReachingEntrypoints { get; init; }
}
///
/// Call path result for a function.
///
public sealed record CallPathResult
{
///
/// Number of call paths found.
///
public required int PathCount { get; init; }
///
/// Individual call paths.
///
public IReadOnlyList? Paths { get; init; }
///
/// Shortest path depth.
///
public int? ShortestPathDepth { get; init; }
}
///
/// A single call path from entrypoint to target.
///
public sealed record CallPath
{
///
/// Entrypoint function name.
///
public required string Entrypoint { get; init; }
///
/// Target function name.
///
public required string Target { get; init; }
///
/// Call chain (function names).
///
public required IReadOnlyList Chain { get; init; }
///
/// Path depth (number of calls).
///
public int Depth => Chain.Count;
}