Add receipt input JSON and SHA256 hash for CVSS policy scoring tests

- Introduced a new JSON fixture `receipt-input.json` containing base, environmental, and threat metrics for CVSS scoring.
- Added corresponding SHA256 hash file `receipt-input.sha256` to ensure integrity of the JSON fixture.
This commit is contained in:
StellaOps Bot
2025-12-04 07:30:42 +02:00
parent 2d079d61ed
commit e1262eb916
91 changed files with 19493 additions and 187 deletions

View File

@@ -0,0 +1,38 @@
using System.Collections.Immutable;
using StellaOps.Concelier.Storage.Postgres.Repositories;
namespace StellaOps.Concelier.Storage.Postgres.Converters.Importers;
/// <summary>
/// Compares imported advisory snapshots between sources to ensure parity before cutover.
/// </summary>
public sealed class ParityRunner
{
private readonly IAdvisorySnapshotRepository _snapshots;
public ParityRunner(IAdvisorySnapshotRepository snapshots)
{
_snapshots = snapshots;
}
/// <summary>
/// Compares two feed snapshots by advisory keys; returns true when keys match exactly.
/// </summary>
public async Task<ParityResult> CompareAsync(Guid feedSnapshotA, Guid feedSnapshotB, CancellationToken cancellationToken = default)
{
var a = await _snapshots.GetByFeedSnapshotAsync(feedSnapshotA, cancellationToken).ConfigureAwait(false);
var b = await _snapshots.GetByFeedSnapshotAsync(feedSnapshotB, cancellationToken).ConfigureAwait(false);
var setA = a.Select(s => s.AdvisoryKey).ToImmutableSortedSet(StringComparer.OrdinalIgnoreCase);
var setB = b.Select(s => s.AdvisoryKey).ToImmutableSortedSet(StringComparer.OrdinalIgnoreCase);
var missingInB = setA.Except(setB).ToArray();
var missingInA = setB.Except(setA).ToArray();
var match = missingInA.Length == 0 && missingInB.Length == 0;
return new ParityResult(match, missingInA, missingInB);
}
public sealed record ParityResult(bool Match, IReadOnlyList<string> MissingInA, IReadOnlyList<string> MissingInB);
}