58 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| namespace StellaOps.Concelier.Connector.Nvd.Configuration;
 | |
| 
 | |
| public sealed class NvdOptions
 | |
| {
 | |
|     /// <summary>
 | |
|     /// Name of the HttpClient registered for NVD fetches.
 | |
|     /// </summary>
 | |
|     public const string HttpClientName = "nvd";
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Base API endpoint for CVE feed queries.
 | |
|     /// </summary>
 | |
|     public Uri BaseEndpoint { get; set; } = new("https://services.nvd.nist.gov/rest/json/cves/2.0");
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Duration of each modified window fetch.
 | |
|     /// </summary>
 | |
|     public TimeSpan WindowSize { get; set; } = TimeSpan.FromHours(4);
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Overlap added when advancing the sliding window to cover upstream delays.
 | |
|     /// </summary>
 | |
|     public TimeSpan WindowOverlap { get; set; } = TimeSpan.FromMinutes(5);
 | |
| 
 | |
|     /// <summary>
 | |
|     /// Maximum look-back period used when the connector first starts or state is empty.
 | |
|     /// </summary>
 | |
|     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.");
 | |
|         }
 | |
|     }
 | |
| }
 |