namespace StellaOps.Concelier.Connector.Nvd.Configuration;
public sealed class NvdOptions
{
///
/// Name of the HttpClient registered for NVD fetches.
///
public const string HttpClientName = "nvd";
///
/// Base API endpoint for CVE feed queries.
///
public Uri BaseEndpoint { get; set; } = new("https://services.nvd.nist.gov/rest/json/cves/2.0");
///
/// Duration of each modified window fetch.
///
public TimeSpan WindowSize { get; set; } = TimeSpan.FromHours(4);
///
/// Overlap added when advancing the sliding window to cover upstream delays.
///
public TimeSpan WindowOverlap { get; set; } = TimeSpan.FromMinutes(5);
///
/// Maximum look-back period used when the connector first starts or state is empty.
///
public TimeSpan InitialBackfill { get; set; } = TimeSpan.FromDays(7);
public void Validate()
{
if (BaseEndpoint is null)
{
throw new InvalidOperationException("NVD base endpoint must be configured.");
}
if (!BaseEndpoint.IsAbsoluteUri)
{
throw new InvalidOperationException("NVD base endpoint must be an absolute URI.");
}
if (WindowSize <= TimeSpan.Zero)
{
throw new InvalidOperationException("Window size must be positive.");
}
if (WindowOverlap < TimeSpan.Zero || WindowOverlap >= WindowSize)
{
throw new InvalidOperationException("Window overlap must be non-negative and less than the window size.");
}
if (InitialBackfill <= TimeSpan.Zero)
{
throw new InvalidOperationException("Initial backfill duration must be positive.");
}
}
}