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