using System; using System.Collections.Generic; namespace StellaOps.Scanner.WebService.Options; /// /// Strongly typed configuration for the Scanner WebService host. /// public sealed class ScannerWebServiceOptions { public const string SectionName = "scanner"; /// /// Schema version for configuration consumers to coordinate breaking changes. /// public int SchemaVersion { get; set; } = 1; /// /// Mongo storage configuration used for catalog and job state. /// public StorageOptions Storage { get; set; } = new(); /// /// Queue configuration used to enqueue scan jobs. /// public QueueOptions Queue { get; set; } = new(); /// /// Object store configuration for SBOM artefacts. /// public ArtifactStoreOptions ArtifactStore { get; set; } = new(); /// /// Feature flags toggling optional behaviours. /// public FeatureFlagOptions Features { get; set; } = new(); /// /// Plug-in loader configuration. /// public PluginOptions Plugins { get; set; } = new(); /// /// Telemetry configuration for logs, metrics, traces. /// public TelemetryOptions Telemetry { get; set; } = new(); /// /// Authority / authentication configuration. /// public AuthorityOptions Authority { get; set; } = new(); /// /// Signing configuration for report envelopes and attestations. /// public SigningOptions Signing { get; set; } = new(); /// /// API-specific settings such as base path. /// public ApiOptions Api { get; set; } = new(); /// /// Platform event emission settings. /// public EventsOptions Events { get; set; } = new(); /// /// Runtime ingestion configuration. /// public RuntimeOptions Runtime { get; set; } = new(); public sealed class StorageOptions { public string Driver { get; set; } = "mongo"; public string Dsn { get; set; } = string.Empty; public string? Database { get; set; } public int CommandTimeoutSeconds { get; set; } = 30; public int HealthCheckTimeoutSeconds { get; set; } = 5; public IList Migrations { get; set; } = new List(); } public sealed class QueueOptions { public string Driver { get; set; } = "redis"; public string Dsn { get; set; } = string.Empty; public string Namespace { get; set; } = "scanner"; public int VisibilityTimeoutSeconds { get; set; } = 300; public int LeaseHeartbeatSeconds { get; set; } = 30; public int MaxDeliveryAttempts { get; set; } = 5; public IDictionary DriverSettings { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class ArtifactStoreOptions { public string Driver { get; set; } = "rustfs"; public string Endpoint { get; set; } = string.Empty; public bool UseTls { get; set; } = true; public bool AllowInsecureTls { get; set; } = false; public int TimeoutSeconds { get; set; } = 60; public string AccessKey { get; set; } = string.Empty; public string SecretKey { get; set; } = string.Empty; public string? SecretKeyFile { get; set; } public string Bucket { get; set; } = "scanner-artifacts"; public string? Region { get; set; } public bool EnableObjectLock { get; set; } = true; public int ObjectLockRetentionDays { get; set; } = 30; public string? ApiKey { get; set; } public string ApiKeyHeader { get; set; } = string.Empty; public IDictionary Headers { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class FeatureFlagOptions { public bool AllowAnonymousScanSubmission { get; set; } public bool EnableSignedReports { get; set; } = true; public bool EnablePolicyPreview { get; set; } = true; public IDictionary Experimental { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class PluginOptions { public string? BaseDirectory { get; set; } public string? Directory { get; set; } public IList SearchPatterns { get; set; } = new List(); public IList OrderedPlugins { get; set; } = new List(); } public sealed class TelemetryOptions { public bool Enabled { get; set; } = true; public bool EnableTracing { get; set; } = true; public bool EnableMetrics { get; set; } = true; public bool EnableLogging { get; set; } = true; public bool EnableRequestLogging { get; set; } = true; public string MinimumLogLevel { get; set; } = "Information"; public string? ServiceName { get; set; } public string? OtlpEndpoint { get; set; } public IDictionary OtlpHeaders { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); public IDictionary ResourceAttributes { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class AuthorityOptions { public bool Enabled { get; set; } public bool AllowAnonymousFallback { get; set; } = true; public string Issuer { get; set; } = string.Empty; public string? MetadataAddress { get; set; } public bool RequireHttpsMetadata { get; set; } = true; public int BackchannelTimeoutSeconds { get; set; } = 30; public int TokenClockSkewSeconds { get; set; } = 60; public IList Audiences { get; set; } = new List(); public IList RequiredScopes { get; set; } = new List(); public IList BypassNetworks { get; set; } = new List(); public string? ClientId { get; set; } public string? ClientSecret { get; set; } public string? ClientSecretFile { get; set; } public IList ClientScopes { get; set; } = new List(); public ResilienceOptions Resilience { get; set; } = new(); public sealed class ResilienceOptions { public bool? EnableRetries { get; set; } public IList RetryDelays { get; set; } = new List(); public bool? AllowOfflineCacheFallback { get; set; } public TimeSpan? OfflineCacheTolerance { get; set; } } } public sealed class SigningOptions { public bool Enabled { get; set; } = false; public string KeyId { get; set; } = string.Empty; public string Algorithm { get; set; } = "ed25519"; public string? Provider { get; set; } public string? KeyPem { get; set; } public string? KeyPemFile { get; set; } public string? CertificatePem { get; set; } public string? CertificatePemFile { get; set; } public string? CertificateChainPem { get; set; } public string? CertificateChainPemFile { get; set; } public int EnvelopeTtlSeconds { get; set; } = 600; } public sealed class ApiOptions { public string BasePath { get; set; } = "/api/v1"; public string ScansSegment { get; set; } = "scans"; public string ReportsSegment { get; set; } = "reports"; public string PolicySegment { get; set; } = "policy"; public string RuntimeSegment { get; set; } = "runtime"; } public sealed class EventsOptions { public bool Enabled { get; set; } public string Driver { get; set; } = "redis"; public string Dsn { get; set; } = string.Empty; public string Stream { get; set; } = "stella.events"; public double PublishTimeoutSeconds { get; set; } = 5; public long MaxStreamLength { get; set; } = 10000; public IDictionary DriverSettings { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); } public sealed class RuntimeOptions { public int MaxBatchSize { get; set; } = 256; public int MaxPayloadBytes { get; set; } = 1 * 1024 * 1024; public int EventTtlDays { get; set; } = 45; public double PerNodeEventsPerSecond { get; set; } = 50; public int PerNodeBurst { get; set; } = 200; public double PerTenantEventsPerSecond { get; set; } = 200; public int PerTenantBurst { get; set; } = 1000; public int PolicyCacheTtlSeconds { get; set; } = 300; } }