Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Findings Ledger CI / build-test (push) Has been cancelled
Findings Ledger CI / migration-validation (push) Has been cancelled
Findings Ledger CI / generate-manifest (push) Has been cancelled
Lighthouse CI / Lighthouse Audit (push) Has been cancelled
Lighthouse CI / Axe Accessibility Audit (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Reachability Corpus Validation / validate-corpus (push) Has been cancelled
Reachability Corpus Validation / validate-ground-truths (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Reachability Corpus Validation / determinism-check (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
- Introduced `all-edge-reasons.json` to test edge resolution reasons in .NET. - Added `all-visibility-levels.json` to validate method visibility levels in .NET. - Created `dotnet-aspnetcore-minimal.json` for a minimal ASP.NET Core application. - Included `go-gin-api.json` for a Go Gin API application structure. - Added `java-spring-boot.json` for the Spring PetClinic application in Java. - Introduced `legacy-no-schema.json` for legacy application structure without schema. - Created `node-express-api.json` for an Express.js API application structure.
114 lines
4.0 KiB
C#
114 lines
4.0 KiB
C#
using System.Globalization;
|
|
using System.Text.Json;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Spectre.Console;
|
|
using StellaOps.ExportCenter.Core.EvidenceCache;
|
|
|
|
namespace StellaOps.Cli.Commands;
|
|
|
|
internal static partial class CommandHandlers
|
|
{
|
|
internal static async Task<int> HandleExportCacheStatsAsync(
|
|
IServiceProvider services,
|
|
string scanOutputPath,
|
|
bool json,
|
|
bool verbose,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
SetVerbosity(services, verbose);
|
|
|
|
if (string.IsNullOrWhiteSpace(scanOutputPath))
|
|
{
|
|
AnsiConsole.MarkupLine("[red]Scan output path is required.[/]");
|
|
return 1;
|
|
}
|
|
|
|
scanOutputPath = Path.GetFullPath(scanOutputPath);
|
|
if (!Directory.Exists(scanOutputPath))
|
|
{
|
|
AnsiConsole.MarkupLine($"[red]Scan output directory not found:[/] {Markup.Escape(scanOutputPath)}");
|
|
return 1;
|
|
}
|
|
|
|
var cache = services.GetRequiredService<IEvidenceCacheService>();
|
|
var statistics = await cache.GetStatisticsAsync(scanOutputPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
if (json)
|
|
{
|
|
var payload = new
|
|
{
|
|
scanOutput = scanOutputPath,
|
|
statistics
|
|
};
|
|
|
|
AnsiConsole.WriteLine(JsonSerializer.Serialize(payload, JsonOptions));
|
|
return 0;
|
|
}
|
|
|
|
if (statistics.TotalBundles == 0)
|
|
{
|
|
AnsiConsole.MarkupLine("[yellow]No evidence cache entries found.[/]");
|
|
}
|
|
|
|
var table = new Table().AddColumns("Field", "Value");
|
|
table.AddRow("Scan output", Markup.Escape(scanOutputPath));
|
|
table.AddRow("Total bundles", statistics.TotalBundles.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Fully available", statistics.FullyAvailable.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Partially available", statistics.PartiallyAvailable.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Pending enrichment", statistics.PendingEnrichment.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Offline resolvable", FormattableString.Invariant($"{statistics.OfflineResolvablePercentage:0.##}%"));
|
|
table.AddRow("Total size", FormatBytes(statistics.TotalSizeBytes));
|
|
|
|
AnsiConsole.Write(table);
|
|
return 0;
|
|
}
|
|
|
|
internal static async Task<int> HandleExportCacheProcessQueueAsync(
|
|
IServiceProvider services,
|
|
string scanOutputPath,
|
|
bool json,
|
|
bool verbose,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
SetVerbosity(services, verbose);
|
|
|
|
if (string.IsNullOrWhiteSpace(scanOutputPath))
|
|
{
|
|
AnsiConsole.MarkupLine("[red]Scan output path is required.[/]");
|
|
return 1;
|
|
}
|
|
|
|
scanOutputPath = Path.GetFullPath(scanOutputPath);
|
|
if (!Directory.Exists(scanOutputPath))
|
|
{
|
|
AnsiConsole.MarkupLine($"[red]Scan output directory not found:[/] {Markup.Escape(scanOutputPath)}");
|
|
return 1;
|
|
}
|
|
|
|
var cache = services.GetRequiredService<IEvidenceCacheService>();
|
|
var result = await cache.ProcessEnrichmentQueueAsync(scanOutputPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
if (json)
|
|
{
|
|
var payload = new
|
|
{
|
|
scanOutput = scanOutputPath,
|
|
result
|
|
};
|
|
|
|
AnsiConsole.WriteLine(JsonSerializer.Serialize(payload, JsonOptions));
|
|
return 0;
|
|
}
|
|
|
|
var table = new Table().AddColumns("Field", "Value");
|
|
table.AddRow("Scan output", Markup.Escape(scanOutputPath));
|
|
table.AddRow("Processed", result.ProcessedCount.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Failed", result.FailedCount.ToString(CultureInfo.InvariantCulture));
|
|
table.AddRow("Remaining", result.RemainingCount.ToString(CultureInfo.InvariantCulture));
|
|
|
|
AnsiConsole.Write(table);
|
|
return 0;
|
|
}
|
|
}
|
|
|