// ----------------------------------------------------------------------------- // IInternalCallGraphBuilder.cs // Sprint: SPRINT_3700_0003_0001_trigger_extraction // Description: Interface for building internal call graphs from package sources. // ----------------------------------------------------------------------------- using System.Threading; using System.Threading.Tasks; namespace StellaOps.Scanner.VulnSurfaces.CallGraph; /// /// Builds internal call graphs from package/assembly sources. /// Implementations exist for different ecosystems (.NET, Java, Node.js, Python). /// public interface IInternalCallGraphBuilder { /// /// Ecosystem this builder supports (e.g., "nuget", "maven", "npm", "pypi"). /// string Ecosystem { get; } /// /// Checks if this builder can handle the given package. /// /// Path to package archive or extracted directory. bool CanHandle(string packagePath); /// /// Builds an internal call graph from a package. /// /// Build request with package details. /// Cancellation token. /// Internal call graph for the package. Task BuildAsync( InternalCallGraphBuildRequest request, CancellationToken cancellationToken = default); } /// /// Request to build an internal call graph. /// public sealed record InternalCallGraphBuildRequest { /// /// Package identifier (PURL or package name). /// public required string PackageId { get; init; } /// /// Package version. /// public required string Version { get; init; } /// /// Path to the package archive or extracted directory. /// public required string PackagePath { get; init; } /// /// Whether to include private methods in the graph. /// Default is false (only public API surface). /// public bool IncludePrivateMethods { get; init; } /// /// Maximum depth for call graph traversal. /// public int MaxDepth { get; init; } = 20; } /// /// Result of building an internal call graph. /// public sealed record InternalCallGraphBuildResult { /// /// Whether the build succeeded. /// public bool Success { get; init; } /// /// The built call graph (null if failed). /// public InternalCallGraph? Graph { get; init; } /// /// Error message if build failed. /// public string? Error { get; init; } /// /// Build duration. /// public TimeSpan Duration { get; init; } /// /// Number of assemblies/files processed. /// public int FilesProcessed { get; init; } /// /// Creates a successful result. /// public static InternalCallGraphBuildResult Ok(InternalCallGraph graph, TimeSpan duration, int filesProcessed) => new() { Success = true, Graph = graph, Duration = duration, FilesProcessed = filesProcessed }; /// /// Creates a failed result. /// public static InternalCallGraphBuildResult Fail(string error, TimeSpan duration) => new() { Success = false, Error = error, Duration = duration }; }