namespace StellaOps.SbomService.Models; /// /// Type of registry source. /// public enum RegistrySourceType { /// Docker Hub registry. DockerHub = 1, /// Harbor registry. Harbor = 2, /// AWS ECR registry. Ecr = 3, /// Google Container Registry / Artifact Registry. Gcr = 4, /// Azure Container Registry. Acr = 5, /// GitHub Container Registry. Ghcr = 6, /// GitLab Container Registry. GitLabRegistry = 7, /// Quay.io registry. Quay = 8, /// JFrog Artifactory. Artifactory = 9, /// Sonatype Nexus. Nexus = 10, /// Generic OCI-compliant registry. OciGeneric = 99 } /// /// Trigger mode for registry source scanning. /// public enum RegistryTriggerMode { /// No automatic triggers; manual only. Manual = 0, /// Cron-based scheduled scanning. Schedule = 1, /// Webhook-triggered scanning. Webhook = 2, /// Both scheduled and webhook triggers. Both = 3 } /// /// Status of a registry source. /// public enum RegistrySourceStatus { /// Just created, not verified. Pending = 0, /// Verified and active. Active = 1, /// Paused by operator. Paused = 2, /// Verification failed. Failed = 3, /// Marked for deletion. Archived = 4 } /// /// Status of a registry source run. /// public enum RegistryRunStatus { /// Run is queued. Queued = 0, /// Run is in progress. Running = 1, /// Run completed successfully. Completed = 2, /// Run failed. Failed = 3, /// Run was cancelled. Cancelled = 4 } /// /// Registry source entity representing a container registry to scan. /// public sealed class RegistrySource { public required Guid Id { get; init; } /// Human-readable name for the source. public required string Name { get; set; } /// Optional description. public string? Description { get; set; } /// Type of registry. public required RegistrySourceType Type { get; init; } /// Registry base URL (e.g., https://harbor.example.com). public required string RegistryUrl { get; set; } /// AuthRef URI for credentials. public string? AuthRefUri { get; set; } /// Credential reference URI for authentication. public string? CredentialRef { get; set; } /// Linked integration ID from Integration Catalog. public Guid? IntegrationId { get; set; } /// Repository filter patterns (glob, e.g., "library/*", "myorg/**"). public List RepoFilters { get; set; } = []; /// Repository allowlist patterns (glob, e.g., "library/*"). If non-empty, only matching repos are processed. public List RepositoryAllowlist { get; set; } = []; /// Repository denylist patterns. Matching repos are skipped even if they match allowlist. public List RepositoryDenylist { get; set; } = []; /// Tag filter patterns (glob, e.g., "v*", "latest"). public List TagFilters { get; set; } = []; /// Tag allowlist patterns. If non-empty, only matching tags are processed. public List TagAllowlist { get; set; } = []; /// Tag denylist patterns. Matching tags are skipped even if they match allowlist. public List TagDenylist { get; set; } = []; /// Trigger mode for scanning. public RegistryTriggerMode TriggerMode { get; set; } = RegistryTriggerMode.Manual; /// Cron expression for scheduled scans (when TriggerMode includes Schedule). public string? ScheduleCron { get; set; } /// Webhook secret for signature verification. public string? WebhookSecretRefUri { get; set; } /// Current status. public RegistrySourceStatus Status { get; set; } = RegistrySourceStatus.Pending; /// Last successful run timestamp. public DateTimeOffset? LastRunAt { get; set; } /// Last successful run status. public RegistryRunStatus? LastRunStatus { get; set; } /// Number of images discovered in last run. public int LastDiscoveredCount { get; set; } /// Number of images scanned in last run. public int LastScannedCount { get; set; } /// Creation timestamp. public required DateTimeOffset CreatedAt { get; init; } /// Last update timestamp. public required DateTimeOffset UpdatedAt { get; set; } /// Creator user/system. public string? CreatedBy { get; init; } /// Last updater user/system. public string? UpdatedBy { get; set; } /// Tenant isolation ID. public string? TenantId { get; init; } /// Tags for filtering. public List Tags { get; set; } = []; /// Soft-delete marker. public bool IsDeleted { get; set; } } /// /// Registry source run history record. /// public sealed class RegistrySourceRun { public required Guid Id { get; init; } /// Parent source ID. public required Guid SourceId { get; init; } /// Run status. public RegistryRunStatus Status { get; set; } = RegistryRunStatus.Queued; /// Trigger type (manual, schedule, webhook). public required string TriggerType { get; init; } /// Trigger metadata (webhook payload ID, cron tick, etc.). public string? TriggerMetadata { get; set; } /// Number of repositories discovered. public int ReposDiscovered { get; set; } /// Number of images discovered. public int ImagesDiscovered { get; set; } /// Number of images scanned. public int ImagesScanned { get; set; } /// Number of scan jobs submitted. public int JobsSubmitted { get; set; } /// Number of scan jobs completed. public int JobsCompleted { get; set; } /// Number of scan jobs failed. public int JobsFailed { get; set; } /// Error message if failed. public string? ErrorMessage { get; set; } /// Run start timestamp. public required DateTimeOffset StartedAt { get; init; } /// Run completion timestamp. public DateTimeOffset? CompletedAt { get; set; } /// Duration of the run. public TimeSpan? Duration => CompletedAt.HasValue ? CompletedAt.Value - StartedAt : null; }