Documentation
¶
Index ¶
- Constants
- func RepositoryToResponse(r *models.Repository) responses.RepositoryResponse
- func ValidateAIArtifactIdentity(format, name, version string) string
- type AIHandler
- type AIStore
- type AdminAIHandler
- type AdminAIStore
- type AdminAuditHandler
- type AdminAuditStore
- type AdminDeclarativeHandler
- type AdminDeclarativeStore
- type AdminGPGHandler
- type AdminGPGStore
- type AdminGroupsHandler
- type AdminGroupsStore
- type AdminOIDCPoliciesHandler
- type AdminOIDCPoliciesStore
- type AdminPermissionsHandler
- type AdminPermissionsStore
- type AdminRecoveryHandler
- type AdminReplicationHandler
- type AdminSSOHandler
- type AdminSSOStore
- type AdminServiceAccountsHandler
- type AdminServiceAccountsStore
- type AdminStorageHandler
- type AdminStorageStore
- type AdminTieringHandler
- type AdminTokensHandler
- type AdminTokensStore
- type AdminUsersHandler
- type AdminUsersStore
- type ApkKeyHandler
- type AttestationAttachHandler
- type AttestationAttachStore
- type AttestationAttacher
- func (a *AttestationAttacher) AttachSBOM(ctx context.Context, repo *models.Repository, report *models.SBOMReport, ...) (*responses.AttestationAttachResponse, error)
- func (a *AttestationAttacher) AttachVEX(ctx context.Context, repo *models.Repository, artifactID, format string) (*responses.AttestationAttachResponse, error)
- func (a *AttestationAttacher) Enabled(ctx context.Context, repo *models.Repository) bool
- func (a *AttestationAttacher) OnSBOMGenerated(ctx context.Context, repo *models.Repository, report *models.SBOMReport, ...)
- func (a *AttestationAttacher) OnScan(ctx context.Context, repoID, artifactID string)
- type AttestationAttacherStore
- type AttestationHandler
- type AuthHandler
- type AuthStore
- type BackupHandler
- type BackupStore
- type BrandingHandler
- type BundleKeyResolver
- type BundlesHandler
- func (h *BundlesHandler) RegisterAuthed(r chi.Router)
- func (h *BundlesHandler) WithBundleSigners(entries []string) *BundlesHandler
- func (h *BundlesHandler) WithGPGKeys(keys BundleKeyResolver) *BundlesHandler
- func (h *BundlesHandler) WithPublisher(p webhook.Publisher) *BundlesHandler
- func (h *BundlesHandler) WithWorkers(w *lifecycle.Workers) *BundlesHandler
- type BundlesStore
- type CleanupHandler
- type CleanupRunner
- type CleanupStore
- type CompletePresignedUploadResponse
- type CreatePresignedUploadRequest
- type CreatePresignedUploadResponse
- type CurationHandler
- type CurationStore
- type DTrackPusher
- type DTrackSources
- type DTrackSourcesStore
- type DebUploadHandler
- type DebUploadStore
- type DeltaHandler
- type DeltaStore
- type DependencyTrackHandler
- type DependencyTrackStore
- type DockerGCHandler
- type DockerGCHandlerStore
- type DockerGCRunner
- type ErrorResponse
- type FederationDeferredResponse
- type FederationHandler
- type FederationHandlerStore
- type FederationPeerResponse
- type FederationStatusResponse
- type FederationTokenCreatedResponse
- type FederationTokenResponse
- type FrontendTelemetryHandler
- type GroupMetadataNotifier
- type HTTPServer
- func (s *HTTPServer) AddMiddleware(middleware func(http.Handler) http.Handler)
- func (s *HTTPServer) DisableKeepAlives()
- func (s *HTTPServer) EnableTLS(certFile, keyFile string)
- func (s *HTTPServer) GetRouter() chi.Router
- func (s *HTTPServer) ServeErrors() <-chan error
- func (s *HTTPServer) SetConnLimits(idleTimeout time.Duration, maxHeaderBytes int)
- func (s *HTTPServer) SetTimeouts(readTimeout, writeTimeout, readHeaderTimeout time.Duration)
- func (s *HTTPServer) Start(ctx context.Context) error
- func (s *HTTPServer) Stop(ctx context.Context) error
- type LicenseHandler
- type LicenseStore
- type MavenUploadHandler
- type MavenUploadStore
- type NPMUploadHandler
- func (h *NPMUploadHandler) HandlePublish(w http.ResponseWriter, r *http.Request)
- func (h *NPMUploadHandler) Register(router chi.Router)
- func (h *NPMUploadHandler) RegisterRepoRoutes(r chi.Router)
- func (h *NPMUploadHandler) SetNPMWorker(w *worker.NPMMetadataWorker)
- func (h *NPMUploadHandler) SetPublisher(p webhook.Publisher)
- type NPMUploadStore
- type NixKeyHandler
- type OIDCExchangeHandler
- type OIDCExchangeStore
- type OIDCHandler
- type OIDCStore
- type OpenAPIHandler
- type PackageDeleter
- type PresignedPart
- type PresignedPartsRequest
- type PresignedPartsResponse
- type PresignedUploadHandler
- type PresignedUploadStore
- type ProjectCleanupPreviewer
- type ProjectsHandler
- type ProjectsStore
- type PropertiesHandler
- type PublishTimeSource
- type QuotasHandler
- type QuotasStore
- type RPMUploadHandler
- func (h *RPMUploadHandler) Register(router chi.Router)
- func (h *RPMUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
- func (h *RPMUploadHandler) SetKeyResolver(r gpg.Resolver)
- func (h *RPMUploadHandler) SetPackageDeleter(d PackageDeleter)
- func (h *RPMUploadHandler) SetPublisher(p webhook.Publisher)
- func (h *RPMUploadHandler) SetRPMWorker(w *worker.RPMetadataWorker)
- type RPMUploadStore
- type RecoveryStatusSource
- type ReferrerRegistry
- type ReplicationService
- type RepositoriesHandler
- func (h *RepositoriesHandler) RegisterAuthed(r chi.Router)
- func (h *RepositoriesHandler) WithBlobStore(store storage.BlobStore) *RepositoriesHandler
- func (h *RepositoriesHandler) WithFederation(store *federation.Store) *RepositoriesHandler
- func (h *RepositoriesHandler) WithGroupMetadata(n GroupMetadataNotifier) *RepositoriesHandler
- func (h *RepositoriesHandler) WithPublisher(p webhook.Publisher) *RepositoriesHandler
- func (h *RepositoriesHandler) WithTasks(tasks *bgtask.Runner) *RepositoriesHandler
- type RepositoriesStore
- type RepositoryActivityHandler
- type RepositoryActivityStore
- type Response
- type SAMLHandler
- type SAMLStore
- type SBOMHandler
- type SBOMStore
- type SecretsHandler
- type SecretsStore
- type SecurityHandler
- type SecurityStore
- type SelfTokensHandler
- type SelfTokensStore
- type SystemInfoHandler
- func (h *SystemInfoHandler) RegisterAuthed(r chi.Router)
- func (h *SystemInfoHandler) RegisterPublic(r chi.Router)
- func (h *SystemInfoHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request)
- func (h *SystemInfoHandler) WithAIAvailable(built bool) *SystemInfoHandler
- func (h *SystemInfoHandler) WithAPIReference(enabled bool) *SystemInfoHandler
- func (h *SystemInfoHandler) WithDocsBaseURL(base string) *SystemInfoHandler
- type SystemInfoStore
- type TierPlanner
- type TierRegistry
- type TierRunner
- type TieringAdminDB
- type TrashHandler
- func (h *TrashHandler) RegisterAuthed(r chi.Router)
- func (h *TrashHandler) WithBlobStore(store storage.BlobStore) *TrashHandler
- func (h *TrashHandler) WithGroupMetadata(n GroupMetadataNotifier) *TrashHandler
- func (h *TrashHandler) WithPublisher(p webhook.Publisher) *TrashHandler
- func (h *TrashHandler) WithTasks(tasks *bgtask.Runner) *TrashHandler
- func (h *TrashHandler) WithWorkers(ws *lifecycle.Workers) *TrashHandler
- type TrashOps
- type VEXHandler
- type VEXStore
- type VulnHandler
- func (h *VulnHandler) ForwardScansTo(s *workq.Store) *VulnHandler
- func (h *VulnHandler) RegisterOverviewRoutes(authedRouter chi.Router)
- func (h *VulnHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)
- func (h *VulnHandler) ServeScansFrom(c *workq.Consumer)
- func (h *VulnHandler) WithExploit(e *exploit.Enricher) *VulnHandler
- func (h *VulnHandler) WithOSVMirror(cfg config.OSVMirrorConfig) *VulnHandler
- func (h *VulnHandler) WithScanHook(f func(repoID, artifactID string)) *VulnHandler
- func (h *VulnHandler) WithTasks(tasks *bgtask.Runner) *VulnHandler
- type VulnStore
- type WebhooksHandler
- type WebhooksStore
Constants ¶
const AttestationKeyPath = "/.well-known/openartifact/attestation-key.pem"
AttestationKeyPath is where the public key verifying the attestations is served, unauthenticated.
const MaxMavenUploadBytes int64 = 1 << 30 // 1 GiB
const MaxNPMUploadBytes int64 = 200 << 20
const VulnScanRequestKind = "vuln:scan"
VulnScanRequestKind is the kind of the worker request that asks for a scan.
Variables ¶
This section is empty.
Functions ¶
func RepositoryToResponse ¶ added in v0.3.0
func RepositoryToResponse(r *models.Repository) responses.RepositoryResponse
RepositoryToResponse converts a repository to its public API shape. It never includes upstream credentials; the MCP server reuses it.
func ValidateAIArtifactIdentity ¶ added in v0.6.0
ValidateAIArtifactIdentity checks the artifact_format, artifact_name and artifact_version a caller supplies when triggering an analysis (REST and MCP share it) and returns a message for the first problem, "" when acceptable. The format is one of the repository formats, which are also the ids package listings report. It is compiled into every build because the MCP server validates with it even when the AI handlers are left out (-tags noai).
Types ¶
type AIHandler ¶
type AIHandler struct {
// contains filtered or unexported fields
}
AIHandler handles AI analysis REST endpoints.
func NewAIHandler ¶
func NewAIHandler(db AIStore, log *logger.Logger, evaluator *auth.Evaluator, aiWorker *worker.AIAnalysisWorker) *AIHandler
NewAIHandler creates a new AI analysis handler.
type AIStore ¶ added in v0.15.0
type AIStore interface {
GetAIAnalysis(ctx context.Context, repoID string, artifactID string) (*models.AIAnalysis, error)
GetRepoComponentBlob(ctx context.Context, repoID string, id string) (*models.ComponentBlob, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListAIAnalyses(
ctx context.Context,
repoID string,
status string,
licenseReviewOnly bool,
limit int,
offset int,
) ([]*models.AIAnalysis, int, error)
}
AIStore is the part of the database AIHandler needs.
type AdminAIHandler ¶
type AdminAIHandler struct {
// contains filtered or unexported fields
}
func NewAdminAIHandler ¶
func NewAdminAIHandler(db AdminAIStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminAIHandler
func (*AdminAIHandler) Register ¶
func (h *AdminAIHandler) Register(r chi.Router)
func (*AdminAIHandler) WithRuntime ¶ added in v0.6.0
func (h *AdminAIHandler) WithRuntime(w *worker.AIAnalysisWorker, env ai.Settings) *AdminAIHandler
WithRuntime makes configuration changes take effect immediately in this process: after every saved change the worker's client and auto-analysis switch are rebuilt from the stored settings layered over env (the env/YAML defaults). The other processes follow by polling (worker.SyncSettings).
type AdminAIStore ¶ added in v0.15.0
type AdminAIStore interface {
GetSystemSetting(ctx context.Context, key string) (string, error)
SetSystemSetting(ctx context.Context, key string, value string) error
}
AdminAIStore is the part of the database AdminAIHandler needs.
type AdminAuditHandler ¶
type AdminAuditHandler struct {
// contains filtered or unexported fields
}
func NewAdminAuditHandler ¶
func NewAdminAuditHandler(db AdminAuditStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminAuditHandler
func (*AdminAuditHandler) Register ¶
func (h *AdminAuditHandler) Register(r chi.Router)
type AdminAuditStore ¶ added in v0.15.0
type AdminAuditStore interface {
// contains filtered or unexported methods
}
AdminAuditStore is the part of the database AdminAuditHandler needs.
type AdminDeclarativeHandler ¶ added in v0.8.1
type AdminDeclarativeHandler struct {
// contains filtered or unexported fields
}
AdminDeclarativeHandler stores the ownership markers of `oa apply`: which objects it created or adopted, so --prune only deletes managed objects.
Markers are deliberately not part of backups: a restored instance has none, so prune touches nothing until the next apply re-adopts the objects.
func NewAdminDeclarativeHandler ¶ added in v0.8.1
func NewAdminDeclarativeHandler(db AdminDeclarativeStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminDeclarativeHandler
func (*AdminDeclarativeHandler) Register ¶ added in v0.8.1
func (h *AdminDeclarativeHandler) Register(r chi.Router)
type AdminDeclarativeStore ¶ added in v0.15.0
type AdminDeclarativeStore interface {
DeleteDeclarativeObject(ctx context.Context, kind string, name string) (bool, error)
ListDeclarativeObjects(ctx context.Context) ([]models.DeclarativeObject, error)
UpsertDeclarativeObjects(ctx context.Context, items []models.DeclarativeObject) ([]models.DeclarativeObject, error)
}
AdminDeclarativeStore is the part of the database AdminDeclarativeHandler needs.
type AdminGPGHandler ¶
type AdminGPGHandler struct {
// contains filtered or unexported fields
}
AdminGPGHandler manages the GPG keys that sign deb/rpm metadata and sealed release bundles (docs/security/signing.md). Every route needs an admin.
func NewAdminGPGHandler ¶
func NewAdminGPGHandler(db AdminGPGStore, log *logger.Logger, evaluator *auth.Evaluator, keys *gpgkeys.Service) *AdminGPGHandler
func (*AdminGPGHandler) Register ¶
func (h *AdminGPGHandler) Register(r chi.Router)
type AdminGPGStore ¶ added in v0.15.0
type AdminGPGStore interface {
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
}
AdminGPGStore is the part of the database AdminGPGHandler needs.
type AdminGroupsHandler ¶
type AdminGroupsHandler struct {
// contains filtered or unexported fields
}
func NewAdminGroupsHandler ¶
func NewAdminGroupsHandler(db AdminGroupsStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminGroupsHandler
func (*AdminGroupsHandler) Register ¶
func (h *AdminGroupsHandler) Register(r chi.Router)
type AdminGroupsStore ¶ added in v0.15.0
type AdminGroupsStore interface {
AddUserToGroup(ctx context.Context, userID string, groupID string) error
CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)
DeleteGroup(ctx context.Context, id string) error
GetGroupByID(ctx context.Context, id string) (*models.Group, error)
ListGroups(ctx context.Context) ([]*models.Group, error)
ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)
ListUsersByGroup(ctx context.Context, groupID string) ([]*models.User, error)
RemoveUserFromGroup(ctx context.Context, userID string, groupID string) error
SetGroupMembers(ctx context.Context, groupID string, userIDs []string) error
UpdateGroup(ctx context.Context, group *models.Group) error
}
AdminGroupsStore is the part of the database AdminGroupsHandler needs.
type AdminOIDCPoliciesHandler ¶ added in v0.16.0
type AdminOIDCPoliciesHandler struct {
// contains filtered or unexported fields
}
AdminOIDCPoliciesHandler manages the CI OIDC trust policies that POST /api/v1/auth/oidc/exchange evaluates.
func NewAdminOIDCPoliciesHandler ¶ added in v0.16.0
func NewAdminOIDCPoliciesHandler(db AdminOIDCPoliciesStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminOIDCPoliciesHandler
func (*AdminOIDCPoliciesHandler) Register ¶ added in v0.16.0
func (h *AdminOIDCPoliciesHandler) Register(r chi.Router)
type AdminOIDCPoliciesStore ¶ added in v0.16.0
type AdminOIDCPoliciesStore interface {
CreateOIDCPolicy(ctx context.Context, p *models.OIDCTrustPolicy) (*models.OIDCTrustPolicy, error)
GetOIDCPolicy(ctx context.Context, id string) (*models.OIDCTrustPolicy, error)
ListOIDCPolicies(ctx context.Context) ([]*models.OIDCTrustPolicy, error)
UpdateOIDCPolicy(ctx context.Context, p *models.OIDCTrustPolicy) (*models.OIDCTrustPolicy, error)
DeleteOIDCPolicy(ctx context.Context, id string) (bool, error)
GetServiceAccount(ctx context.Context, id string) (*models.User, error)
}
AdminOIDCPoliciesStore is the part of the database AdminOIDCPoliciesHandler needs.
type AdminPermissionsHandler ¶
type AdminPermissionsHandler struct {
// contains filtered or unexported fields
}
func NewAdminPermissionsHandler ¶
func NewAdminPermissionsHandler(db AdminPermissionsStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminPermissionsHandler
func (*AdminPermissionsHandler) Register ¶
func (h *AdminPermissionsHandler) Register(r chi.Router)
type AdminPermissionsStore ¶ added in v0.15.0
type AdminPermissionsStore interface {
CreatePermissionAssignment(ctx context.Context, assignment *models.PermissionAssignment) error
CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)
DeletePermissionAssignment(ctx context.Context, targetID string, principalType string, principalID string) error
DeletePermissionTarget(ctx context.Context, id string) error
GetGroupByID(ctx context.Context, id string) (*models.Group, error)
GetPermissionTargetByID(ctx context.Context, id string) (*models.PermissionTarget, error)
GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
GetUserByID(ctx context.Context, id string) (*models.User, error)
ListPermissionAssignmentsForTarget(ctx context.Context, targetID string) ([]models.PermissionAssignmentView, error)
ListPermissionTargets(ctx context.Context) ([]*models.PermissionTarget, error)
UpdatePermissionTarget(ctx context.Context, target *models.PermissionTarget) error
}
AdminPermissionsStore is the part of the database AdminPermissionsHandler needs.
type AdminRecoveryHandler ¶ added in v0.9.0
type AdminRecoveryHandler struct {
// contains filtered or unexported fields
}
AdminRecoveryHandler serves /api/v1/admin/recovery: the state of the row journal that makes `openartifact rebuild` possible.
func NewAdminRecoveryHandler ¶ added in v0.9.0
func NewAdminRecoveryHandler(src RecoveryStatusSource, log *logger.Logger, evaluator *auth.Evaluator) *AdminRecoveryHandler
NewAdminRecoveryHandler creates the handler.
func (*AdminRecoveryHandler) Register ¶ added in v0.9.0
func (h *AdminRecoveryHandler) Register(r chi.Router)
Register mounts the routes.
type AdminReplicationHandler ¶ added in v0.9.0
type AdminReplicationHandler struct {
// contains filtered or unexported fields
}
AdminReplicationHandler serves the replication status and verify endpoints.
func NewAdminReplicationHandler ¶ added in v0.9.0
func NewAdminReplicationHandler(svc ReplicationService, log *logger.Logger, evaluator *auth.Evaluator) *AdminReplicationHandler
NewAdminReplicationHandler creates the handler. svc is nil when no replica is configured: the status endpoint then reports enabled=false.
func (*AdminReplicationHandler) Register ¶ added in v0.9.0
func (h *AdminReplicationHandler) Register(r chi.Router)
Register mounts the routes. They are static paths, so they win over the parameterized /api/v1/admin/storage/{name}: a record that was named "replication" before the name was reserved is listed, but reads and tests of it reach these endpoints instead (see reservedStorageBackendName).
type AdminSSOHandler ¶
type AdminSSOHandler struct {
// contains filtered or unexported fields
}
func NewAdminSSOHandler ¶
func NewAdminSSOHandler( db AdminSSOStore, log *logger.Logger, evaluator *auth.Evaluator, baseURL string, cfg *config.Config, ) *AdminSSOHandler
func (*AdminSSOHandler) RegisterAuthed ¶
func (h *AdminSSOHandler) RegisterAuthed(authed chi.Router)
func (*AdminSSOHandler) RegisterPublic ¶
func (h *AdminSSOHandler) RegisterPublic(r chi.Router)
type AdminSSOStore ¶ added in v0.15.0
type AdminSSOStore interface {
CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
CreateSystemSettingIfAbsent(ctx context.Context, key string, value string) (bool, error)
DeleteSSOProvider(ctx context.Context, id string) error
GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)
GetSystemSetting(ctx context.Context, key string) (string, error)
ListAllSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
ListEnabledSSOProviders(ctx context.Context) ([]*models.SSOProvider, error)
UpdateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
}
AdminSSOStore is the part of the database AdminSSOHandler needs.
type AdminServiceAccountsHandler ¶ added in v0.16.0
type AdminServiceAccountsHandler struct {
// contains filtered or unexported fields
}
AdminServiceAccountsHandler manages service accounts: named non-human principals for automation. They hold project roles, group memberships and permission assignments like users do and own API tokens (through the /api/v1/users/{id}/tokens routes), but cannot sign in.
func NewAdminServiceAccountsHandler ¶ added in v0.16.0
func NewAdminServiceAccountsHandler( db AdminServiceAccountsStore, log *logger.Logger, evaluator *auth.Evaluator, ) *AdminServiceAccountsHandler
func (*AdminServiceAccountsHandler) Register ¶ added in v0.16.0
func (h *AdminServiceAccountsHandler) Register(r chi.Router)
type AdminServiceAccountsStore ¶ added in v0.16.0
type AdminServiceAccountsStore interface {
CreateServiceAccount(ctx context.Context, name string, description *string, disabled bool) (*models.User, error)
GetServiceAccount(ctx context.Context, id string) (*models.User, error)
ListServiceAccounts(ctx context.Context, page, perPage int) ([]*models.User, int, error)
UpdateServiceAccount(ctx context.Context, id string, description *string, disabled *bool) (*models.User, error)
DeleteServiceAccount(ctx context.Context, id string) (bool, error)
}
AdminServiceAccountsStore is the part of the database AdminServiceAccountsHandler needs.
type AdminStorageHandler ¶
type AdminStorageHandler struct {
// contains filtered or unexported fields
}
func NewAdminStorageHandler ¶
func NewAdminStorageHandler(db AdminStorageStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminStorageHandler
func (*AdminStorageHandler) Register ¶
func (h *AdminStorageHandler) Register(r chi.Router)
func (*AdminStorageHandler) WithPrimary ¶ added in v0.13.0
func (h *AdminStorageHandler) WithPrimary(cfg storage.StorageConfig, store storage.BlobStore) *AdminStorageHandler
WithPrimary makes the configured primary store (cfg, opened as store) show up in the storage admin API. Only the non-secret location is ever exposed.
type AdminStorageStore ¶ added in v0.15.0
type AdminStorageStore interface {
CountBlobsOnStorageBackend(ctx context.Context, backendID string) (int64, error)
CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
DeleteStorageBackend(ctx context.Context, id string) error
GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)
ListStorageBackends(ctx context.Context) ([]*models.StorageBackend, error)
StorageBackendBusyReason(ctx context.Context, backendID string) (string, error)
StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
UpdateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
UpdateStorageBackendStatus(ctx context.Context, id string, status string, message *string) error
}
AdminStorageStore is the part of the database AdminStorageHandler needs.
type AdminTieringHandler ¶ added in v0.7.0
type AdminTieringHandler struct {
// contains filtered or unexported fields
}
AdminTieringHandler serves /api/v1/admin/tiering: tiers, lifecycle policies, dry runs and the mover status.
func NewAdminTieringHandler ¶ added in v0.7.0
func NewAdminTieringHandler( db TieringAdminDB, reg TierRegistry, planner TierPlanner, runner TierRunner, log *logger.Logger, evaluator *auth.Evaluator, ) *AdminTieringHandler
NewAdminTieringHandler creates the handler.
func (*AdminTieringHandler) Register ¶ added in v0.7.0
func (h *AdminTieringHandler) Register(r chi.Router)
Register mounts the routes.
type AdminTokensHandler ¶
type AdminTokensHandler struct {
// contains filtered or unexported fields
}
func NewAdminTokensHandler ¶
func NewAdminTokensHandler(db AdminTokensStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminTokensHandler
func (*AdminTokensHandler) Register ¶
func (h *AdminTokensHandler) Register(r chi.Router)
type AdminTokensStore ¶ added in v0.15.0
type AdminTokensStore interface {
GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)
GetUserByID(ctx context.Context, id string) (*models.User, error)
ListAllTokens(ctx context.Context, page int, perPage int) ([]*models.Token, int, error)
ListProjectGrantsByUser(ctx context.Context, userID string) ([]*models.ProjectGrant, error)
ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)
ListUnifiedTokens(ctx context.Context, params models.TokenListParams) ([]*models.TokenListItem, int, error)
RevokeToken(ctx context.Context, tokenID string) error
// contains filtered or unexported methods
}
AdminTokensStore is the part of the database AdminTokensHandler needs.
type AdminUsersHandler ¶
type AdminUsersHandler struct {
// contains filtered or unexported fields
}
func NewAdminUsersHandler ¶
func NewAdminUsersHandler(db AdminUsersStore, log *logger.Logger, evaluator *auth.Evaluator) *AdminUsersHandler
func (*AdminUsersHandler) Register ¶
func (h *AdminUsersHandler) Register(r chi.Router)
type AdminUsersStore ¶ added in v0.15.0
type AdminUsersStore interface {
CreateUser(ctx context.Context, user *models.User) (*models.User, error)
DeleteSessionsByUser(ctx context.Context, userID string) error
DeleteUser(ctx context.Context, id string) (bool, error)
GetUserByID(ctx context.Context, id string) (*models.User, error)
ListUsers(ctx context.Context, page int, perPage int) ([]*models.User, int, error)
UpdateUser(ctx context.Context, user *models.User) error
}
AdminUsersStore is the part of the database AdminUsersHandler needs.
type ApkKeyHandler ¶ added in v0.13.0
type ApkKeyHandler struct {
// contains filtered or unexported fields
}
ApkKeyHandler manages the RSA key that signs the APKINDEX of an apk repository (docs/formats/apk.md). Every route needs an admin.
func NewApkKeyHandler ¶ added in v0.13.0
func NewApkKeyHandler(db signingKeyAdminStore, log *logger.Logger, evaluator *auth.Evaluator, keys *apkkeys.Service) *ApkKeyHandler
NewApkKeyHandler builds the handler.
func (*ApkKeyHandler) Register ¶ added in v0.13.0
func (h *ApkKeyHandler) Register(r chi.Router)
Register registers the routes on the authenticated REST router.
type AttestationAttachHandler ¶ added in v0.8.0
type AttestationAttachHandler struct {
// contains filtered or unexported fields
}
AttestationAttachHandler serves the attach endpoints and the per-repository switch.
func NewAttestationAttachHandler ¶ added in v0.8.0
func NewAttestationAttachHandler( db AttestationAttachStore, log *logger.Logger, evaluator *auth.Evaluator, attacher *AttestationAttacher, blobs storage.BlobStore, ) *AttestationAttachHandler
NewAttestationAttachHandler builds the handler.
func (*AttestationAttachHandler) RegisterAuthed ¶ added in v0.8.0
func (h *AttestationAttachHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin routes.
type AttestationAttachStore ¶ added in v0.15.0
type AttestationAttachStore interface {
GetRepositoryAttestationAttach(ctx context.Context, repoID string) (bool, error)
GetSBOMReportByID(ctx context.Context, repoID string, id string) (*models.SBOMReport, error)
SetRepositoryAttestationAttach(ctx context.Context, repoID string, enabled bool) error
// contains filtered or unexported methods
}
AttestationAttachStore is the part of the database AttestationAttachHandler needs.
type AttestationAttacher ¶ added in v0.8.0
type AttestationAttacher struct {
// contains filtered or unexported fields
}
AttestationAttacher signs SBOMs and VEX documents and attaches them to the image they describe as OCI referrers, so `cosign verify-attestation`, `cosign tree` and `oras discover` find them next to the image.
func NewAttestationAttacher ¶ added in v0.8.0
func NewAttestationAttacher( db AttestationAttacherStore, log *logger.Logger, gen *sbom.Generator, svc *attest.Service, reg ReferrerRegistry, ) *AttestationAttacher
NewAttestationAttacher builds the attacher.
func (*AttestationAttacher) AttachSBOM ¶ added in v0.8.0
func (a *AttestationAttacher) AttachSBOM( ctx context.Context, repo *models.Repository, report *models.SBOMReport, doc []byte, ) (*responses.AttestationAttachResponse, error)
AttachSBOM attaches the stored SBOM report's document (JSON formats only).
func (*AttestationAttacher) AttachVEX ¶ added in v0.8.0
func (a *AttestationAttacher) AttachVEX( ctx context.Context, repo *models.Repository, artifactID, format string, ) (*responses.AttestationAttachResponse, error)
AttachVEX builds the VEX document of one artifact and attaches it.
func (*AttestationAttacher) Enabled ¶ added in v0.8.0
func (a *AttestationAttacher) Enabled(ctx context.Context, repo *models.Repository) bool
Enabled reports whether the repository attaches attestations automatically.
func (*AttestationAttacher) OnSBOMGenerated ¶ added in v0.8.0
func (a *AttestationAttacher) OnSBOMGenerated(ctx context.Context, repo *models.Repository, report *models.SBOMReport, doc []byte)
OnSBOMGenerated attaches a freshly generated SBOM when the repository opted in.
type AttestationAttacherStore ¶ added in v0.15.0
type AttestationAttacherStore interface {
GetDockerTag(ctx context.Context, repoID string, image string, name string) (*models.DockerTag, error)
GetRepositoryAttestationAttach(ctx context.Context, repoID string) (bool, error)
GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
// contains filtered or unexported methods
}
AttestationAttacherStore is the part of the database AttestationAttacher needs.
type AttestationHandler ¶ added in v0.8.0
type AttestationHandler struct {
// contains filtered or unexported fields
}
AttestationHandler exposes the public key that verifies SBOM and VEX attestations.
func NewAttestationHandler ¶ added in v0.8.0
func NewAttestationHandler(svc *attest.Service, log *logger.Logger, evaluator *auth.Evaluator) *AttestationHandler
NewAttestationHandler creates the handler; svc may be nil when attestations are unavailable.
func (*AttestationHandler) RegisterAuthed ¶ added in v0.8.0
func (h *AttestationHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin description of the signing key.
func (*AttestationHandler) RegisterPublic ¶ added in v0.8.0
func (h *AttestationHandler) RegisterPublic(r chi.Router)
RegisterPublic serves the PEM public key without authentication: a verifier has to be able to fetch it before it trusts anything.
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler( db AuthStore, log *logger.Logger, evaluator *auth.Evaluator, trustedProxies *middleware.TrustedProxies, ) *AuthHandler
func (*AuthHandler) RegisterAuthed ¶
func (h *AuthHandler) RegisterAuthed(r chi.Router)
func (*AuthHandler) RegisterPublic ¶
func (h *AuthHandler) RegisterPublic(r chi.Router)
func (*AuthHandler) WithBaseURL ¶ added in v0.6.0
func (h *AuthHandler) WithBaseURL(baseURL string) *AuthHandler
WithBaseURL sets the public base URL; an https value forces Secure cookies.
type AuthStore ¶ added in v0.15.0
type AuthStore interface {
CreateSession(ctx context.Context, session *models.Session) (*models.Session, error)
DeleteOtherSessionsByUser(ctx context.Context, userID string, keepTokenHash string) error
DeleteSessionsByUser(ctx context.Context, userID string) error
GetPasswordExpiry(ctx context.Context, userID string) (*time.Time, error)
GetUserByID(ctx context.Context, id string) (*models.User, error)
GetUserByUsername(ctx context.Context, username string) (*models.User, error)
ListGroupsByUser(ctx context.Context, userID string) ([]*models.Group, error)
ListProjects(ctx context.Context, userID string) ([]*models.Project, error)
UpdateUserLastLogin(ctx context.Context, id string, at time.Time) error
UpdateUserPassword(ctx context.Context, id string, passwordHash string, mustChange bool) error
// contains filtered or unexported methods
}
AuthStore is the part of the database AuthHandler needs.
type BackupHandler ¶
type BackupHandler struct {
// contains filtered or unexported fields
}
func NewBackupHandler ¶
func NewBackupHandler(db BackupStore, log *logger.Logger, evaluator *auth.Evaluator, backupEngine *backup.Engine) *BackupHandler
func (*BackupHandler) RegisterAuthed ¶
func (h *BackupHandler) RegisterAuthed(r chi.Router)
func (*BackupHandler) WithTasks ¶ added in v0.11.0
func (h *BackupHandler) WithTasks(tasks *bgtask.Runner) *BackupHandler
WithTasks runs the async backups and restores under the server lifecycle: they are cancelled and awaited when the runner shuts down.
type BackupStore ¶ added in v0.15.0
type BackupStore interface {
CreateBackupJob(ctx context.Context, job *models.BackupJob) error
GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)
ListBackupJobs(ctx context.Context, limit int) ([]*models.BackupJob, error)
// contains filtered or unexported methods
}
BackupStore is the part of the database BackupHandler needs.
type BrandingHandler ¶ added in v0.10.0
type BrandingHandler struct {
// contains filtered or unexported fields
}
BrandingHandler serves the public white-label settings and lets global administrators change them at runtime.
func NewBrandingHandler ¶ added in v0.10.0
func NewBrandingHandler(mgr *branding.Manager, log *logger.Logger, evaluator *auth.Evaluator) *BrandingHandler
NewBrandingHandler returns the branding handler.
func (*BrandingHandler) RegisterAuthed ¶ added in v0.10.0
func (h *BrandingHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin endpoints behind the RBAC middleware.
func (*BrandingHandler) RegisterPublic ¶ added in v0.10.0
func (h *BrandingHandler) RegisterPublic(r chi.Router)
RegisterPublic registers the unauthenticated endpoints on the bare router: the login page needs them before anyone is signed in.
type BundleKeyResolver ¶ added in v0.8.0
type BundleKeyResolver interface {
SignerByRef(ctx context.Context, ref string) (gpg.Signer, *models.GPGKey, error)
// List returns the stored keys and the read-only configuration key.
List(ctx context.Context) ([]gpgkeys.Entry, error)
}
BundleKeyResolver finds the signer for a seal request's gpg_key_id (a stored key id, a fingerprint, or "config").
type BundlesHandler ¶
type BundlesHandler struct {
// contains filtered or unexported fields
}
func NewBundlesHandler ¶
func NewBundlesHandler(db BundlesStore, log *logger.Logger, evaluator *auth.Evaluator) *BundlesHandler
func (*BundlesHandler) RegisterAuthed ¶
func (h *BundlesHandler) RegisterAuthed(r chi.Router)
func (*BundlesHandler) WithBundleSigners ¶ added in v0.15.0
func (h *BundlesHandler) WithBundleSigners(entries []string) *BundlesHandler
WithBundleSigners sets the per-key signer allowlist: each entry is "<key id or fingerprint>=<username>" (gpg.bundleSigners). Without a grant only administrators (global `manage`) may choose the signing key of a bundle. Malformed entries are dropped; config validation rejects them at startup.
func (*BundlesHandler) WithGPGKeys ¶ added in v0.8.0
func (h *BundlesHandler) WithGPGKeys(keys BundleKeyResolver) *BundlesHandler
WithGPGKeys enables sealing with gpg_key_id: the sealed bundle's manifest is signed with the referenced key.
func (*BundlesHandler) WithPublisher ¶ added in v0.8.0
func (h *BundlesHandler) WithPublisher(p webhook.Publisher) *BundlesHandler
WithPublisher enables the bundle.promoted webhook event.
func (*BundlesHandler) WithWorkers ¶ added in v0.15.0
func (h *BundlesHandler) WithWorkers(w *lifecycle.Workers) *BundlesHandler
WithWorkers enqueues the refresh of generated metadata (deb, npm and rpm indexes, ...) in the target repository after a promotion, through the Changed lifecycle hook of each format over the metadata workers.
type BundlesStore ¶ added in v0.15.0
type BundlesStore interface {
quarantine.Checker
AddBundleItems(ctx context.Context, bundleID string, items []*models.ReleaseBundleItem) error
BeginTx(ctx context.Context) (database.Transaction, error)
BundleItemStored(ctx context.Context, repoID, repoName, format, sha256, path string) (bool, error)
CreatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error
CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeletePromotionPipeline(ctx context.Context, id string) error
DeleteReleaseBundle(ctx context.Context, id string) error
GetBundleItem(ctx context.Context, bundleID string, sha256 string) (*models.ReleaseBundleItem, error)
GetPromotionPipelineByID(ctx context.Context, id string) (*models.PromotionPipeline, error)
GetPromotionPipelineByName(ctx context.Context, name string) (*models.PromotionPipeline, error)
GetReleaseBundle(ctx context.Context, name string, version string) (*models.ReleaseBundle, error)
GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
ListBundleItems(ctx context.Context, bundleID string) ([]*models.ReleaseBundleItem, error)
ListBundlePromotions(ctx context.Context, bundleID string) ([]*models.BundlePromotion, error)
ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)
ListPromotionPipelines(ctx context.Context) ([]*models.PromotionPipeline, error)
ListReleaseBundles(
ctx context.Context,
nameFilter string,
stateFilter string,
page int,
limit int,
) ([]*models.ReleaseBundle, int, error)
ListRepositories(ctx context.Context, page int, limit int, formatFilter string) ([]*models.Repository, error)
RemoveBundleItem(ctx context.Context, bundleID string, sha256 string) error
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
SealReleaseBundle(ctx context.Context, bundleID string, sealedBy string, sealedAt time.Time, sig *models.BundleSignature) (bool, error)
UpdatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error
UpdateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
// contains filtered or unexported methods
}
BundlesStore is the part of the database BundlesHandler needs.
type CleanupHandler ¶
type CleanupHandler struct {
// contains filtered or unexported fields
}
func NewCleanupHandler ¶
func NewCleanupHandler(db CleanupStore, log *logger.Logger, evaluator *auth.Evaluator, runner CleanupRunner) *CleanupHandler
func (*CleanupHandler) RegisterAuthed ¶
func (h *CleanupHandler) RegisterAuthed(r chi.Router)
type CleanupRunner ¶ added in v0.2.0
type CleanupRunner interface {
TriggerPolicy(ctx context.Context, policyID string) error
// PreviewPolicy reports what a run would remove, removing nothing.
PreviewPolicy(ctx context.Context, policyID string) (*worker.CleanupPreview, error)
// PreviewDraftPolicy is PreviewPolicy for a policy that is not stored.
PreviewDraftPolicy(ctx context.Context, policy *models.CleanupPolicy) (*worker.CleanupPreview, error)
}
CleanupRunner starts an immediate run of a cleanup policy. It is satisfied by *worker.CleanupWorker.
type CleanupStore ¶ added in v0.15.0
type CleanupStore interface {
CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
DeleteCleanupPolicy(ctx context.Context, id string) error
GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)
ListCleanupPolicies(ctx context.Context, repoID string) ([]*models.CleanupPolicy, error)
UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
// contains filtered or unexported methods
}
CleanupStore is the part of the database CleanupHandler needs.
type CompletePresignedUploadResponse ¶ added in v0.5.0
type CompletePresignedUploadResponse struct {
ID string `json:"id"`
Path string `json:"path"`
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
}
CompletePresignedUploadResponse mirrors the response of a raw PUT.
type CreatePresignedUploadRequest ¶ added in v0.5.0
type CreatePresignedUploadRequest struct {
Path string `json:"path"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
ContentType string `json:"content_type,omitempty"`
// Multipart asks for a multipart upload: the client PUTs the object in
// parts to URLs fetched from the parts endpoint. Required above the
// single-upload limit (5 GiB).
Multipart bool `json:"multipart,omitempty"`
// PartSize is the part size in bytes of a multipart upload (5 MiB to
// 4000 MiB); 0 lets the server choose.
PartSize int64 `json:"part_size,omitempty"`
}
CreatePresignedUploadRequest is the body of POST /repositories/{name}/uploads.
type CreatePresignedUploadResponse ¶ added in v0.5.0
type CreatePresignedUploadResponse struct {
ID string `json:"id"`
// UploadURL accepts one PUT of exactly Size bytes. Do not log it: the
// query string is the credential. Absent for a multipart upload.
UploadURL string `json:"upload_url,omitempty"`
Method string `json:"method,omitempty"`
// Headers must be sent with the PUT.
Headers map[string]string `json:"headers,omitempty"`
ExpiresAt time.Time `json:"expires_at"`
// Multipart, PartSize and PartCount describe a multipart upload: PUT each
// part (all PartSize bytes but the last) to a URL from the parts endpoint.
Multipart bool `json:"multipart,omitempty"`
PartSize int64 `json:"part_size,omitempty"`
PartCount int `json:"part_count,omitempty"`
}
CreatePresignedUploadResponse tells the client where and how to upload.
type CurationHandler ¶ added in v0.16.0
type CurationHandler struct {
// contains filtered or unexported fields
}
CurationHandler serves the curation rules of proxy repositories and the explanation of why a package version is, or is not, available.
func NewCurationHandler ¶ added in v0.16.0
func NewCurationHandler( db CurationStore, log *logger.Logger, evaluator *auth.Evaluator, published PublishTimeSource, ) *CurationHandler
NewCurationHandler builds the handler. published may be nil: the minimum age is then reported as unknown.
func (*CurationHandler) RegisterAuthed ¶ added in v0.16.0
func (h *CurationHandler) RegisterAuthed(r chi.Router)
type CurationStore ¶ added in v0.16.0
type CurationStore interface {
ListCurationRules(ctx context.Context, repoID string) ([]curation.Rule, error)
GetCurationRule(ctx context.Context, repoID, id string) (*curation.Rule, error)
CreateCurationRule(ctx context.Context, rule *curation.Rule) (*curation.Rule, error)
UpdateCurationRule(ctx context.Context, rule *curation.Rule) (*curation.Rule, error)
DeleteCurationRule(ctx context.Context, repoID, id string) error
PackageVersionHolds(ctx context.Context, repoID, pkg, version string) (models.VersionHolds, error)
// contains filtered or unexported methods
}
CurationStore is the part of the database CurationHandler needs.
type DTrackPusher ¶ added in v0.8.0
DTrackPusher is what the handler needs from the background pusher.
type DTrackSources ¶ added in v0.8.0
type DTrackSources struct {
// contains filtered or unexported fields
}
DTrackSources builds the documents pushed to Dependency-Track from stored state.
func NewDTrackSources ¶ added in v0.8.0
func NewDTrackSources(db DTrackSourcesStore, gen *sbom.Generator) *DTrackSources
NewDTrackSources creates the sources over db and the SBOM generator.
func (*DTrackSources) BOM ¶ added in v0.8.0
func (s *DTrackSources) BOM(ctx context.Context, repo *models.Repository, artifactID string) ([]byte, int, error)
BOM implements dtrack.Sources: the CycloneDX SBOM without its vulnerabilities (Dependency-Track runs its own analysis and receives the decisions as VEX).
func (*DTrackSources) VEX ¶ added in v0.8.0
func (s *DTrackSources) VEX(ctx context.Context, repo *models.Repository, artifactID string, opts sbom.VEXOptions) ([]byte, int, error)
VEX implements dtrack.Sources.
type DTrackSourcesStore ¶ added in v0.15.0
type DTrackSourcesStore interface {
// contains filtered or unexported methods
}
DTrackSourcesStore is the part of the database DTrackSources needs.
type DebUploadHandler ¶
type DebUploadHandler struct {
// contains filtered or unexported fields
}
func NewDebUploadHandler ¶
func NewDebUploadHandler(log *logger.Logger, db DebUploadStore, blobStore storage.BlobStore, reg *metrics.Registry) *DebUploadHandler
func (*DebUploadHandler) Register ¶
func (h *DebUploadHandler) Register(router chi.Router)
func (*DebUploadHandler) SetDebWorker ¶
func (h *DebUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
func (*DebUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *DebUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact events.
type DebUploadStore ¶ added in v0.15.0
type DebUploadStore interface {
ArtifactExists(ctx context.Context, sha256 string, repositoryID string) (bool, error)
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
CreateDebPackage(ctx context.Context, pkg *models.Component, distID string, compID string, control models.DebControl) error
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeleteComponent(ctx context.Context, componentID string) error
GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)
GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)
GetDebianPackageByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
GetOrCreateDebianArchitecture(ctx context.Context, distID string, name string) (*models.DebianArchitecture, error)
GetOrCreateDebianComponent(ctx context.Context, distID string, name string) (*models.DebianComponent, error)
GetOrCreateDebianDistribution(ctx context.Context, repoID string, name string) (*models.DebianDistribution, error)
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
UpsertBlob(ctx context.Context, sha256 string, blobKey string, sizeBytes int64) (string, error)
}
DebUploadStore is the part of the database DebUploadHandler needs.
type DeltaHandler ¶
type DeltaHandler struct {
// contains filtered or unexported fields
}
DeltaHandler handles package delta requests.
func NewDeltaHandler ¶
func NewDeltaHandler(log *logger.Logger, db DeltaStore, blobStore storage.BlobStore) *DeltaHandler
NewDeltaHandler creates a new DeltaHandler.
func (*DeltaHandler) Register ¶
func (h *DeltaHandler) Register(router chi.Router)
Register registers the delta routes on the given router.
type DeltaStore ¶ added in v0.15.0
type DeltaStore interface {
quarantine.Checker
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
CreatePackageDelta(ctx context.Context, delta *models.PackageDelta) error
GetComponentByID(ctx context.Context, id string) (*models.Component, error)
GetComponentBySHA256(ctx context.Context, repoID string, sha256 string) (*models.Component, error)
GetPackageDelta(ctx context.Context, repoID string, fromSHA256 string, toSHA256 string) (*models.PackageDelta, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListPackageDeltas(ctx context.Context, repoID string, toSHA256 string) ([]*models.PackageDelta, error)
UpsertBlob(ctx context.Context, sha256 string, blobKey string, sizeBytes int64) (string, error)
}
DeltaStore is the part of the database DeltaHandler needs.
type DependencyTrackHandler ¶ added in v0.8.0
type DependencyTrackHandler struct {
// contains filtered or unexported fields
}
DependencyTrackHandler manages the Dependency-Track integration: the global settings, per-repository overrides, connection tests and manual pushes.
func NewDependencyTrackHandler ¶ added in v0.8.0
func NewDependencyTrackHandler( db DependencyTrackStore, log *logger.Logger, evaluator *auth.Evaluator, pusher DTrackPusher, ) *DependencyTrackHandler
NewDependencyTrackHandler creates the handler; pusher may be nil (manual pushes then answer 501).
func (*DependencyTrackHandler) RegisterAuthed ¶ added in v0.8.0
func (h *DependencyTrackHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the admin routes.
type DependencyTrackStore ¶ added in v0.15.0
type DependencyTrackStore interface {
DeleteRepositoryDependencyTrack(ctx context.Context, repoID string) (bool, error)
GetDependencyTrackPush(ctx context.Context, repoID string, artifactID string) (*models.DependencyTrackPush, error)
GetRepositoryDependencyTrack(ctx context.Context, repoID string) (*models.RepositoryDependencyTrack, error)
GetSystemSetting(ctx context.Context, key string) (string, error)
ListDependencyTrackPushes(ctx context.Context, repoID string, limit int) ([]*models.DependencyTrackPush, error)
SetSystemSetting(ctx context.Context, key string, value string) error
UpsertDependencyTrackPush(ctx context.Context, s *models.DependencyTrackPush) error
UpsertRepositoryDependencyTrack(ctx context.Context, c *models.RepositoryDependencyTrack) error
// contains filtered or unexported methods
}
DependencyTrackStore is the part of the database DependencyTrackHandler needs.
type DockerGCHandler ¶ added in v0.4.0
type DockerGCHandler struct {
// contains filtered or unexported fields
}
DockerGCHandler serves the admin endpoint that runs Docker registry garbage collection (untagged manifests and the blobs only they referenced) on demand.
func NewDockerGCHandler ¶ added in v0.4.0
func NewDockerGCHandler(db DockerGCHandlerStore, log *logger.Logger, evaluator *auth.Evaluator, runner DockerGCRunner) *DockerGCHandler
func (*DockerGCHandler) RegisterAuthed ¶ added in v0.4.0
func (h *DockerGCHandler) RegisterAuthed(r chi.Router)
type DockerGCHandlerStore ¶ added in v0.15.0
type DockerGCHandlerStore interface {
// contains filtered or unexported methods
}
DockerGCHandlerStore is the part of the database NewDockerGCHandler needs.
type DockerGCRunner ¶ added in v0.4.0
type DockerGCRunner interface {
RunRepo(ctx context.Context, repo *models.Repository, opts worker.DockerGCOptions) (*worker.DockerGCReport, error)
DefaultGrace() time.Duration
}
DockerGCRunner runs Docker registry garbage collection. It is satisfied by *worker.DockerGCWorker.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Code string `json:"code"`
Details string `json:"details,omitempty"`
}
ErrorResponse represents an error response.
type FederationDeferredResponse ¶ added in v0.9.0
type FederationDeferredResponse struct {
UnitKey string `json:"unit_key"`
Seq int64 `json:"seq"`
Attempts int `json:"attempts"`
Reason string `json:"reason"`
LastError string `json:"last_error"`
FirstSeenAt time.Time `json:"first_seen_at"`
NextAttemptAt time.Time `json:"next_attempt_at"`
}
FederationDeferredResponse is a unit set aside after failing to apply.
type FederationHandler ¶ added in v0.9.0
type FederationHandler struct {
// contains filtered or unexported fields
}
FederationHandler serves the federation admin API of a repository.
func NewFederationHandler ¶ added in v0.9.0
func NewFederationHandler( db FederationHandlerStore, log *logger.Logger, evaluator *auth.Evaluator, store *federation.Store, serverEnabled bool, kick func(), ) *FederationHandler
NewFederationHandler creates the handler.
func (*FederationHandler) RegisterAuthed ¶ added in v0.9.0
func (h *FederationHandler) RegisterAuthed(r chi.Router)
RegisterAuthed mounts the routes on the authenticated API router.
type FederationHandlerStore ¶ added in v0.15.0
type FederationHandlerStore interface {
// contains filtered or unexported methods
}
FederationHandlerStore is the part of the database NewFederationHandler needs.
type FederationPeerResponse ¶ added in v0.9.0
type FederationPeerResponse struct {
ID string `json:"id"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
Enabled bool `json:"enabled"`
State string `json:"state"`
CursorSeq int64 `json:"cursor_seq"`
RemoteHeadSeq int64 `json:"remote_head_seq"`
BacklogUnits int64 `json:"backlog_units"`
LagSeconds float64 `json:"lag_seconds"`
LastAttemptAt *time.Time `json:"last_attempt_at,omitempty"`
LastSuccessAt *time.Time `json:"last_success_at,omitempty"`
NextAttemptAt *time.Time `json:"next_attempt_at,omitempty"`
LastError string `json:"last_error"`
ErrorCount int `json:"error_count"`
AppliedTotal int64 `json:"applied_total"`
ConflictsTotal int64 `json:"conflicts_total"`
DeferredUnits int `json:"deferred_units"`
ResyncRequested bool `json:"resync_requested"`
HasCAPEM bool `json:"has_ca_pem"`
HasClientCert bool `json:"has_client_cert"`
CreatedAt time.Time `json:"created_at"`
}
FederationPeerResponse is a federation peer with its replication state.
type FederationStatusResponse ¶ added in v0.9.0
type FederationStatusResponse struct {
Enabled bool `json:"enabled"`
Supported bool `json:"supported"`
// ServerEnabled is federation.enabled; Supported is false while it is off.
ServerEnabled bool `json:"server_enabled"`
InstanceID string `json:"instance_id"`
LogID string `json:"log_id"`
HeadSeq int64 `json:"head_seq"`
Units int64 `json:"units"`
Tombstones int64 `json:"tombstones"`
Peers []FederationPeerResponse `json:"peers"`
Tokens []FederationTokenResponse `json:"tokens"`
}
FederationStatusResponse is the federation state of a repository.
type FederationTokenCreatedResponse ¶ added in v0.9.0
type FederationTokenCreatedResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Token string `json:"token"`
CreatedAt time.Time `json:"created_at"`
}
FederationTokenCreatedResponse carries the new token's secret.
type FederationTokenResponse ¶ added in v0.9.0
type FederationTokenResponse struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
}
FederationTokenResponse is a peer token; the secret is shown once, at creation.
type FrontendTelemetryHandler ¶ added in v0.15.0
type FrontendTelemetryHandler struct {
// contains filtered or unexported fields
}
FrontendTelemetryHandler serves the experimental browser telemetry: the config endpoint the web UI reads before loading the SDK, and the same-origin relay that validates its OTLP/HTTP export requests (protobuf that parses, ids of the right size, bounded record, attribute and string sizes, a fixed resource, a rate limit per user) and forwards the bounded re-encoding to the collector. Both answer 404 while the feature is off. Redaction of what the browser puts in the values stays the collector's job.
func NewFrontendTelemetryHandler ¶ added in v0.15.0
func NewFrontendTelemetryHandler(cfg telemetry.Config, reg *metrics.Registry, log *logger.Logger) *FrontendTelemetryHandler
NewFrontendTelemetryHandler creates the handler for cfg; reg may be nil. Its client refuses redirects: one would replay the body and the otlp.headers (collector credentials) to wherever it points. It is deliberately not the SSRF-safe client of internal/netutil: the collector is operator configuration and usually internal (localhost, a sidecar, a compose service).
func (*FrontendTelemetryHandler) RegisterAuthed ¶ added in v0.15.0
func (h *FrontendTelemetryHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the routes on the authenticated router. RBAC lets sessions reach them (isSelfServiceRequest); the relay itself refuses every other credential.
type GroupMetadataNotifier ¶ added in v0.8.0
type GroupMetadataNotifier interface {
// NotifyStale marks a group's metadata stale and schedules its regeneration.
NotifyStale(groupID string)
// NotifyMemberChanged does so for every apk/deb/rpm group listing the repository.
NotifyMemberChanged(repoID string)
}
GroupMetadataNotifier invalidates the generated metadata of apk, deb and rpm group repositories (worker.GroupMetadataWorker).
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer implements the Server interface.
func NewHTTPServer ¶
func NewHTTPServer(addr string, log *logger.Logger) *HTTPServer
NewHTTPServer creates a new HTTP server. Defaults favor never truncating large artifact transfers: no read/write timeout, with only header reads bounded (slowloris mitigation) until SetTimeouts overrides them from config.
func (*HTTPServer) AddMiddleware ¶
func (s *HTTPServer) AddMiddleware(middleware func(http.Handler) http.Handler)
AddMiddleware adds a middleware to the server.
func (*HTTPServer) DisableKeepAlives ¶ added in v0.13.2
func (s *HTTPServer) DisableKeepAlives()
DisableKeepAlives makes the server close each connection after its current request, so clients reconnect (to another replica) while the pod drains.
func (*HTTPServer) EnableTLS ¶ added in v0.2.0
func (s *HTTPServer) EnableTLS(certFile, keyFile string)
EnableTLS makes Start serve HTTPS using the given certificate and key files.
func (*HTTPServer) GetRouter ¶
func (s *HTTPServer) GetRouter() chi.Router
GetRouter returns the underlying chi router.
func (*HTTPServer) ServeErrors ¶ added in v0.4.0
func (s *HTTPServer) ServeErrors() <-chan error
ServeErrors delivers the error that ended the accept loop unexpectedly (anything but a graceful Stop). The caller must treat it as fatal.
func (*HTTPServer) SetConnLimits ¶ added in v0.15.0
func (s *HTTPServer) SetConnLimits(idleTimeout time.Duration, maxHeaderBytes int)
SetConnLimits sets the keep-alive idle timeout and the request header size cap. idleTimeout 0 means no limit; maxHeaderBytes 0 keeps the Go default.
func (*HTTPServer) SetTimeouts ¶
func (s *HTTPServer) SetTimeouts(readTimeout, writeTimeout, readHeaderTimeout time.Duration)
SetTimeouts configures read, write, and read-header timeouts on the HTTP server. readTimeout/writeTimeout of 0 mean "no limit" (relevant for large artifact transfers); readHeaderTimeout should stay non-zero regardless — it bounds only the header-read phase, so it never truncates a body.
func (*HTTPServer) Start ¶
func (s *HTTPServer) Start(ctx context.Context) error
Start binds the listen address and serves in the background. Everything that can be checked up front (the TLS key pair, the bind itself) fails here, so a misconfigured server never reports a successful start. A later failure of the accept loop is delivered on ServeErrors.
type LicenseHandler ¶
type LicenseHandler struct {
// contains filtered or unexported fields
}
func NewLicenseHandler ¶
func NewLicenseHandler( db LicenseStore, log *logger.Logger, evaluator *auth.Evaluator, detector *license.Detector, blobs storage.BlobStore, ) *LicenseHandler
NewLicenseHandler returns the license scan and policy handler. blobs is the store the scan reads artifact files from to find their declared licenses.
func (*LicenseHandler) RegisterRoutes ¶
func (h *LicenseHandler) RegisterRoutes(authedRouter chi.Router)
type LicenseStore ¶ added in v0.15.0
type LicenseStore interface {
CreateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
DeleteArtifactProperty(ctx context.Context, repoID string, artifactID string, key string) error
DeleteLicensePolicy(ctx context.Context, id string) error
GetLicensePolicy(ctx context.Context, id string) (*models.LicensePolicy, error)
GetLicenseScanResult(ctx context.Context, repoID string, artifactID string) (*models.LicenseScanResult, error)
GetLicenseScanResultByID(ctx context.Context, repoID string, id string) (*models.LicenseScanResult, error)
GetRepoComponentBlob(ctx context.Context, repoID string, id string) (*models.ComponentBlob, error)
ListGlobalLicensePolicies(ctx context.Context) ([]*models.LicensePolicy, error)
ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)
ListLicenseScanResults(ctx context.Context, repoID string) ([]*models.LicenseScanResult, error)
SearchByProperty(ctx context.Context, repoID string, key string, value string) ([]string, error)
SetArtifactProperties(ctx context.Context, repoID string, artifactID string, props map[string]string, replace bool) error
SetLicenseScanQuarantine(ctx context.Context, repoID string, id string, quarantined bool) error
UpdateLicensePolicy(ctx context.Context, policy *models.LicensePolicy) error
// contains filtered or unexported methods
}
LicenseStore is the part of the database LicenseHandler needs.
type MavenUploadHandler ¶
type MavenUploadHandler struct {
// contains filtered or unexported fields
}
func NewMavenUploadHandler ¶
func NewMavenUploadHandler( log *logger.Logger, db MavenUploadStore, blobStore storage.BlobStore, reg *metrics.Registry, ) *MavenUploadHandler
func (*MavenUploadHandler) Register ¶
func (h *MavenUploadHandler) Register(router chi.Router)
Register mounts PUT/DELETE using a true chi wildcard ("/*"), not a regexp param: chi's {name:regexp} params never span "/" (the tail delimiter defaults to '/', so the regexp is only ever tested against a single path segment), so {path:.*} can never match a multi-segment GAV path and silently 404s every real upload/delete.
func (*MavenUploadHandler) SetMavenWorker ¶
func (h *MavenUploadHandler) SetMavenWorker(w *worker.MavenMetadataWorker)
SetMavenWorker wires the debounced maven-metadata.xml regeneration worker. Call NotifyStale(repoID, groupID, artifactID) after each successful upload.
func (*MavenUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *MavenUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher for artifact.* events.
func (*MavenUploadHandler) WithTasks ¶ added in v0.15.0
func (h *MavenUploadHandler) WithTasks(tasks *bgtask.Runner) *MavenUploadHandler
WithTasks runs the re-evaluation of the poms waiting for a parent under the server lifecycle: it is cancelled at shutdown, which waits for it, bounded.
type MavenUploadStore ¶ added in v0.15.0
type MavenUploadStore interface {
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
CreateMavenArtifact(ctx context.Context, a *models.MavenArtifact) error
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeleteMavenArtifact(ctx context.Context, id string) error
GetDebBlobInfo(ctx context.Context, blobID string) (string, int64, error)
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
UpsertBlob(ctx context.Context, sha256 string, blobKey string, sizeBytes int64) (string, error)
// contains filtered or unexported methods
}
MavenUploadStore is the part of the database MavenUploadHandler needs.
type NPMUploadHandler ¶
type NPMUploadHandler struct {
// contains filtered or unexported fields
}
func NewNPMUploadHandler ¶
func NewNPMUploadHandler( log *logger.Logger, db NPMUploadStore, blobStore storage.BlobStore, reg *metrics.Registry, ) *NPMUploadHandler
func (*NPMUploadHandler) HandlePublish ¶ added in v0.2.0
func (h *NPMUploadHandler) HandlePublish(w http.ResponseWriter, r *http.Request)
HandlePublish serves an npm publish (or `-rev` unpublish) PUT. It is exported for routers that share PUT "/*" with another format.
func (*NPMUploadHandler) Register ¶
func (h *NPMUploadHandler) Register(router chi.Router)
Register mounts the publish/unpublish routes under /repos/{name} on a router that has no other /repos/{name} subrouter (tests). Production code shares the /repos/{name} subrouter with the other formats and calls RegisterRepoRoutes.
func (*NPMUploadHandler) RegisterRepoRoutes ¶ added in v0.2.0
func (h *NPMUploadHandler) RegisterRepoRoutes(r chi.Router)
RegisterRepoRoutes registers the routes relative to a /repos/{name} subrouter. They must live inside that subrouter: a sibling /repos/{repo}/* route is shadowed by the mount and every PUT/DELETE 404s.
func (*NPMUploadHandler) SetNPMWorker ¶
func (h *NPMUploadHandler) SetNPMWorker(w *worker.NPMMetadataWorker)
SetNPMWorker wires the debounced npm packument regeneration worker. Call NotifyStale(packageID) after each successful publish.
func (*NPMUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *NPMUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact.uploaded and artifact.deleted events. It must be called before the handler serves requests.
type NPMUploadStore ¶ added in v0.15.0
type NPMUploadStore interface {
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
CreateNPMPackage(ctx context.Context, p *models.NPMPackage) (*models.NPMPackage, error)
CreateNPMVersion(ctx context.Context, v *models.NPMVersion) (*models.NPMVersion, error)
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeleteNPMDistTag(ctx context.Context, packageID string, tag string) error
DeleteNPMPackage(ctx context.Context, packageID string) error
DeleteNPMVersion(ctx context.Context, packageID string, version string) error
GetNPMDistTags(ctx context.Context, packageID string) (map[string]string, error)
GetNPMPackageByName(ctx context.Context, repoID string, fullName string) (*models.NPMPackage, error)
GetNPMVersion(ctx context.Context, packageID string, version string) (*models.NPMVersion, error)
GetNPMVersionsByPackage(ctx context.Context, packageID string) ([]*models.NPMVersion, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListLicensePolicies(ctx context.Context, repoID string) ([]*models.LicensePolicy, error)
MarkPackumentStale(ctx context.Context, packageID string) error
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
UpdateNPMVersionManifest(ctx context.Context, packageID string, version string, manifest []byte) error
UpsertBlob(ctx context.Context, sha256 string, blobKey string, sizeBytes int64) (string, error)
UpsertNPMDistTag(ctx context.Context, t *models.NPMDistTag) (*models.NPMDistTag, error)
}
NPMUploadStore is the part of the database NPMUploadHandler needs.
type NixKeyHandler ¶ added in v0.14.0
type NixKeyHandler struct {
// contains filtered or unexported fields
}
NixKeyHandler manages the ed25519 key that signs the narinfo of a Nix repository (docs/formats/nix.md). Every route needs an admin.
func NewNixKeyHandler ¶ added in v0.14.0
func NewNixKeyHandler(db signingKeyAdminStore, log *logger.Logger, evaluator *auth.Evaluator, keys *nixkeys.Service) *NixKeyHandler
NewNixKeyHandler builds the handler.
func (*NixKeyHandler) Register ¶ added in v0.14.0
func (h *NixKeyHandler) Register(r chi.Router)
Register registers the routes on the authenticated REST router.
type OIDCExchangeHandler ¶ added in v0.16.0
type OIDCExchangeHandler struct {
// contains filtered or unexported fields
}
OIDCExchangeHandler trades the ID token of a CI job for a short-lived token of the service account an administrator mapped it to (see auth.CIOIDC). The endpoint needs no credentials; the ID token is the credential.
func NewOIDCExchangeHandler ¶ added in v0.16.0
func NewOIDCExchangeHandler(db OIDCExchangeStore, log *logger.Logger, trustedProxies *middleware.TrustedProxies) *OIDCExchangeHandler
NewOIDCExchangeHandler returns the handler; trustedProxies resolves the client address behind a reverse proxy.
func (*OIDCExchangeHandler) RegisterPublic ¶ added in v0.16.0
func (h *OIDCExchangeHandler) RegisterPublic(r chi.Router)
RegisterPublic mounts the exchange on the unauthenticated router.
type OIDCExchangeStore ¶ added in v0.16.0
type OIDCExchangeStore interface {
auth.CIOIDCStore
auth.CreateTokenStore
}
OIDCExchangeStore is the part of the database OIDCExchangeHandler needs.
type OIDCHandler ¶
type OIDCHandler struct {
// contains filtered or unexported fields
}
func NewOIDCHandler ¶
func (*OIDCHandler) RegisterPublic ¶
func (h *OIDCHandler) RegisterPublic(public chi.Router)
func (*OIDCHandler) WithTrustedProxies ¶ added in v0.2.0
func (h *OIDCHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *OIDCHandler
WithTrustedProxies sets the reverse-proxy allowlist used to resolve the client IP recorded on new sessions. Without it the TCP peer address is used.
type OIDCStore ¶ added in v0.15.0
type OIDCStore interface {
CreateUser(ctx context.Context, user *models.User) (*models.User, error)
GetGroupByName(ctx context.Context, name string) (*models.Group, error)
GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)
GetOrCreatePermissionAssignment(ctx context.Context, targetID string, principalType string, principalID string) error
GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
GetUserByEmail(ctx context.Context, email string) (*models.User, error)
GetUserByExternalID(ctx context.Context, externalID string, providerSlug string) (*models.User, error)
GetUserByUsername(ctx context.Context, username string) (*models.User, error)
SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error
UpdateUserSSO(ctx context.Context, userID string, externalID string, providerSlug string) error
UpdateUserSSOProfile(ctx context.Context, id string, email *string, fullName *string, lastLogin time.Time) error
// contains filtered or unexported methods
}
OIDCStore is the part of the database OIDCHandler needs.
type OpenAPIHandler ¶
type OpenAPIHandler struct {
// contains filtered or unexported fields
}
OpenAPIHandler serves the OpenAPI spec and the interactive API reference.
func NewOpenAPIHandler ¶
func NewOpenAPIHandler(version string, docsEnabled bool) *OpenAPIHandler
NewOpenAPIHandler returns a handler stamping version into the spec. The spec routes are always served; the API reference and the legacy /swagger redirects only when docsEnabled.
func (*OpenAPIHandler) RegisterRoutes ¶
func (h *OpenAPIHandler) RegisterRoutes(router chi.Router)
type PackageDeleter ¶ added in v0.8.0
type PackageDeleter interface {
DeletePackage(
ctx context.Context,
repo *models.Repository,
id string,
guard func(worker.DeletedPackage) error,
actor string,
) (*worker.DeletedPackage, error)
}
PackageDeleter deletes a package row of any hosted format by its listing id. It is satisfied by *worker.CleanupWorker.
type PresignedPart ¶ added in v0.8.0
type PresignedPart struct {
PartNumber int `json:"part_number"`
// UploadURL accepts one PUT of exactly Size bytes. Do not log it: the
// query string is the credential.
UploadURL string `json:"upload_url"`
Method string `json:"method"`
// Headers must be sent with the PUT.
Headers map[string]string `json:"headers"`
// Size is the exact size of the part in bytes.
Size int64 `json:"size"`
}
PresignedPart is the upload target of one part.
type PresignedPartsRequest ¶ added in v0.8.0
type PresignedPartsRequest struct {
// PartNumbers are the 1-based parts to sign, at most 100 per call.
PartNumbers []int `json:"part_numbers"`
}
PresignedPartsRequest is the body of POST /repositories/{name}/uploads/{id}/parts.
type PresignedPartsResponse ¶ added in v0.8.0
type PresignedPartsResponse struct {
Parts []PresignedPart `json:"parts"`
ExpiresAt time.Time `json:"expires_at"`
}
PresignedPartsResponse carries the signed part URLs.
type PresignedUploadHandler ¶ added in v0.5.0
type PresignedUploadHandler struct {
*base.Handler
DB PresignedUploadStore
// contains filtered or unexported fields
}
PresignedUploadHandler implements client-direct uploads: the client PUTs the bytes straight to the object store using a short-lived presigned URL, then calls complete so the server can verify size and sha256 and record the artifact. Only raw hosted repositories are supported.
func NewPresignedUploadHandler ¶ added in v0.5.0
func NewPresignedUploadHandler(log *logger.Logger, db PresignedUploadStore, blobStore storage.BlobStore, evaluator *auth.Evaluator, urlTTL time.Duration, maxPending int, reg *metrics.Registry, ) *PresignedUploadHandler
NewPresignedUploadHandler builds the handler. blobStore may or may not support staging uploads; an unsupported backend answers 501 without recording anything. maxPending caps one user's outstanding uploads (0 = unlimited).
func (*PresignedUploadHandler) Register ¶ added in v0.5.0
func (h *PresignedUploadHandler) Register(router chi.Router)
Register mounts the routes.
type PresignedUploadStore ¶ added in v0.15.0
type PresignedUploadStore interface {
quarantine.Checker
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
ClaimPresignedUpload(ctx context.Context, repoID string, id string, lease time.Duration) (bool, error)
CreatePresignedUploadCapped(ctx context.Context, u *models.PresignedUpload, maxPending int) error
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
DeletePresignedUpload(ctx context.Context, id string) error
ExtendPresignedUploadExpiry(ctx context.Context, id string, expiresAt time.Time) error
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetPresignedUpload(ctx context.Context, repoID string, id string) (*models.PresignedUpload, error)
GetRawArtifact(ctx context.Context, repoID string, path string) (*models.RawArtifact, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
MarkPresignedUploadCompleted(ctx context.Context, id string, artifactID string) error
ReleasePresignedUpload(ctx context.Context, id string) error
ReserveStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) (bool, error)
SetPresignedUploadMultipartID(ctx context.Context, id string, multipartID string) error
UpsertRawArtifact(ctx context.Context, artifact *models.RawArtifact) error
}
PresignedUploadStore is the part of the database PresignedUploadHandler needs.
type ProjectCleanupPreviewer ¶ added in v0.8.0
type ProjectCleanupPreviewer interface {
PreviewProjectPolicy(ctx context.Context, policyID string) ([]*worker.CleanupPreview, error)
}
ProjectCleanupPreviewer evaluates a project default cleanup policy without running it. It is satisfied by *worker.CleanupWorker.
type ProjectsHandler ¶ added in v0.6.0
type ProjectsHandler struct {
// contains filtered or unexported fields
}
ProjectsHandler serves /api/v1/projects: projects, their members and the groups attached to them. The RBAC middleware is the first gate (project scope, 404 for non-members, 403 below the required role); the handler re-checks the same decision from the evaluator, so a route reached any other way is still protected, and adds the escalation guards the middleware cannot know (which role is granted to whom).
func NewProjectsHandler ¶ added in v0.6.0
func NewProjectsHandler( db ProjectsStore, log *logger.Logger, evaluator *auth.Evaluator, settings *auth.ProjectSettings, ) *ProjectsHandler
NewProjectsHandler returns the projects handler. evaluator decides roles and who is a global admin (implicit owner of every project); settings holds the projects.self_create switch.
func (*ProjectsHandler) RegisterRoutes ¶ added in v0.6.0
func (h *ProjectsHandler) RegisterRoutes(r chi.Router)
func (*ProjectsHandler) SetCleanupPreviewer ¶ added in v0.8.0
func (h *ProjectsHandler) SetCleanupPreviewer(p ProjectCleanupPreviewer)
SetCleanupPreviewer wires the dry run of project default cleanup policies.
type ProjectsStore ¶ added in v0.15.0
type ProjectsStore interface {
AddProjectMember(ctx context.Context, projectID string, userID string, role string) error
ChangeProjectGroup(
ctx context.Context,
projectID string,
groupID string,
newRole string,
createdBy *string,
guard database.ProjectRoleGuard,
) error
ChangeProjectMember(ctx context.Context, projectID string, userID string, newRole string, guard database.ProjectRoleGuard) error
CountRepositoriesByProject(ctx context.Context, projectIDs []string) (map[string]int, error)
CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
CreateProject(ctx context.Context, project *models.Project) error
CreateProjectToken(ctx context.Context, spec database.ProjectTokenSpec) (*models.Token, error)
DeleteCleanupPolicy(ctx context.Context, id string) error
DeleteProject(ctx context.Context, id string) error
GetCleanupPolicy(ctx context.Context, id string) (*models.CleanupPolicy, error)
GetGroupByID(ctx context.Context, id string) (*models.Group, error)
GetGroupByName(ctx context.Context, name string) (*models.Group, error)
GetProjectByName(ctx context.Context, name string) (*models.Project, error)
GetProjectGroup(ctx context.Context, projectID string, groupID string) (*models.ProjectGroup, error)
GetProjectMember(ctx context.Context, projectID string, userID string) (*models.ProjectMember, error)
GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
GetProjectUsage(ctx context.Context, projectID string) (*models.ProjectUsage, error)
GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)
GetUserByID(ctx context.Context, id string) (*models.User, error)
GetUserByUsername(ctx context.Context, username string) (*models.User, error)
ListAllProjects(ctx context.Context) ([]*models.Project, error)
ListProjectCleanupPolicies(ctx context.Context, projectID string) ([]*models.CleanupPolicy, error)
ListProjectGroups(ctx context.Context, projectID string) ([]*models.ProjectGroup, error)
ListProjectMembers(ctx context.Context, projectID string) ([]*models.ProjectMember, error)
ListProjectRepositories(ctx context.Context, projectID string, page int, limit int) ([]*models.Repository, int, error)
ListProjectStats(ctx context.Context, projectIDs []string) (map[string]*models.ProjectStats, error)
ListProjectTokens(ctx context.Context, projectID string, createdBy *string) ([]*models.Token, error)
ListProjects(ctx context.Context, userID string) ([]*models.Project, error)
RevokeProjectToken(ctx context.Context, projectID string, tokenID string) (bool, error)
SetProjectQuota(
ctx context.Context,
projectID string,
maxSizeBytes int64,
maxArtifactCount int64,
warnThresholdPercent int,
) (*models.ProjectQuota, error)
UpdateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
UpdateProject(ctx context.Context, project *models.Project) error
// contains filtered or unexported methods
}
ProjectsStore is the part of the database ProjectsHandler needs.
type PropertiesHandler ¶
type PropertiesHandler struct {
// contains filtered or unexported fields
}
func NewPropertiesHandler ¶
func NewPropertiesHandler(log *logger.Logger, db LicenseStore, blobs storage.BlobStore) *PropertiesHandler
NewPropertiesHandler returns the artifact properties handler. blobs is the store read to re-evaluate license policies on the artifact's own declared licenses when a license property changes.
func (*PropertiesHandler) RegisterRoutes ¶
func (h *PropertiesHandler) RegisterRoutes(r chi.Router, pathPrefix string)
type PublishTimeSource ¶ added in v0.16.0
type PublishTimeSource interface {
PublishTime(ctx context.Context, repo *models.Repository, pkg, version string) (time.Time, bool)
HeldBackVersions(ctx context.Context, repo *models.Repository, pkg string) ([]proxy.HeldBack, bool, error)
}
PublishTimeSource is the publish time an upstream states for a package version of a proxy repository, read from the metadata already cached. It is satisfied by *proxy.Service.
type QuotasHandler ¶
type QuotasHandler struct {
// contains filtered or unexported fields
}
func NewQuotasHandler ¶
func NewQuotasHandler(log *logger.Logger, db QuotasStore, evaluator *auth.Evaluator) *QuotasHandler
func (*QuotasHandler) RegisterAdminRoutes ¶ added in v0.11.0
func (h *QuotasHandler) RegisterAdminRoutes(r chi.Router)
RegisterAdminRoutes registers the instance-wide quota overview.
func (*QuotasHandler) RegisterRoutes ¶
func (h *QuotasHandler) RegisterRoutes(r chi.Router, pathPrefix string)
type QuotasStore ¶ added in v0.15.0
type QuotasStore interface {
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetProjectQuota(ctx context.Context, projectID string) (*models.ProjectQuota, error)
GetRepositoryUsage(ctx context.Context, repoID string) (*models.RepositoryUsage, error)
ListQuotaOverview(ctx context.Context, params models.QuotaListParams) ([]*models.QuotaOverview, int, error)
ReconcileStorageUsage(ctx context.Context, repoID string) (*models.StorageQuota, error)
UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
// contains filtered or unexported methods
}
QuotasStore is the part of the database QuotasHandler needs.
type RPMUploadHandler ¶
type RPMUploadHandler struct {
// contains filtered or unexported fields
}
func NewRPMUploadHandler ¶
func NewRPMUploadHandler(log *logger.Logger, db RPMUploadStore, blobStore storage.BlobStore, reg *metrics.Registry) *RPMUploadHandler
func (*RPMUploadHandler) Register ¶
func (h *RPMUploadHandler) Register(router chi.Router)
func (*RPMUploadHandler) SetDebWorker ¶
func (h *RPMUploadHandler) SetDebWorker(w *worker.DebMetadataWorker)
func (*RPMUploadHandler) SetKeyResolver ¶ added in v0.8.0
func (h *RPMUploadHandler) SetKeyResolver(r gpg.Resolver)
SetKeyResolver wires the signing keys used by repositories with sign_packages.
func (*RPMUploadHandler) SetPackageDeleter ¶ added in v0.8.0
func (h *RPMUploadHandler) SetPackageDeleter(d PackageDeleter)
SetPackageDeleter wires the deleter behind DELETE /repositories/{name}/packages/{id} for every format but deb and rpm, which have handlers of their own.
func (*RPMUploadHandler) SetPublisher ¶ added in v0.2.0
func (h *RPMUploadHandler) SetPublisher(p webhook.Publisher)
SetPublisher wires the webhook publisher used for artifact events. It also covers the embedded deb handler that serves deb repositories on the same routes.
func (*RPMUploadHandler) SetRPMWorker ¶
func (h *RPMUploadHandler) SetRPMWorker(w *worker.RPMetadataWorker)
type RPMUploadStore ¶ added in v0.15.0
type RPMUploadStore interface {
DebUploadStore
CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error
CreateRpmPackage(ctx context.Context, pkg *models.Component) error
GetComponentByFilename(ctx context.Context, repoID string, filename string) (*models.Component, error)
GetComponentByID(ctx context.Context, id string) (*models.Component, error)
GetDB() *sql.DB
GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)
GetRepoMetadataByPath(ctx context.Context, repositoryID string, path string) (*models.RepoMetadata, error)
GetRpmPackageByID(ctx context.Context, id string) (*models.RpmPackage, error)
MarkRepoStale(ctx context.Context, repositoryID string) error
RpmPackageExists(ctx context.Context, repoID string, name string, version string, release string, epoch int, arch string) (bool, error)
UpsertRepoMetadata(ctx context.Context, meta *models.RepoMetadata) error
}
RPMUploadStore is the part of the database RPMUploadHandler needs.
type RecoveryStatusSource ¶ added in v0.9.0
RecoveryStatusSource reports the disaster-recovery journal state.
type ReferrerRegistry ¶ added in v0.8.0
type ReferrerRegistry interface {
AttachReferrer(ctx context.Context, repo *models.Repository, req docker.ReferrerRequest) (*docker.ReferrerResult, error)
FindReferrer(
ctx context.Context,
repo *models.Repository,
image, subjectDigest, artifactType string,
annotations map[string]string,
) (string, error)
}
ReferrerRegistry is the docker registry's way of storing a referrer.
type ReplicationService ¶ added in v0.9.0
type ReplicationService interface {
Status(ctx context.Context) (replication.Status, error)
// RequestVerify asks for a verify pass; false when one is running or requested.
RequestVerify(ctx context.Context) (bool, error)
}
ReplicationService is blob replication as the admin API sees it; *replication.Service implements it.
type RepositoriesHandler ¶
type RepositoriesHandler struct {
// contains filtered or unexported fields
}
func NewRepositoriesHandler ¶
func NewRepositoriesHandler(db RepositoriesStore, log *logger.Logger, evaluator *auth.Evaluator) *RepositoriesHandler
func (*RepositoriesHandler) RegisterAuthed ¶
func (h *RepositoriesHandler) RegisterAuthed(r chi.Router)
func (*RepositoriesHandler) WithBlobStore ¶ added in v0.2.0
func (h *RepositoriesHandler) WithBlobStore(store storage.BlobStore) *RepositoriesHandler
WithBlobStore enables the package download endpoint.
func (*RepositoriesHandler) WithFederation ¶ added in v0.9.0
func (h *RepositoriesHandler) WithFederation(store *federation.Store) *RepositoriesHandler
WithFederation lets repositories be created federated (federation.enabled).
func (*RepositoriesHandler) WithGroupMetadata ¶ added in v0.8.0
func (h *RepositoriesHandler) WithGroupMetadata(n GroupMetadataNotifier) *RepositoriesHandler
WithGroupMetadata makes changes to deb and rpm repositories regenerate the metadata of the groups they belong to.
func (*RepositoriesHandler) WithPublisher ¶ added in v0.2.0
func (h *RepositoriesHandler) WithPublisher(p webhook.Publisher) *RepositoriesHandler
WithPublisher enables repository.created / repository.deleted webhook events.
func (*RepositoriesHandler) WithTasks ¶ added in v0.11.0
func (h *RepositoriesHandler) WithTasks(tasks *bgtask.Runner) *RepositoriesHandler
WithTasks runs the background orphan-blob collections under the server lifecycle: they are cancelled and awaited when the runner shuts down.
type RepositoriesStore ¶ added in v0.15.0
type RepositoriesStore interface {
quarantine.Checker
ArtifactSecurity(ctx context.Context, repoID string, artifactIDs []string) (map[string]models.ArtifactSecurity, error)
CountRepoPackageNames(ctx context.Context, repoIDs []string) (map[string]int64, error)
CreateProjectRepository(ctx context.Context, repo *models.Repository, memberIDs []string, maxRepositories int) error
CreateRepositoryWithMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
DeleteRepository(ctx context.Context, id string) error
GetProject(ctx context.Context, id string) (*models.Project, error)
GetProjectByName(ctx context.Context, name string) (*models.Project, error)
GetRepoComponentBlob(ctx context.Context, repoID string, id string) (*models.ComponentBlob, error)
GetRepoComponentDetail(ctx context.Context, repoID string, id string) (*models.ComponentDetail, error)
GetRepoMetadataByRepo(ctx context.Context, repositoryID string) ([]models.RepoMetadata, error)
GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListComponentsByRepo(ctx context.Context, repoID string, formatFilter string, page int, limit int) ([]*models.Component, int, error)
ListGroupMembers(ctx context.Context, groupRepoID string) ([]*models.RepositoryGroupMember, error)
ListMetadataGroupsOfMember(ctx context.Context, memberRepoID string) ([]string, error)
ListRecentPackages(ctx context.Context, repoIDs []string, limit int) ([]models.RecentPackage, error)
ListRepoPackageRollup(ctx context.Context, opts models.PackageRollupOptions) ([]models.PackageRollup, int, error)
ListRepositories(ctx context.Context, page int, limit int, formatFilter string) ([]*models.Repository, error)
MoveRepositoryToProject(ctx context.Context, repoID string, toProjectID string, maxRepositories int) error
ReplaceGroupMembers(ctx context.Context, groupRepoID string, memberIDs []string) error
RepoCatalogStats(ctx context.Context, repoIDs []string, withLastPublished bool) (map[string]models.RepoStats, error)
UpdateRepository(ctx context.Context, repo *models.Repository) error
UpdateRepositoryAndMembers(ctx context.Context, repo *models.Repository, memberIDs []string) error
// contains filtered or unexported methods
}
RepositoriesStore is the part of the database RepositoriesHandler needs.
type RepositoryActivityHandler ¶ added in v0.11.0
type RepositoryActivityHandler struct {
// contains filtered or unexported fields
}
RepositoryActivityHandler serves the audit feed of one repository.
func NewRepositoryActivityHandler ¶ added in v0.11.0
func NewRepositoryActivityHandler(db RepositoryActivityStore, log *logger.Logger, evaluator *auth.Evaluator) *RepositoryActivityHandler
func (*RepositoryActivityHandler) RegisterAuthed ¶ added in v0.11.0
func (h *RepositoryActivityHandler) RegisterAuthed(r chi.Router)
type RepositoryActivityStore ¶ added in v0.15.0
type RepositoryActivityStore interface {
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
ListAuditLogs(ctx context.Context, params models.AuditListParams) (*models.AuditPage, error)
// contains filtered or unexported methods
}
RepositoryActivityStore is the part of the database RepositoryActivityHandler needs.
type Response ¶
type Response struct {
Success bool `json:"success"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
}
Response represents a standard API response.
type SAMLHandler ¶
type SAMLHandler struct {
// contains filtered or unexported fields
}
func NewSAMLHandler ¶
func (*SAMLHandler) RegisterPublic ¶
func (h *SAMLHandler) RegisterPublic(public chi.Router)
func (*SAMLHandler) WithTrustedProxies ¶ added in v0.2.0
func (h *SAMLHandler) WithTrustedProxies(tp *middleware.TrustedProxies) *SAMLHandler
WithTrustedProxies overrides the reverse-proxy allowlist (default: the configured server.trustedProxies) used to resolve the client IP recorded on new sessions.
type SAMLStore ¶ added in v0.15.0
type SAMLStore interface {
ConsumeSAMLAssertion(ctx context.Context, providerSlug string, assertionID string, expiresAt time.Time) (bool, error)
CreateSystemSettingIfAbsent(ctx context.Context, key string, value string) (bool, error)
CreateUser(ctx context.Context, user *models.User) (*models.User, error)
GetGroupByName(ctx context.Context, name string) (*models.Group, error)
GetOrCreateGroup(ctx context.Context, name string) (*models.Group, error)
GetOrCreatePermissionAssignment(ctx context.Context, targetID string, principalType string, principalID string) error
GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
GetSSOProviderBySlug(ctx context.Context, slug string) (*models.SSOProvider, error)
GetSystemSetting(ctx context.Context, key string) (string, error)
GetUserByEmail(ctx context.Context, email string) (*models.User, error)
GetUserByExternalID(ctx context.Context, externalID string, providerSlug string) (*models.User, error)
GetUserByUsername(ctx context.Context, username string) (*models.User, error)
SyncSSOGroups(ctx context.Context, userID string, groupIDs []string) error
UpdateUserSSO(ctx context.Context, userID string, externalID string, providerSlug string) error
UpdateUserSSOProfile(ctx context.Context, id string, email *string, fullName *string, lastLogin time.Time) error
// contains filtered or unexported methods
}
SAMLStore is the part of the database SAMLHandler needs.
type SBOMHandler ¶
type SBOMHandler struct {
// contains filtered or unexported fields
}
func NewSBOMHandler ¶
func (*SBOMHandler) RegisterAuthed ¶
func (h *SBOMHandler) RegisterAuthed(r chi.Router)
func (*SBOMHandler) WithAttacher ¶ added in v0.8.0
func (h *SBOMHandler) WithAttacher(a *AttestationAttacher) *SBOMHandler
WithAttacher attaches each generated SBOM to its docker image as an OCI referrer in repositories that enabled it.
func (*SBOMHandler) WithAttestation ¶ added in v0.8.0
func (h *SBOMHandler) WithAttestation(svc *attest.Service) *SBOMHandler
WithAttestation enables signed downloads (`?attest=true`).
type SBOMStore ¶ added in v0.15.0
type SBOMStore interface {
BlobReferenceCount(ctx context.Context, sha256 string) (int, error)
CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error
DeleteSBOMReportInRepo(ctx context.Context, repoID string, id string) (string, error)
GetSBOMReportByID(ctx context.Context, repoID string, id string) (*models.SBOMReport, error)
ListSBOMReports(ctx context.Context, repoID string) ([]*models.SBOMReport, error)
// contains filtered or unexported methods
}
SBOMStore is the part of the database SBOMHandler needs.
type SecretsHandler ¶
type SecretsHandler struct {
// contains filtered or unexported fields
}
func NewSecretsHandler ¶
func NewSecretsHandler(db SecretsStore, log *logger.Logger, scanner *secrets.Scanner) *SecretsHandler
func (*SecretsHandler) RegisterRoutes ¶
func (h *SecretsHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)
type SecretsStore ¶ added in v0.15.0
type SecretsStore interface {
CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error
DeleteSecretScanResult(ctx context.Context, repoID string, id string) error
GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
GetPermissionTargetsForPrincipal(ctx context.Context, userID string, groupIDs []string) ([]*models.PermissionTarget, error)
GetProjectByName(ctx context.Context, name string) (*models.Project, error)
GetSecretScanResult(ctx context.Context, repoID string, artifactID string) (*models.SecretScanResult, error)
ListProjectGrantsByUser(ctx context.Context, userID string) ([]*models.ProjectGrant, error)
ListPublicRepositoryNames(ctx context.Context) ([]string, error)
ListSecretScanResults(ctx context.Context, repoID string, flaggedOnly bool) ([]*models.SecretScanResult, error)
QuarantineArtifact(ctx context.Context, repoID string, artifactID string, quarantined bool) error
// contains filtered or unexported methods
}
SecretsStore is the part of the database SecretsHandler needs.
type SecurityHandler ¶ added in v0.11.0
type SecurityHandler struct {
// contains filtered or unexported fields
}
SecurityHandler serves the cross-type security findings (vulnerabilities, licenses, secrets, AI analysis) of every repository, the admin security health and the counts-only security summary of one repository (docs/security/findings.md).
func NewSecurityHandler ¶ added in v0.11.0
func NewSecurityHandler(db SecurityStore, log *logger.Logger, evaluator *auth.Evaluator, scanners *vuln.Registry, generator *sbom.Generator, aiEnabled func(context.Context) bool, ) *SecurityHandler
NewSecurityHandler builds the handler. scanners reports the scanner readiness and generator builds the VEX export; aiEnabled answers whether AI analysis is on and is nil when it is not compiled into the binary.
func (*SecurityHandler) RegisterRoutes ¶ added in v0.11.0
func (h *SecurityHandler) RegisterRoutes(authedRouter chi.Router)
RegisterRoutes registers the security routes on the authenticated router. Findings are for global admins and project maintainers or owners (each sees their projects' repositories); health is administrative; the repository summary needs read access to the repository.
func (*SecurityHandler) WithExploit ¶ added in v0.14.0
func (h *SecurityHandler) WithExploit(e *exploit.Enricher) *SecurityHandler
WithExploit sets the enricher whose EPSS threshold derives the finding priority.
type SecurityStore ¶ added in v0.15.0
type SecurityStore interface {
GetRepositoryByName(ctx context.Context, name string) (*models.Repository, error)
GetRepositoryDependencyTrack(ctx context.Context, repoID string) (*models.RepositoryDependencyTrack, error)
GetSystemSetting(ctx context.Context, key string) (string, error)
LatestFinishedDependencyTrackPush(ctx context.Context) (*models.DependencyTrackLastPush, error)
ListSecurityFindings(ctx context.Context, params models.FindingListParams) (*models.FindingPage, error)
RepoSecuritySummary(ctx context.Context, repoID string, packageName string, version string) (*models.RepoSecuritySummary, error)
SecurityFindingsSummary(ctx context.Context, filter models.FindingFilter) (*models.FindingsSummary, error)
SecurityHealthStats(ctx context.Context) (*models.SecurityHealthStats, error)
SetSystemSetting(ctx context.Context, key string, value string) error
// contains filtered or unexported methods
}
SecurityStore is the part of the database SecurityHandler needs.
type SelfTokensHandler ¶
type SelfTokensHandler struct {
// contains filtered or unexported fields
}
func NewSelfTokensHandler ¶
func NewSelfTokensHandler(db SelfTokensStore, log *logger.Logger, evaluator *auth.Evaluator) *SelfTokensHandler
func (*SelfTokensHandler) Register ¶
func (h *SelfTokensHandler) Register(r chi.Router)
type SelfTokensStore ¶ added in v0.15.0
type SelfTokensStore interface {
GetTokenByID(ctx context.Context, tokenID string) (*models.Token, error)
ListTokensByUser(ctx context.Context, userID string) ([]*models.Token, error)
RevokeToken(ctx context.Context, tokenID string) error
// contains filtered or unexported methods
}
SelfTokensStore is the part of the database SelfTokensHandler needs.
type SystemInfoHandler ¶
type SystemInfoHandler struct {
// contains filtered or unexported fields
}
func NewSystemInfoHandler ¶
func NewSystemInfoHandler( version, commit, buildTime string, db SystemInfoStore, blobStore storage.BlobStore, storageType string, ) *SystemInfoHandler
func (*SystemInfoHandler) RegisterAuthed ¶ added in v0.2.0
func (h *SystemInfoHandler) RegisterAuthed(r chi.Router)
RegisterAuthed registers the detailed endpoint (behind the admin RBAC check).
func (*SystemInfoHandler) RegisterPublic ¶
func (h *SystemInfoHandler) RegisterPublic(r chi.Router)
RegisterPublic registers the unauthenticated, trimmed endpoint: version and an overall status only.
func (*SystemInfoHandler) ServeHTTP ¶
func (h *SystemInfoHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request)
func (*SystemInfoHandler) WithAIAvailable ¶ added in v0.15.0
func (h *SystemInfoHandler) WithAIAvailable(built bool) *SystemInfoHandler
WithAIAvailable sets whether this binary contains AI analysis (it does not when built with -tags noai), advertised as ai_available so the UI hides the AI settings and health entry instead of showing a feature that answers 501.
func (*SystemInfoHandler) WithAPIReference ¶ added in v0.11.0
func (h *SystemInfoHandler) WithAPIReference(enabled bool) *SystemInfoHandler
WithAPIReference sets whether the public info endpoint advertises the interactive API reference (api_reference_enabled), so the UI links it only when it is served.
func (*SystemInfoHandler) WithDocsBaseURL ¶ added in v0.9.0
func (h *SystemInfoHandler) WithDocsBaseURL(base string) *SystemInfoHandler
WithDocsBaseURL sets the documentation site root the public info endpoint advertises as docs_url, resolved against the server version.
type SystemInfoStore ¶ added in v0.15.0
SystemInfoStore is the part of the database SystemInfoHandler needs.
type TierPlanner ¶ added in v0.7.0
type TierPlanner interface {
Plan(ctx context.Context, draft *tiering.Policy, sampleLimit int) (*tiering.Plan, error)
}
TierPlanner simulates policies (the tiering engine).
type TierRegistry ¶ added in v0.7.0
TierRegistry is the tier registry as the admin API sees it.
type TierRunner ¶ added in v0.7.0
type TierRunner interface {
// Trigger asks for an immediate pass; it reports false when one is already running.
Trigger() bool
Status() tiering.RunnerStatus
}
TierRunner is the background mover as the admin API sees it.
type TieringAdminDB ¶ added in v0.7.0
type TieringAdminDB interface {
ListStorageTiers(ctx context.Context) ([]*models.StorageTier, error)
GetStorageTierByName(ctx context.Context, name string) (*models.StorageTier, error)
CreateStorageTier(ctx context.Context, t *models.StorageTier) error
UpdateStorageTier(ctx context.Context, t *models.StorageTier) error
// DeleteStorageTierIfUnused checks and deletes atomically; it returns the
// reason the tier is still in use, or "" once it is deleted.
DeleteStorageTierIfUnused(ctx context.Context, id string) (string, error)
GetStorageBackend(ctx context.Context, name string) (*models.StorageBackend, error)
ListStoragePolicies(ctx context.Context) ([]*models.StoragePolicy, error)
GetStoragePolicy(ctx context.Context, id string) (*models.StoragePolicy, error)
CreateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
UpdateStoragePolicy(ctx context.Context, p *models.StoragePolicy) error
DeleteStoragePolicy(ctx context.Context, id string) (bool, error)
StorageTierUsage(ctx context.Context) ([]models.TierUsage, error)
ListStorageTierMoves(ctx context.Context, limit int) ([]*models.StorageTierMove, error)
CountStorageTierMoves(ctx context.Context) (int64, error)
}
TieringAdminDB is the persistence the tiering admin API needs.
type TrashHandler ¶ added in v0.5.0
type TrashHandler struct {
// contains filtered or unexported fields
}
TrashHandler serves the trash API: listing, restoring and purging soft-deleted packages and repositories.
The global routes (/api/v1/trash...) are admin only. The repository routes (/api/v1/repositories/{name}/trash...) need the repository-scoped `delete` permission and only ever touch items of that repository; emptying a repository's trash needs the repository-scoped `manage` permission.
func NewTrashHandler ¶ added in v0.5.0
func (*TrashHandler) RegisterAuthed ¶ added in v0.5.0
func (h *TrashHandler) RegisterAuthed(r chi.Router)
func (*TrashHandler) WithBlobStore ¶ added in v0.5.0
func (h *TrashHandler) WithBlobStore(store storage.BlobStore) *TrashHandler
WithBlobStore enables freeing blobs when an item is purged.
func (*TrashHandler) WithGroupMetadata ¶ added in v0.8.0
func (h *TrashHandler) WithGroupMetadata(n GroupMetadataNotifier) *TrashHandler
WithGroupMetadata makes restoring a deb or rpm repository regenerate the merged metadata of the groups it belongs to (or its own, for a group).
func (*TrashHandler) WithPublisher ¶ added in v0.5.0
func (h *TrashHandler) WithPublisher(p webhook.Publisher) *TrashHandler
WithPublisher enables the artifact.restored/purged and repository.restored/purged events.
func (*TrashHandler) WithTasks ¶ added in v0.11.0
func (h *TrashHandler) WithTasks(tasks *bgtask.Runner) *TrashHandler
WithTasks runs the background orphan-blob collections under the server lifecycle: they are cancelled and awaited when the runner shuts down.
func (*TrashHandler) WithWorkers ¶ added in v0.15.0
func (h *TrashHandler) WithWorkers(ws *lifecycle.Workers) *TrashHandler
WithWorkers enables the metadata refresh after a restore: the format lifecycles notify the metadata workers in ws.
type TrashOps ¶ added in v0.15.0
type TrashOps interface {
DecrementStorageUsage(ctx context.Context, repoID string, sizeBytes int64, artifactCount int) error
GetRepositoryByID(ctx context.Context, id string) (*models.Repository, error)
MarkPackumentStale(ctx context.Context, packageID string) error
MarkRepoStale(ctx context.Context, repositoryID string) error
// contains filtered or unexported methods
}
TrashOps is the part of the database TrashHandler needs.
type VEXHandler ¶ added in v0.7.0
type VEXHandler struct {
// contains filtered or unexported fields
}
VEXHandler serves VEX documents built from the scan results and manages the admin VEX decisions.
func NewVEXHandler ¶ added in v0.7.0
func (*VEXHandler) RegisterAuthed ¶ added in v0.7.0
func (h *VEXHandler) RegisterAuthed(r chi.Router)
func (*VEXHandler) WithAttestation ¶ added in v0.8.0
func (h *VEXHandler) WithAttestation(svc *attest.Service) *VEXHandler
WithAttestation enables signed documents (`?attest=true`).
type VEXStore ¶ added in v0.15.0
type VEXStore interface {
DeleteVEXStatement(ctx context.Context, repoID string, id string) error
ListVEXStatements(ctx context.Context, repoID string, artifactID string) ([]*models.VEXStatement, error)
UpsertVEXStatement(ctx context.Context, s *models.VEXStatement) error
// contains filtered or unexported methods
}
VEXStore is the part of the database VEXHandler needs.
type VulnHandler ¶
type VulnHandler struct {
// contains filtered or unexported fields
}
VulnHandler handles vulnerability scanning endpoints.
func NewVulnHandler ¶
func NewVulnHandler(db VulnStore, log *logger.Logger, evaluator *auth.Evaluator, scanners *vuln.Registry) *VulnHandler
NewVulnHandler creates a new vulnerability handler. scanners provides the scanner backends and their availability; nil means the defaults (trivy and grype from PATH, no database refresh).
func (*VulnHandler) ForwardScansTo ¶ added in v0.15.0
func (h *VulnHandler) ForwardScansTo(s *workq.Store) *VulnHandler
ForwardScansTo makes the handler hand its scans to a worker process (server.role=web): the scan is stored as "scanning" and a request is written to s, for a process running ServeScansFrom to run. A web process has no scanner installed and reserves no scan slot.
func (*VulnHandler) RegisterOverviewRoutes ¶ added in v0.7.0
func (h *VulnHandler) RegisterOverviewRoutes(authedRouter chi.Router)
RegisterOverviewRoutes registers the cross-repository scan overview, which is not scoped to one repository. Administrative like every scan route: the RBAC middleware requires "manage" on /api/v1/ paths and the handlers check the admin flag again.
func (*VulnHandler) RegisterRoutes ¶
func (h *VulnHandler) RegisterRoutes(authedRouter chi.Router, pathPrefix string)
RegisterRoutes registers vulnerability scanning routes.
func (*VulnHandler) ServeScansFrom ¶ added in v0.15.0
func (h *VulnHandler) ServeScansFrom(c *workq.Consumer)
ServeScansFrom makes the handler run the scans the requests claimed by c ask for, with the same concurrency bound as the scans of its own API.
func (*VulnHandler) WithExploit ¶ added in v0.14.0
func (h *VulnHandler) WithExploit(e *exploit.Enricher) *VulnHandler
WithExploit sets the enricher that marks findings with the CISA KEV and FIRST EPSS signals (the default has no feeds: findings carry their severity as priority).
func (*VulnHandler) WithOSVMirror ¶ added in v0.14.0
func (h *VulnHandler) WithOSVMirror(cfg config.OSVMirrorConfig) *VulnHandler
WithOSVMirror tells the handler how the local OSV mirror is configured, for the status endpoint.
func (*VulnHandler) WithScanHook ¶ added in v0.8.0
func (h *VulnHandler) WithScanHook(f func(repoID, artifactID string)) *VulnHandler
WithScanHook sets a function called after each completed (or partial) scan was stored; the Dependency-Track integration uses it to push fresh results.
func (*VulnHandler) WithTasks ¶ added in v0.11.0
func (h *VulnHandler) WithTasks(tasks *bgtask.Runner) *VulnHandler
WithTasks runs the background scans under the server lifecycle: they are cancelled and awaited when the runner shuts down.
type VulnStore ¶ added in v0.15.0
type VulnStore interface {
CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
DeleteVulnScanResult(ctx context.Context, repoID string, id string) error
GetComponentByID(ctx context.Context, id string) (*models.Component, error)
GetDebPackageByID(ctx context.Context, id string) (*models.DebPackage, error)
GetDebianDistributionsByRepo(ctx context.Context, repoID string) ([]models.DebianDistribution, error)
GetVulnScanResultByID(ctx context.Context, repoID string, id string) (*models.VulnScanResult, error)
ListVulnScanOverview(ctx context.Context, params models.VulnScanListParams) (*models.VulnScanOverviewPage, error)
ListVulnScanResults(ctx context.Context, repoID string, vulnerableOnly bool) ([]*models.VulnScanResult, error)
SetVulnScanQuarantine(ctx context.Context, repoID string, id string, quarantined bool) error
UpdateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
VulnScanOverviewSummary(ctx context.Context, repoName string) (*models.VulnScanSummary, error)
// contains filtered or unexported methods
}
VulnStore is the part of the database VulnHandler needs.
type WebhooksHandler ¶
type WebhooksHandler struct {
// contains filtered or unexported fields
}
func NewWebhooksHandler ¶
func NewWebhooksHandler( db WebhooksStore, log *logger.Logger, evaluator *auth.Evaluator, dispatcher *webhook.Dispatcher, ) *WebhooksHandler
func (*WebhooksHandler) RegisterAuthed ¶
func (h *WebhooksHandler) RegisterAuthed(r chi.Router)
type WebhooksStore ¶ added in v0.15.0
type WebhooksStore interface {
CreateWebhook(ctx context.Context, wh *models.Webhook) error
DeleteWebhook(ctx context.Context, id string) error
GetWebhook(ctx context.Context, id string) (*models.Webhook, error)
ListWebhookDeliveries(ctx context.Context, webhookID string, limit int) ([]*models.WebhookDelivery, error)
ListWebhooks(ctx context.Context, repoID string) ([]*models.Webhook, error)
UpdateWebhook(ctx context.Context, wh *models.Webhook) error
// contains filtered or unexported methods
}
WebhooksStore is the part of the database WebhooksHandler needs.
Source Files
¶
- admin_ai.go
- admin_apk_key.go
- admin_audit.go
- admin_audit_cursor.go
- admin_crud.go
- admin_declarative.go
- admin_gpg.go
- admin_groups.go
- admin_mutation_audit.go
- admin_nix_key.go
- admin_oidc_policies.go
- admin_permissions.go
- admin_recovery.go
- admin_replication.go
- admin_service_accounts.go
- admin_signing_key.go
- admin_sso.go
- admin_sso_oidc.go
- admin_storage.go
- admin_storage_primary.go
- admin_tiering.go
- admin_tokens.go
- admin_users.go
- ai.go
- ai_identity.go
- artifact_detail.go
- attestation.go
- attestation_attach.go
- audit_export.go
- audit_subjects.go
- auth_handlers.go
- auth_helpers.go
- auth_login_trust.go
- backup.go
- branding.go
- bundles.go
- bundles_authz.go
- bundles_promote.go
- bundles_signing.go
- cleanup.go
- cookie.go
- curation.go
- delta.go
- dependency_track.go
- docker_gc.go
- federation.go
- frontend_telemetry.go
- frontend_telemetry_limit.go
- frontend_telemetry_otlp.go
- interfaces.go
- license.go
- license_artifact.go
- maven_parent_license.go
- maven_pom_rescans.go
- oidc_exchange.go
- openapi.go
- package_delete.go
- presigned_multipart.go
- presigned_uploads.go
- projects.go
- projects_activity.go
- projects_audit.go
- projects_cleanup.go
- projects_groups.go
- projects_members.go
- projects_quota.go
- projects_repos.go
- projects_tokens.go
- properties.go
- quotas.go
- quotas_overview.go
- repo_access.go
- repositories.go
- repositories_activity.go
- repositories_catalog_list.go
- repositories_catalog_packages.go
- repositories_project.go
- sbom.go
- scan_export.go
- scan_helpers.go
- secrets.go
- security_export.go
- security_findings.go
- security_health.go
- self_tokens.go
- server.go
- sso_common.go
- sso_oidc_handlers.go
- sso_saml_handlers.go
- system_info.go
- tokens_unified.go
- trash.go
- trash_regen.go
- upload_deb.go
- upload_maven.go
- upload_npm.go
- upload_npm_body.go
- upload_npm_deprecate.go
- upload_rpm.go
- vex.go
- vuln.go
- vuln_distro.go
- vuln_exploit.go
- vuln_osv_mirror.go
- vuln_overview.go
- vuln_overview_cursor.go
- vuln_remote.go
- webhooks.go