mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-04 02:04:06 +00:00
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
304 lines
8.1 KiB
TypeScript
304 lines
8.1 KiB
TypeScript
export const REGISTRY_ENDPOINT = {
|
|
PROVIDERS: "providers",
|
|
AVAILABLE_ARTIFACTS: "available_artifacts",
|
|
CREDENTIAL: "credential",
|
|
MUTATION: "mutation",
|
|
} as const;
|
|
|
|
export type RegistryEndpoint =
|
|
(typeof REGISTRY_ENDPOINT)[keyof typeof REGISTRY_ENDPOINT];
|
|
|
|
export const REGISTRY_FAILURE = {
|
|
ACCESS_DENIED: "access_denied",
|
|
ONBOARDING: "onboarding",
|
|
RECONNECT: "reconnect",
|
|
UNAVAILABLE: "unavailable",
|
|
ERROR: "error",
|
|
} as const;
|
|
|
|
export type RegistryFailureResult =
|
|
| { status: typeof REGISTRY_FAILURE.ACCESS_DENIED }
|
|
| { status: typeof REGISTRY_FAILURE.ONBOARDING }
|
|
| { status: typeof REGISTRY_FAILURE.RECONNECT }
|
|
| { status: typeof REGISTRY_FAILURE.UNAVAILABLE }
|
|
| { status: typeof REGISTRY_FAILURE.ERROR };
|
|
|
|
export const REGISTRY_SUBMISSION = {
|
|
PENDING: "pending",
|
|
ERROR: "error",
|
|
} as const;
|
|
|
|
export type RegistryTaskSubmissionResult =
|
|
| {
|
|
status: typeof REGISTRY_SUBMISSION.PENDING;
|
|
taskId: string;
|
|
}
|
|
| { status: typeof REGISTRY_SUBMISSION.ERROR };
|
|
|
|
export type RegistryCredentialSubmissionResult = RegistryTaskSubmissionResult;
|
|
|
|
export interface RegistryArtifactTaskResult {
|
|
installed: boolean;
|
|
error: string | null;
|
|
}
|
|
|
|
export interface RegistryAddArtifactInput {
|
|
normalizedName: string;
|
|
versionSpec?: string;
|
|
}
|
|
|
|
export const REGISTRY_INSTALL_OPERATION = {
|
|
ADD: "add",
|
|
UPDATE: "update",
|
|
} as const;
|
|
|
|
export type RegistryInstallOperation =
|
|
(typeof REGISTRY_INSTALL_OPERATION)[keyof typeof REGISTRY_INSTALL_OPERATION];
|
|
|
|
export type RegistryArtifactExecutionInput =
|
|
| (RegistryAddArtifactInput & {
|
|
operation?: typeof REGISTRY_INSTALL_OPERATION.ADD;
|
|
})
|
|
| {
|
|
normalizedName: string;
|
|
versionSpec: string;
|
|
operation: typeof REGISTRY_INSTALL_OPERATION.UPDATE;
|
|
};
|
|
|
|
export const REGISTRY_ARTIFACT_ACTION = {
|
|
SUBMITTED: "submitted",
|
|
} as const;
|
|
|
|
export type RegistryArtifactSubmitResult = {
|
|
status: typeof REGISTRY_ARTIFACT_ACTION.SUBMITTED;
|
|
taskId: string;
|
|
};
|
|
|
|
export interface RegistryCredentialStatus {
|
|
configured: boolean;
|
|
isValid: boolean;
|
|
scopes: string[];
|
|
lastValidatedAt?: string;
|
|
validationStatus?: string;
|
|
validationPending: boolean;
|
|
}
|
|
|
|
export const REGISTRY_CATALOG = {
|
|
COMPLETE: "complete",
|
|
INCOMPLETE: "incomplete",
|
|
} as const;
|
|
export const REGISTRY_CATALOG_INCOMPLETE_REASON = {
|
|
CONFLICTING_DUPLICATE: "conflicting_duplicate",
|
|
COUNT_MISMATCH: "count_mismatch",
|
|
GUARD_EXHAUSTED: "guard_exhausted",
|
|
INVALID_PAGE: "invalid_page",
|
|
INVALID_RESOURCE: "invalid_resource",
|
|
PAGE_FAILED: "page_failed",
|
|
} as const;
|
|
export type RegistryCatalogIncompleteReason =
|
|
(typeof REGISTRY_CATALOG_INCOMPLETE_REASON)[keyof typeof REGISTRY_CATALOG_INCOMPLETE_REASON];
|
|
|
|
export interface RegistryArtifactOwner {
|
|
name: string;
|
|
type: string;
|
|
logoUrl?: string;
|
|
}
|
|
|
|
export interface RegistryCatalogArtifact {
|
|
normalizedName: string;
|
|
name?: string;
|
|
description?: string;
|
|
latestVersion?: string;
|
|
providers: string[];
|
|
/** Provider declared by a provider artifact; distinct from its target filters. */
|
|
providerSlug?: string;
|
|
isVerified: boolean;
|
|
isOfficial: boolean;
|
|
isBuiltin: boolean;
|
|
isMeta: boolean;
|
|
hasProvider: boolean;
|
|
hasChecks: boolean;
|
|
hasCompliance: boolean;
|
|
/** The API's verdict for this deployment; never recomputed client-side. */
|
|
isInstallable: boolean;
|
|
/** Stable API code; new codes can appear without a UI release. */
|
|
notInstallableReason?: string;
|
|
checkCount?: number;
|
|
complianceCount?: number;
|
|
versionCount: number;
|
|
totalDownloads: number;
|
|
owners: RegistryArtifactOwner[];
|
|
}
|
|
|
|
export interface RegistryTenantArtifact {
|
|
normalizedName: string;
|
|
versionSpec: string;
|
|
resolvedVersion?: string;
|
|
/** Built-in providers this install adds checks to without defining them. */
|
|
extendsProviderSlugs?: string[];
|
|
insertedAt?: string;
|
|
updatedAt?: string;
|
|
}
|
|
|
|
export type RegistryCatalogResult =
|
|
| {
|
|
status: typeof REGISTRY_CATALOG.COMPLETE;
|
|
artifacts: RegistryCatalogArtifact[];
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_CATALOG.INCOMPLETE;
|
|
reason: RegistryCatalogIncompleteReason;
|
|
collectedCount: number;
|
|
};
|
|
|
|
export const REGISTRY_CREDENTIAL_READ = {
|
|
STATUS: "status",
|
|
} as const;
|
|
|
|
export type RegistryCredentialReadResult =
|
|
| {
|
|
status: typeof REGISTRY_CREDENTIAL_READ.STATUS;
|
|
credential: RegistryCredentialStatus;
|
|
}
|
|
| RegistryFailureResult;
|
|
|
|
export const REGISTRY_CREDENTIAL_ACTION = {
|
|
CONNECTED: "connected",
|
|
DISCONNECTED: "disconnected",
|
|
INVALID: "invalid",
|
|
PENDING: "pending",
|
|
REPLACEMENT_FAILED: "replacement_failed",
|
|
SUBMITTED: "submitted",
|
|
} as const;
|
|
|
|
export type RegistryCredentialSubmitResult =
|
|
| {
|
|
status: typeof REGISTRY_CREDENTIAL_ACTION.SUBMITTED;
|
|
taskId: string;
|
|
priorConfigured: boolean;
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_CREDENTIAL_ACTION.REPLACEMENT_FAILED;
|
|
credential: RegistryCredentialStatus;
|
|
}
|
|
| RegistryFailureResult;
|
|
|
|
export type RegistryCredentialActionResult =
|
|
| {
|
|
status: typeof REGISTRY_CREDENTIAL_ACTION.CONNECTED;
|
|
credential: RegistryCredentialStatus;
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_CREDENTIAL_ACTION.DISCONNECTED;
|
|
credential: RegistryCredentialStatus;
|
|
tenantArtifacts: RegistryTenantArtifact[];
|
|
}
|
|
| {
|
|
status:
|
|
| typeof REGISTRY_CREDENTIAL_ACTION.INVALID
|
|
| typeof REGISTRY_CREDENTIAL_ACTION.PENDING
|
|
| typeof REGISTRY_CREDENTIAL_ACTION.REPLACEMENT_FAILED;
|
|
credential: RegistryCredentialStatus;
|
|
}
|
|
| RegistryFailureResult;
|
|
|
|
type RegistryCompleteCatalog = Extract<
|
|
RegistryCatalogResult,
|
|
{ status: typeof REGISTRY_CATALOG.COMPLETE }
|
|
>;
|
|
type RegistryIncompleteCatalog = Exclude<
|
|
RegistryCatalogResult,
|
|
RegistryCompleteCatalog
|
|
>;
|
|
|
|
export type RegistryCollectionsResult =
|
|
| {
|
|
status: typeof REGISTRY_CATALOG.COMPLETE;
|
|
catalog: RegistryCompleteCatalog;
|
|
tenantArtifacts: RegistryTenantArtifact[];
|
|
}
|
|
| RegistryIncompleteCatalog
|
|
| RegistryFailureResult;
|
|
|
|
export const REGISTRY_MUTATION = {
|
|
CONFIRMED: "confirmed",
|
|
REFRESH_FAILED: "refresh_failed",
|
|
REFUSED: "refused",
|
|
} as const;
|
|
|
|
export type RegistryMutationResult =
|
|
| {
|
|
status: typeof REGISTRY_MUTATION.CONFIRMED;
|
|
tenantArtifacts: RegistryTenantArtifact[];
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_MUTATION.REFRESH_FAILED;
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_MUTATION.REFUSED;
|
|
message: string;
|
|
}
|
|
| RegistryArtifactSubmitResult
|
|
| RegistryFailureResult;
|
|
|
|
export const REGISTRY_ARTIFACT_REMOVAL = {
|
|
/** Providers stand on it: they must be deleted first. */
|
|
IN_USE: "in_use",
|
|
/** A scan is running its checks: it clears by itself. */
|
|
BUSY: "busy",
|
|
} as const;
|
|
|
|
export type RegistryArtifactRemovalConflict =
|
|
| { status: typeof REGISTRY_ARTIFACT_REMOVAL.IN_USE }
|
|
| { status: typeof REGISTRY_ARTIFACT_REMOVAL.BUSY };
|
|
|
|
export type RegistryArtifactRemovalResult =
|
|
| RegistryMutationResult
|
|
| RegistryArtifactRemovalConflict;
|
|
|
|
export type RegistryRemoveDialogError =
|
|
| RegistryArtifactRemovalConflict
|
|
| { status: typeof REGISTRY_FAILURE.ERROR; message: string };
|
|
|
|
export const REGISTRY_BOOTSTRAP_STATE = {
|
|
ONBOARDING: "onboarding",
|
|
VALIDATION_PENDING: "validation_pending",
|
|
READY: "ready",
|
|
RECONNECT: "reconnect",
|
|
UNAVAILABLE: "unavailable",
|
|
INCOMPLETE: "incomplete",
|
|
ERROR: "error",
|
|
} as const;
|
|
|
|
export type RegistryBootstrapState =
|
|
| {
|
|
status:
|
|
| typeof REGISTRY_BOOTSTRAP_STATE.ONBOARDING
|
|
| typeof REGISTRY_BOOTSTRAP_STATE.VALIDATION_PENDING;
|
|
credential: RegistryCredentialStatus;
|
|
tenantArtifacts: RegistryTenantArtifact[];
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_BOOTSTRAP_STATE.READY;
|
|
credential: RegistryCredentialStatus;
|
|
catalog: RegistryCompleteCatalog;
|
|
tenantArtifacts: RegistryTenantArtifact[];
|
|
}
|
|
| {
|
|
status:
|
|
| typeof REGISTRY_BOOTSTRAP_STATE.RECONNECT
|
|
| typeof REGISTRY_BOOTSTRAP_STATE.UNAVAILABLE
|
|
| typeof REGISTRY_BOOTSTRAP_STATE.ERROR;
|
|
}
|
|
| {
|
|
status: typeof REGISTRY_BOOTSTRAP_STATE.INCOMPLETE;
|
|
catalog: RegistryIncompleteCatalog;
|
|
};
|
|
|
|
export type RegistryBootstrapResult =
|
|
| {
|
|
status: typeof REGISTRY_BOOTSTRAP_STATE.READY;
|
|
state: RegistryBootstrapState;
|
|
}
|
|
| { status: typeof REGISTRY_FAILURE.ACCESS_DENIED };
|